From cc23f9cdd76fb926cb3853245cf16cfe9f91fb5e Mon Sep 17 00:00:00 2001 From: gwenn Date: Sun, 20 Nov 2022 18:07:17 +0100 Subject: [PATCH 01/63] Captured identifiers in SQL strings Initial draft --- Cargo.toml | 5 +++ rusqlite-macros/Cargo.toml | 16 +++++++ rusqlite-macros/src/lib.rs | 81 +++++++++++++++++++++++++++++++++++ rusqlite-macros/tests/test.rs | 22 ++++++++++ 4 files changed, 124 insertions(+) create mode 100644 rusqlite-macros/Cargo.toml create mode 100644 rusqlite-macros/src/lib.rs create mode 100644 rusqlite-macros/tests/test.rs diff --git a/Cargo.toml b/Cargo.toml index e813e47..6b609b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -139,6 +139,11 @@ bencher = "0.1" path = "libsqlite3-sys" version = "0.25.0" +# FIXME optional +[dependencies.rusqlite-macros] +path = "rusqlite-macros" +version = "0.1.0" + [[test]] name = "config_log" harness = false diff --git a/rusqlite-macros/Cargo.toml b/rusqlite-macros/Cargo.toml new file mode 100644 index 0000000..af1c040 --- /dev/null +++ b/rusqlite-macros/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "rusqlite-macros" +version = "0.1.0" +authors = ["The rusqlite developers"] +edition = "2021" +description = "Private implementation detail of rusqlite crate" +repository = "https://github.com/rusqlite/rusqlite" +license = "MIT" +categories = ["database"] + +[lib] +proc-macro = true + +[dependencies] +sqlite3-parser = { version = "0.4.0", default-features = false, features = ["YYNOERRORRECOVERY"] } +fallible-iterator = "0.2" diff --git a/rusqlite-macros/src/lib.rs b/rusqlite-macros/src/lib.rs new file mode 100644 index 0000000..a09694e --- /dev/null +++ b/rusqlite-macros/src/lib.rs @@ -0,0 +1,81 @@ +//! Private implementation details of `rusqlite`. + +use proc_macro::{Delimiter, Literal, TokenStream, TokenTree}; + +use fallible_iterator::FallibleIterator; +use sqlite3_parser::lexer::sql::Parser; +use sqlite3_parser::ast::{ParameterInfo, ToTokens}; + +// https://internals.rust-lang.org/t/custom-error-diagnostics-with-procedural-macros-on-almost-stable-rust/8113 + +#[doc(hidden)] +#[proc_macro] +pub fn __bind(input: TokenStream) -> TokenStream { + try_bind(input).unwrap_or_else(|msg| parse_ts(&format!("compile_error!({:?})", msg))) +} + +type Result = std::result::Result; + +fn try_bind(input: TokenStream) -> Result { + //eprintln!("INPUT: {:#?}", input); + let (stmt, literal) = { + let mut iter = input.into_iter(); + let stmt = iter.next().unwrap(); + let _punct = iter.next().unwrap(); + let literal = iter.next().unwrap(); + assert!(iter.next().is_none()); + (stmt, literal) + }; + + let literal = match into_literal(&literal) { + Some(it) => it, + None => return Err("expected a plain string literal".to_string()), + }; + let sql = literal.to_string(); + if !sql.starts_with('"') { + return Err("expected a plain string literal".to_string()); + } + let sql = strip_matches(&sql, "\""); + //eprintln!("SQL: {}", sql); + + let mut parser = Parser::new(sql.as_bytes()); + let ast = match parser.next() { + Ok(None) => return Err("Invalid input".to_owned()), + Err(err) => { + return Err(err.to_string()); + } + Ok(Some(ast)) => ast + }; + let mut info = ParameterInfo::default(); + if let Err(err) = ast.to_tokens(&mut info) { + return Err(err.to_string()); + } + //eprintln!("ParameterInfo.count: {:#?}", info.count); + //eprintln!("ParameterInfo.names: {:#?}", info.names); + + let mut res = TokenStream::new(); + Ok(res) +} + + +fn into_literal(ts: &TokenTree) -> Option { + match ts { + TokenTree::Literal(l) => Some(l.clone()), + TokenTree::Group(g) => match g.delimiter() { + Delimiter::None => match g.stream().into_iter().collect::>().as_slice() { + [TokenTree::Literal(l)] => Some(l.clone()), + _ => None, + }, + Delimiter::Parenthesis | Delimiter::Brace | Delimiter::Bracket => None, + }, + _ => None, + } +} + +fn strip_matches<'a>(s: &'a str, pattern: &str) -> &'a str { + s.strip_prefix(pattern).unwrap_or(s).strip_suffix(pattern).unwrap_or(s) +} + +fn parse_ts(s: &str) -> TokenStream { + s.parse().unwrap() +} diff --git a/rusqlite-macros/tests/test.rs b/rusqlite-macros/tests/test.rs new file mode 100644 index 0000000..e67100f --- /dev/null +++ b/rusqlite-macros/tests/test.rs @@ -0,0 +1,22 @@ +use rusqlite_macros::__bind; + +#[test] +fn test_literal() { + let stmt = (); + __bind!(stmt, "SELECT $name"); +} + +/* FIXME +#[test] +fn test_raw_string() { + let stmt = (); + __bind!((), r#"SELECT 1"#); +} + +#[test] +fn test_const() { + const SQL: &str = "SELECT 1"; + let stmt = (); + __bind!((), SQL); +} +*/ \ No newline at end of file From 5b20201423ed4578c0c1ede25617d3b369a9a88a Mon Sep 17 00:00:00 2001 From: gwenn Date: Sun, 4 Dec 2022 11:25:01 +0100 Subject: [PATCH 02/63] Captured identifiers in SQL strings Use `raw_bind_parameter` --- rusqlite-macros/Cargo.toml | 2 +- rusqlite-macros/src/lib.rs | 28 +++++++++++++++++++++++----- rusqlite-macros/tests/test.rs | 22 ++++++++++++++++++---- 3 files changed, 42 insertions(+), 10 deletions(-) diff --git a/rusqlite-macros/Cargo.toml b/rusqlite-macros/Cargo.toml index af1c040..7dae87a 100644 --- a/rusqlite-macros/Cargo.toml +++ b/rusqlite-macros/Cargo.toml @@ -12,5 +12,5 @@ categories = ["database"] proc-macro = true [dependencies] -sqlite3-parser = { version = "0.4.0", default-features = false, features = ["YYNOERRORRECOVERY"] } +sqlite3-parser = { version = "0.5.0", default-features = false, features = ["YYNOERRORRECOVERY"] } fallible-iterator = "0.2" diff --git a/rusqlite-macros/src/lib.rs b/rusqlite-macros/src/lib.rs index a09694e..cf41258 100644 --- a/rusqlite-macros/src/lib.rs +++ b/rusqlite-macros/src/lib.rs @@ -3,8 +3,8 @@ use proc_macro::{Delimiter, Literal, TokenStream, TokenTree}; use fallible_iterator::FallibleIterator; -use sqlite3_parser::lexer::sql::Parser; use sqlite3_parser::ast::{ParameterInfo, ToTokens}; +use sqlite3_parser::lexer::sql::Parser; // https://internals.rust-lang.org/t/custom-error-diagnostics-with-procedural-macros-on-almost-stable-rust/8113 @@ -19,7 +19,7 @@ type Result = std::result::Result; fn try_bind(input: TokenStream) -> Result { //eprintln!("INPUT: {:#?}", input); let (stmt, literal) = { - let mut iter = input.into_iter(); + let mut iter = input.clone().into_iter(); let stmt = iter.next().unwrap(); let _punct = iter.next().unwrap(); let literal = iter.next().unwrap(); @@ -44,20 +44,35 @@ fn try_bind(input: TokenStream) -> Result { Err(err) => { return Err(err.to_string()); } - Ok(Some(ast)) => ast + Ok(Some(ast)) => ast, }; let mut info = ParameterInfo::default(); if let Err(err) = ast.to_tokens(&mut info) { return Err(err.to_string()); } + if info.count == 0 { + return Ok(input); + } //eprintln!("ParameterInfo.count: {:#?}", info.count); //eprintln!("ParameterInfo.names: {:#?}", info.names); + if info.count as usize != info.names.len() { + return Err("Mixing named and numbered parameters is not supported.".to_string()); + } let mut res = TokenStream::new(); + for (i, name) in info.names.iter().enumerate() { + //eprintln!("(i: {}, name: {})", i + 1, &name[1..]); + res.extend(Some(stmt.clone())); + res.extend(parse_ts(&format!( + ".raw_bind_parameter({}, &{})?;", + i + 1, + &name[1..] + ))); + } + Ok(res) } - fn into_literal(ts: &TokenTree) -> Option { match ts { TokenTree::Literal(l) => Some(l.clone()), @@ -73,7 +88,10 @@ fn into_literal(ts: &TokenTree) -> Option { } fn strip_matches<'a>(s: &'a str, pattern: &str) -> &'a str { - s.strip_prefix(pattern).unwrap_or(s).strip_suffix(pattern).unwrap_or(s) + s.strip_prefix(pattern) + .unwrap_or(s) + .strip_suffix(pattern) + .unwrap_or(s) } fn parse_ts(s: &str) -> TokenStream { diff --git a/rusqlite-macros/tests/test.rs b/rusqlite-macros/tests/test.rs index e67100f..7a97ae4 100644 --- a/rusqlite-macros/tests/test.rs +++ b/rusqlite-macros/tests/test.rs @@ -1,9 +1,23 @@ use rusqlite_macros::__bind; +type Result = std::result::Result<(), String>; + +struct Stmt; + +impl Stmt { + pub fn raw_bind_parameter(&mut self, one_based_col_index: usize, param: &str) -> Result { + let (..) = (one_based_col_index, param); + Ok(()) + } +} + #[test] -fn test_literal() { - let stmt = (); - __bind!(stmt, "SELECT $name"); +fn test_literal() -> Result { + let first_name = "El"; + let last_name = "Barto"; + let mut stmt = Stmt; + __bind!(stmt, "SELECT $first_name, $last_name"); + Ok(()) } /* FIXME @@ -19,4 +33,4 @@ fn test_const() { let stmt = (); __bind!((), SQL); } -*/ \ No newline at end of file +*/ From 78b7c521054d57b95a3fec4d0531ebb54ffd22fc Mon Sep 17 00:00:00 2001 From: gwenn Date: Mon, 26 Dec 2022 20:00:59 +0100 Subject: [PATCH 03/63] Captured identifiers in SQL strings Introduce macro_rules `prepare_and_bind` and `prepare_cached_and_bind` --- src/lib.rs | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index da07327..f0ba603 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -85,6 +85,8 @@ pub use crate::statement::{Statement, StatementStatus}; pub use crate::transaction::{DropBehavior, Savepoint, Transaction, TransactionBehavior}; pub use crate::types::ToSql; pub use crate::version::*; +#[doc(hidden)] +pub use rusqlite_macros::__bind; mod error; @@ -219,6 +221,30 @@ macro_rules! named_params { }; } +/// Captured identifiers in SQL +#[macro_export] +macro_rules! prepare_and_bind { + ($conn:expr, $sql:literal) => {{ + #[cfg(trick_rust_analyzer_into_highlighting_interpolated_bits)] + format_args!($sql); + let mut stmt = $conn.prepare($sql)?; + $crate::__bind!(stmt, $sql); + stmt + }}; +} + +/// Captured identifiers in SQL +#[macro_export] +macro_rules! prepare_cached_and_bind { + ($conn:expr, $sql:literal) => {{ + #[cfg(trick_rust_analyzer_into_highlighting_interpolated_bits)] + format_args!($sql); + let mut stmt = $conn.prepare_cached($sql)?; + $crate::__bind!(stmt, $sql); + stmt + }}; +} + /// A typedef of the result returned by many methods. pub type Result = result::Result; @@ -2088,9 +2114,20 @@ mod test { } #[test] - pub fn db_readonly() -> Result<()> { + fn db_readonly() -> Result<()> { let db = Connection::open_in_memory()?; assert!(!db.is_readonly(MAIN_DB)?); Ok(()) } + + #[test] + fn prepare_and_bind() -> Result<()> { + let db = Connection::open_in_memory()?; + let name = "Lisa"; + let age = 8; + let mut stmt = prepare_and_bind!(db, "SELECT $name, $age;"); + let (v1, v2) = stmt.raw_query().get_expected_row().and_then(|r| Ok((r.get::<_,String>(0)?, r.get::<_,i64>(1)?)))?; + assert_eq!((v1.as_str(), v2), (name, age)); + Ok(()) + } } From b59b0ddf2e3906716abe3756f09217d57d3589ee Mon Sep 17 00:00:00 2001 From: gwenn Date: Sun, 16 Apr 2023 16:17:36 +0200 Subject: [PATCH 04/63] Bump sqlite3-parser version --- libsqlite3-sys/build.rs | 1 + rusqlite-macros/Cargo.toml | 2 +- rusqlite-macros/src/lib.rs | 1 - rusqlite-macros/tests/test.rs | 6 +++--- src/lib.rs | 7 ++++--- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/libsqlite3-sys/build.rs b/libsqlite3-sys/build.rs index e3c065a..da785e4 100644 --- a/libsqlite3-sys/build.rs +++ b/libsqlite3-sys/build.rs @@ -497,6 +497,7 @@ mod bindings { None } } + fn item_name(&self, original_item_name: &str) -> Option { original_item_name .strip_prefix("sqlite3_index_info_") diff --git a/rusqlite-macros/Cargo.toml b/rusqlite-macros/Cargo.toml index 7dae87a..5c5db10 100644 --- a/rusqlite-macros/Cargo.toml +++ b/rusqlite-macros/Cargo.toml @@ -12,5 +12,5 @@ categories = ["database"] proc-macro = true [dependencies] -sqlite3-parser = { version = "0.5.0", default-features = false, features = ["YYNOERRORRECOVERY"] } +sqlite3-parser = { version = "0.7.0", default-features = false, features = ["YYNOERRORRECOVERY"] } fallible-iterator = "0.2" diff --git a/rusqlite-macros/src/lib.rs b/rusqlite-macros/src/lib.rs index cf41258..2369639 100644 --- a/rusqlite-macros/src/lib.rs +++ b/rusqlite-macros/src/lib.rs @@ -21,7 +21,6 @@ fn try_bind(input: TokenStream) -> Result { let (stmt, literal) = { let mut iter = input.clone().into_iter(); let stmt = iter.next().unwrap(); - let _punct = iter.next().unwrap(); let literal = iter.next().unwrap(); assert!(iter.next().is_none()); (stmt, literal) diff --git a/rusqlite-macros/tests/test.rs b/rusqlite-macros/tests/test.rs index 7a97ae4..785ca9b 100644 --- a/rusqlite-macros/tests/test.rs +++ b/rusqlite-macros/tests/test.rs @@ -16,7 +16,7 @@ fn test_literal() -> Result { let first_name = "El"; let last_name = "Barto"; let mut stmt = Stmt; - __bind!(stmt, "SELECT $first_name, $last_name"); + __bind!(stmt "SELECT $first_name, $last_name"); Ok(()) } @@ -24,13 +24,13 @@ fn test_literal() -> Result { #[test] fn test_raw_string() { let stmt = (); - __bind!((), r#"SELECT 1"#); + __bind!(stmt r#"SELECT 1"#); } #[test] fn test_const() { const SQL: &str = "SELECT 1"; let stmt = (); - __bind!((), SQL); + __bind!(stmt SQL); } */ diff --git a/src/lib.rs b/src/lib.rs index 7f95735..1b3b17e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -221,7 +221,7 @@ macro_rules! prepare_and_bind { #[cfg(trick_rust_analyzer_into_highlighting_interpolated_bits)] format_args!($sql); let mut stmt = $conn.prepare($sql)?; - $crate::__bind!(stmt, $sql); + $crate::__bind!(stmt $sql); stmt }}; } @@ -233,7 +233,7 @@ macro_rules! prepare_cached_and_bind { #[cfg(trick_rust_analyzer_into_highlighting_interpolated_bits)] format_args!($sql); let mut stmt = $conn.prepare_cached($sql)?; - $crate::__bind!(stmt, $sql); + $crate::__bind!(stmt $sql); stmt }}; } @@ -923,7 +923,8 @@ impl Connection { /// /// This function is unsafe because improper use may impact the Connection. /// In particular, it should only be called on connections created - /// and owned by the caller, e.g. as a result of calling ffi::sqlite3_open(). + /// and owned by the caller, e.g. as a result of calling + /// ffi::sqlite3_open(). #[inline] pub unsafe fn from_handle_owned(db: *mut ffi::sqlite3) -> Result { let db = InnerConnection::new(db, true); From 0e369ba878c4e5915049fdfed931c6ff56af876d Mon Sep 17 00:00:00 2001 From: gwenn Date: Sun, 16 Apr 2023 18:09:15 +0200 Subject: [PATCH 05/63] Misc --- src/busy.rs | 2 +- src/lib.rs | 6 +++++- src/vtab/vtablog.rs | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/busy.rs b/src/busy.rs index b9a5d40..18fa7e2 100644 --- a/src/busy.rs +++ b/src/busy.rs @@ -1,4 +1,4 @@ -///! Busy handler (when the database is locked) +//! Busy handler (when the database is locked) use std::convert::TryInto; use std::mem; use std::os::raw::{c_int, c_void}; diff --git a/src/lib.rs b/src/lib.rs index 1b3b17e..49ab436 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2120,7 +2120,11 @@ mod test { let name = "Lisa"; let age = 8; let mut stmt = prepare_and_bind!(db, "SELECT $name, $age;"); - let (v1, v2) = stmt.raw_query().get_expected_row().and_then(|r| Ok((r.get::<_,String>(0)?, r.get::<_,i64>(1)?)))?; + let (v1, v2) = stmt + .raw_query() + .next() + .and_then(|o| o.ok_or(Error::QueryReturnedNoRows)) + .and_then(|r| Ok((r.get::<_, String>(0)?, r.get::<_, i64>(1)?)))?; assert_eq!((v1.as_str(), v2), (name, age)); Ok(()) } diff --git a/src/vtab/vtablog.rs b/src/vtab/vtablog.rs index 1b3e1b8..f7aa1b1 100644 --- a/src/vtab/vtablog.rs +++ b/src/vtab/vtablog.rs @@ -1,4 +1,4 @@ -///! Port of C [vtablog](http://www.sqlite.org/cgi/src/finfo?name=ext/misc/vtablog.c) +//! Port of C [vtablog](http://www.sqlite.org/cgi/src/finfo?name=ext/misc/vtablog.c) use std::default::Default; use std::marker::PhantomData; use std::os::raw::c_int; From 5534eb93c63a5f199583224bbf284d42e11ea09d Mon Sep 17 00:00:00 2001 From: Konstantin Shabanov Date: Thu, 25 May 2023 19:33:39 +0600 Subject: [PATCH 06/63] Improve wasm32-wasi support [Starting from 3.41.0 SQLite has wasm32-wasi support out of the box.][0] - Set `-DSQLITE_THREADSAFE=0`. Fixes: ``` $ wasmtime target/wasm32-wasi/release/examples/persons.wasm Error: failed to run main module `target/wasm32-wasi/release/examples/persons.wasm` Caused by: 0: failed to instantiate "target/wasm32-wasi/release/examples/persons.wasm" 1: unknown import: `env::pthread_mutexattr_init` has not been defined ``` - Drop `-DSQLITE_OS_OTHER`. Fixes: ``` $ wasmtime target/wasm32-wasi/release/examples/persons.wasm Error: failed to run main module `target/wasm32-wasi/release/examples/persons.wasm` Caused by: 0: failed to instantiate "target/wasm32-wasi/release/examples/persons.wasm" 1: unknown import: `env::sqlite3_os_init` has not been defined ``` - [Add wasi specific build flags][1] - Add basic example - Also, add instructions how to run it against wasm32-wasi. Using of file databases is also working, though `--mapdir` arg should be provided to `wasmtime run`. [0]: https://wasmlabs.dev/articles/sqlite-wasi-support/ [1]: https://github.com/vmware-labs/webassembly-language-runtimes/blob/main/libs/sqlite/wasi-patches/wlr-build.sh#L11 --- examples/persons/README.md | 28 +++++++++++++++++++++++++ examples/persons/main.rs | 42 ++++++++++++++++++++++++++++++++++++++ libsqlite3-sys/build.rs | 11 +++++++--- 3 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 examples/persons/README.md create mode 100644 examples/persons/main.rs diff --git a/examples/persons/README.md b/examples/persons/README.md new file mode 100644 index 0000000..edea920 --- /dev/null +++ b/examples/persons/README.md @@ -0,0 +1,28 @@ +# Persons example + +## Run + +``` +$ cargo run --example persons +``` + +## Run (wasm32-wasi) + +### Requisites + +- [wasi-sdk](https://github.com/WebAssembly/wasi-sdk) +- [wasmtime](https://wasmtime.dev/) + +``` +# Set to wasi-sdk directory +$ export WASI_SDK_PATH=`` +$ export CC_wasm32_wasi="${WASI_SDK_PATH}/bin/clang --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot" +# Build +$ cargo build --example persons --target wasm32-wasi --release --features bundled +# Run +$ wasmtime target/wasm32-wasi/release/examples/persons.wasm +Found persons: +ID: 1, Name: Steven +ID: 2, Name: John +ID: 3, Name: Alex +``` diff --git a/examples/persons/main.rs b/examples/persons/main.rs new file mode 100644 index 0000000..a1a94ae --- /dev/null +++ b/examples/persons/main.rs @@ -0,0 +1,42 @@ +extern crate rusqlite; +use rusqlite::{Connection, Result}; + +struct Person { + id: i32, + name: String, +} +fn main() -> Result<()> { + let conn = Connection::open_in_memory()?; + + conn.execute( + "CREATE TABLE IF NOT EXISTS persons ( + id INTEGER PRIMARY KEY, + name TEXT NOT NULL + )", + (), // empty list of parameters. + )?; + + conn.execute( + "INSERT INTO persons (name) VALUES (?1), (?2), (?3)", + ["Steven", "John", "Alex"].map(|n| n.to_string()), + )?; + + let mut stmt = conn.prepare("SELECT id, name FROM persons")?; + let rows = stmt.query_map([], |row| { + Ok(Person { + id: row.get(0)?, + name: row.get(1)?, + }) + })?; + + println!("Found persons:"); + + for person in rows { + match person { + Ok(p) => println!("ID: {}, Name: {}", p.id, p.name), + Err(e) => eprintln!("Error: {:?}", e), + } + } + + Ok(()) +} diff --git a/libsqlite3-sys/build.rs b/libsqlite3-sys/build.rs index 37cbb79..48af5da 100644 --- a/libsqlite3-sys/build.rs +++ b/libsqlite3-sys/build.rs @@ -239,11 +239,16 @@ mod build_bundled { if !win_target() { cfg.flag("-DHAVE_LOCALTIME_R"); } - // Target wasm32-wasi can't compile the default VFS if env::var("TARGET").map_or(false, |v| v == "wasm32-wasi") { - cfg.flag("-DSQLITE_OS_OTHER") + cfg.flag("-USQLITE_THREADSAFE") + .flag("-DSQLITE_THREADSAFE=0") // https://github.com/rust-lang/rust/issues/74393 - .flag("-DLONGDOUBLE_TYPE=double"); + .flag("-DLONGDOUBLE_TYPE=double") + .flag("-D_WASI_EMULATED_MMAN") + .flag("-D_WASI_EMULATED_GETPID") + .flag("-D_WASI_EMULATED_SIGNAL") + .flag("-D_WASI_EMULATED_PROCESS_CLOCKS"); + if cfg!(feature = "wasm32-wasi-vfs") { cfg.file("sqlite3/wasm32-wasi-vfs.c"); } From f0670ccaddf3fa2fc0c8ba6a6c7e3c1b015f3908 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 10 Jun 2023 10:55:52 +0200 Subject: [PATCH 07/63] Fix macro hygiene issue --- rusqlite-macros/src/lib.rs | 34 ++++++++++++++++++++++++++++------ src/lib.rs | 25 +++++++++++++++++++++---- 2 files changed, 49 insertions(+), 10 deletions(-) diff --git a/rusqlite-macros/src/lib.rs b/rusqlite-macros/src/lib.rs index 2369639..7bfda9d 100644 --- a/rusqlite-macros/src/lib.rs +++ b/rusqlite-macros/src/lib.rs @@ -1,6 +1,6 @@ //! Private implementation details of `rusqlite`. -use proc_macro::{Delimiter, Literal, TokenStream, TokenTree}; +use proc_macro::{Delimiter, Group, Literal, Span, TokenStream, TokenTree}; use fallible_iterator::FallibleIterator; use sqlite3_parser::ast::{ParameterInfo, ToTokens}; @@ -58,15 +58,19 @@ fn try_bind(input: TokenStream) -> Result { return Err("Mixing named and numbered parameters is not supported.".to_string()); } + let call_site = literal.span(); let mut res = TokenStream::new(); for (i, name) in info.names.iter().enumerate() { //eprintln!("(i: {}, name: {})", i + 1, &name[1..]); res.extend(Some(stmt.clone())); - res.extend(parse_ts(&format!( - ".raw_bind_parameter({}, &{})?;", - i + 1, - &name[1..] - ))); + res.extend(respan( + parse_ts(&format!( + ".raw_bind_parameter({}, &{})?;", + i + 1, + &name[1..] + )), + call_site, + )); } Ok(res) @@ -93,6 +97,24 @@ fn strip_matches<'a>(s: &'a str, pattern: &str) -> &'a str { .unwrap_or(s) } +fn respan(ts: TokenStream, span: Span) -> TokenStream { + let mut res = TokenStream::new(); + for tt in ts { + let tt = match tt { + TokenTree::Ident(mut ident) => { + ident.set_span(ident.span().resolved_at(span).located_at(span)); + TokenTree::Ident(ident) + } + TokenTree::Group(group) => { + TokenTree::Group(Group::new(group.delimiter(), respan(group.stream(), span))) + } + _ => tt, + }; + res.extend(Some(tt)) + } + res +} + fn parse_ts(s: &str) -> TokenStream { s.parse().unwrap() } diff --git a/src/lib.rs b/src/lib.rs index 49ab436..3f6f1c4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -215,11 +215,26 @@ macro_rules! named_params { } /// Captured identifiers in SQL +/// +/// * only SQLite `$x` / `@x` / `:x` syntax works (Rust `&x` syntax does not +/// work). +/// * `$x.y` expression does not work. +/// +/// # Example +/// +/// ```rust, no_run +/// # use rusqlite::{prepare_and_bind, Connection, Result, Statement}; +/// +/// fn misc(db: &Connection) -> Result { +/// let name = "Lisa"; +/// let age = 8; +/// let smart = true; +/// Ok(prepare_and_bind!(db, "SELECT $name, @age, :smart;")) +/// } +/// ``` #[macro_export] macro_rules! prepare_and_bind { ($conn:expr, $sql:literal) => {{ - #[cfg(trick_rust_analyzer_into_highlighting_interpolated_bits)] - format_args!($sql); let mut stmt = $conn.prepare($sql)?; $crate::__bind!(stmt $sql); stmt @@ -227,11 +242,13 @@ macro_rules! prepare_and_bind { } /// Captured identifiers in SQL +/// +/// * only SQLite `$x` / `@x` / `:x` syntax works (Rust `&x` syntax does not +/// work). +/// * `$x.y` expression does not work. #[macro_export] macro_rules! prepare_cached_and_bind { ($conn:expr, $sql:literal) => {{ - #[cfg(trick_rust_analyzer_into_highlighting_interpolated_bits)] - format_args!($sql); let mut stmt = $conn.prepare_cached($sql)?; $crate::__bind!(stmt $sql); stmt From 759471172194cd9952f338ef3a6eaac636700972 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 10 Jun 2023 12:05:55 +0200 Subject: [PATCH 08/63] Make rusqlite-macros optional --- Cargo.toml | 7 ++----- rusqlite-macros/Cargo.toml | 4 ++-- rusqlite-macros/src/lib.rs | 5 ----- src/lib.rs | 5 +++++ 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8c163c9..eca3e34 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -122,6 +122,7 @@ fallible-iterator = "0.2" fallible-streaming-iterator = "0.1" uuid = { version = "1.0", optional = true } smallvec = "1.6.1" +rusqlite-macros = { path = "rusqlite-macros", version = "0.1.0", optional = true } [dev-dependencies] doc-comment = "0.3" @@ -133,16 +134,12 @@ unicase = "2.6.0" # Use `bencher` over criterion because it builds much faster and we don't have # many benchmarks bencher = "0.1" +rusqlite-macros = { path = "rusqlite-macros", version = "0.1.0" } [dependencies.libsqlite3-sys] path = "libsqlite3-sys" version = "0.26.0" -# FIXME optional -[dependencies.rusqlite-macros] -path = "rusqlite-macros" -version = "0.1.0" - [[test]] name = "config_log" harness = false diff --git a/rusqlite-macros/Cargo.toml b/rusqlite-macros/Cargo.toml index 5c5db10..3d40775 100644 --- a/rusqlite-macros/Cargo.toml +++ b/rusqlite-macros/Cargo.toml @@ -12,5 +12,5 @@ categories = ["database"] proc-macro = true [dependencies] -sqlite3-parser = { version = "0.7.0", default-features = false, features = ["YYNOERRORRECOVERY"] } -fallible-iterator = "0.2" +sqlite3-parser = { version = "0.9", default-features = false, features = ["YYNOERRORRECOVERY"] } +fallible-iterator = "0.3" diff --git a/rusqlite-macros/src/lib.rs b/rusqlite-macros/src/lib.rs index 7bfda9d..8dda22c 100644 --- a/rusqlite-macros/src/lib.rs +++ b/rusqlite-macros/src/lib.rs @@ -17,7 +17,6 @@ pub fn __bind(input: TokenStream) -> TokenStream { type Result = std::result::Result; fn try_bind(input: TokenStream) -> Result { - //eprintln!("INPUT: {:#?}", input); let (stmt, literal) = { let mut iter = input.clone().into_iter(); let stmt = iter.next().unwrap(); @@ -35,7 +34,6 @@ fn try_bind(input: TokenStream) -> Result { return Err("expected a plain string literal".to_string()); } let sql = strip_matches(&sql, "\""); - //eprintln!("SQL: {}", sql); let mut parser = Parser::new(sql.as_bytes()); let ast = match parser.next() { @@ -52,8 +50,6 @@ fn try_bind(input: TokenStream) -> Result { if info.count == 0 { return Ok(input); } - //eprintln!("ParameterInfo.count: {:#?}", info.count); - //eprintln!("ParameterInfo.names: {:#?}", info.names); if info.count as usize != info.names.len() { return Err("Mixing named and numbered parameters is not supported.".to_string()); } @@ -61,7 +57,6 @@ fn try_bind(input: TokenStream) -> Result { let call_site = literal.span(); let mut res = TokenStream::new(); for (i, name) in info.names.iter().enumerate() { - //eprintln!("(i: {}, name: {})", i + 1, &name[1..]); res.extend(Some(stmt.clone())); res.extend(respan( parse_ts(&format!( diff --git a/src/lib.rs b/src/lib.rs index 3f6f1c4..12a5d31 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -85,6 +85,7 @@ pub use crate::statement::{Statement, StatementStatus}; pub use crate::transaction::{DropBehavior, Savepoint, Transaction, TransactionBehavior}; pub use crate::types::ToSql; pub use crate::version::*; +#[cfg(feature = "rusqlite-macros")] #[doc(hidden)] pub use rusqlite_macros::__bind; @@ -232,6 +233,8 @@ macro_rules! named_params { /// Ok(prepare_and_bind!(db, "SELECT $name, @age, :smart;")) /// } /// ``` +#[cfg(feature = "rusqlite-macros")] +#[cfg_attr(docsrs, doc(cfg(feature = "rusqlite-macros")))] #[macro_export] macro_rules! prepare_and_bind { ($conn:expr, $sql:literal) => {{ @@ -246,6 +249,8 @@ macro_rules! prepare_and_bind { /// * only SQLite `$x` / `@x` / `:x` syntax works (Rust `&x` syntax does not /// work). /// * `$x.y` expression does not work. +#[cfg(feature = "rusqlite-macros")] +#[cfg_attr(docsrs, doc(cfg(feature = "rusqlite-macros")))] #[macro_export] macro_rules! prepare_cached_and_bind { ($conn:expr, $sql:literal) => {{ From 048a442bc6886a9f561dd8058aea9b3ed738dab0 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 10 Jun 2023 12:14:41 +0200 Subject: [PATCH 09/63] Fix test build error --- Cargo.toml | 3 +-- src/lib.rs | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index eca3e34..fba0ccd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -134,7 +134,6 @@ unicase = "2.6.0" # Use `bencher` over criterion because it builds much faster and we don't have # many benchmarks bencher = "0.1" -rusqlite-macros = { path = "rusqlite-macros", version = "0.1.0" } [dependencies.libsqlite3-sys] path = "libsqlite3-sys" @@ -159,7 +158,7 @@ name = "exec" harness = false [package.metadata.docs.rs] -features = ["modern-full"] +features = ["modern-full", "rusqlite-macros"] all-features = false no-default-features = true default-target = "x86_64-unknown-linux-gnu" diff --git a/src/lib.rs b/src/lib.rs index 12a5d31..b390a42 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2137,6 +2137,7 @@ mod test { } #[test] + #[cfg(feature = "rusqlite-macros")] fn prepare_and_bind() -> Result<()> { let db = Connection::open_in_memory()?; let name = "Lisa"; From 1308cdaa9dce731131bfdbfe18ee4bce9c7662a9 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sun, 9 Jul 2023 10:39:21 +0200 Subject: [PATCH 10/63] Loadable extension --- Cargo.toml | 1 + libsqlite3-sys/Cargo.toml | 12 +- .../bindgen-bindings/bindgen_3.14.0_ext.rs | 6578 ++++++++++++++ libsqlite3-sys/build.rs | 272 +- .../sqlite3/bindgen_bundled_version_ext.rs | 7831 +++++++++++++++++ libsqlite3-sys/upgrade.sh | 23 +- libsqlite3-sys/upgrade_sqlcipher.sh | 2 +- libsqlite3-sys/wrapper_ext.h | 2 + src/inner_connection.rs | 6 +- src/trace.rs | 8 +- tests/deny_single_threaded_sqlite_config.rs | 6 +- 11 files changed, 14701 insertions(+), 40 deletions(-) create mode 100644 libsqlite3-sys/bindgen-bindings/bindgen_3.14.0_ext.rs create mode 100644 libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs create mode 100644 libsqlite3-sys/wrapper_ext.h diff --git a/Cargo.toml b/Cargo.toml index e8a668c..38f5937 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,6 +50,7 @@ bundled-sqlcipher = ["libsqlite3-sys/bundled-sqlcipher", "bundled"] bundled-sqlcipher-vendored-openssl = ["libsqlite3-sys/bundled-sqlcipher-vendored-openssl", "bundled-sqlcipher"] buildtime_bindgen = ["libsqlite3-sys/buildtime_bindgen"] limits = [] +loadable_extension = ["libsqlite3-sys/loadable_extension"] hooks = [] i128_blob = [] sqlcipher = ["libsqlite3-sys/sqlcipher"] diff --git a/libsqlite3-sys/Cargo.toml b/libsqlite3-sys/Cargo.toml index e926668..1b5fd59 100644 --- a/libsqlite3-sys/Cargo.toml +++ b/libsqlite3-sys/Cargo.toml @@ -2,7 +2,7 @@ name = "libsqlite3-sys" version = "0.26.0" authors = ["The rusqlite developers"] -edition = "2018" +edition = "2021" repository = "https://github.com/rusqlite/rusqlite" description = "Native bindings to the libsqlite3 library" license = "MIT" @@ -23,6 +23,7 @@ min_sqlite_version_3_14_0 = ["pkg-config", "vcpkg"] # Bundle only the bindings file. Note that this does nothing if # `buildtime_bindgen` is enabled. bundled_bindings = [] +loadable_extension = ["atomic", "prettyplease", "quote", "regex", "syn"] # sqlite3_unlock_notify >= 3.6.12 unlock_notify = [] # 3.13.0 @@ -42,9 +43,18 @@ winsqlite3 = [] [dependencies] openssl-sys = { version = "0.9", optional = true } +atomic = { version = "0.5", optional = true } [build-dependencies] bindgen = { version = "0.66", optional = true, default-features = false, features = ["runtime"] } pkg-config = { version = "0.3.19", optional = true } cc = { version = "1.0", optional = true } vcpkg = { version = "0.2", optional = true } +# for loadable_extension: +prettyplease = {version = "0.2", optional = true } +# like bindgen +quote = { version = "1", optional = true, default-features = false } +# like bindgen +regex = { version = "1.5", optional = true, default-features = false, features = ["std", "unicode"] } +# like bindgen +syn = { version = "2.0", optional = true, features = ["full", "extra-traits", "visit-mut"] } diff --git a/libsqlite3-sys/bindgen-bindings/bindgen_3.14.0_ext.rs b/libsqlite3-sys/bindgen-bindings/bindgen_3.14.0_ext.rs new file mode 100644 index 0000000..cc6a1a2 --- /dev/null +++ b/libsqlite3-sys/bindgen-bindings/bindgen_3.14.0_ext.rs @@ -0,0 +1,6578 @@ +/* automatically generated by rust-bindgen 0.66.1 */ + +pub const SQLITE_VERSION: &[u8; 7] = b"3.14.0\0"; +pub const SQLITE_VERSION_NUMBER: i32 = 3014000; +pub const SQLITE_SOURCE_ID: &[u8; 61] = + b"2016-08-08 13:40:27 d5e98057028abcf7217d0d2b2e29bbbcdf09d6de\0"; +pub const SQLITE_OK: i32 = 0; +pub const SQLITE_ERROR: i32 = 1; +pub const SQLITE_INTERNAL: i32 = 2; +pub const SQLITE_PERM: i32 = 3; +pub const SQLITE_ABORT: i32 = 4; +pub const SQLITE_BUSY: i32 = 5; +pub const SQLITE_LOCKED: i32 = 6; +pub const SQLITE_NOMEM: i32 = 7; +pub const SQLITE_READONLY: i32 = 8; +pub const SQLITE_INTERRUPT: i32 = 9; +pub const SQLITE_IOERR: i32 = 10; +pub const SQLITE_CORRUPT: i32 = 11; +pub const SQLITE_NOTFOUND: i32 = 12; +pub const SQLITE_FULL: i32 = 13; +pub const SQLITE_CANTOPEN: i32 = 14; +pub const SQLITE_PROTOCOL: i32 = 15; +pub const SQLITE_EMPTY: i32 = 16; +pub const SQLITE_SCHEMA: i32 = 17; +pub const SQLITE_TOOBIG: i32 = 18; +pub const SQLITE_CONSTRAINT: i32 = 19; +pub const SQLITE_MISMATCH: i32 = 20; +pub const SQLITE_MISUSE: i32 = 21; +pub const SQLITE_NOLFS: i32 = 22; +pub const SQLITE_AUTH: i32 = 23; +pub const SQLITE_FORMAT: i32 = 24; +pub const SQLITE_RANGE: i32 = 25; +pub const SQLITE_NOTADB: i32 = 26; +pub const SQLITE_NOTICE: i32 = 27; +pub const SQLITE_WARNING: i32 = 28; +pub const SQLITE_ROW: i32 = 100; +pub const SQLITE_DONE: i32 = 101; +pub const SQLITE_IOERR_READ: i32 = 266; +pub const SQLITE_IOERR_SHORT_READ: i32 = 522; +pub const SQLITE_IOERR_WRITE: i32 = 778; +pub const SQLITE_IOERR_FSYNC: i32 = 1034; +pub const SQLITE_IOERR_DIR_FSYNC: i32 = 1290; +pub const SQLITE_IOERR_TRUNCATE: i32 = 1546; +pub const SQLITE_IOERR_FSTAT: i32 = 1802; +pub const SQLITE_IOERR_UNLOCK: i32 = 2058; +pub const SQLITE_IOERR_RDLOCK: i32 = 2314; +pub const SQLITE_IOERR_DELETE: i32 = 2570; +pub const SQLITE_IOERR_BLOCKED: i32 = 2826; +pub const SQLITE_IOERR_NOMEM: i32 = 3082; +pub const SQLITE_IOERR_ACCESS: i32 = 3338; +pub const SQLITE_IOERR_CHECKRESERVEDLOCK: i32 = 3594; +pub const SQLITE_IOERR_LOCK: i32 = 3850; +pub const SQLITE_IOERR_CLOSE: i32 = 4106; +pub const SQLITE_IOERR_DIR_CLOSE: i32 = 4362; +pub const SQLITE_IOERR_SHMOPEN: i32 = 4618; +pub const SQLITE_IOERR_SHMSIZE: i32 = 4874; +pub const SQLITE_IOERR_SHMLOCK: i32 = 5130; +pub const SQLITE_IOERR_SHMMAP: i32 = 5386; +pub const SQLITE_IOERR_SEEK: i32 = 5642; +pub const SQLITE_IOERR_DELETE_NOENT: i32 = 5898; +pub const SQLITE_IOERR_MMAP: i32 = 6154; +pub const SQLITE_IOERR_GETTEMPPATH: i32 = 6410; +pub const SQLITE_IOERR_CONVPATH: i32 = 6666; +pub const SQLITE_IOERR_VNODE: i32 = 6922; +pub const SQLITE_IOERR_AUTH: i32 = 7178; +pub const SQLITE_LOCKED_SHAREDCACHE: i32 = 262; +pub const SQLITE_BUSY_RECOVERY: i32 = 261; +pub const SQLITE_BUSY_SNAPSHOT: i32 = 517; +pub const SQLITE_CANTOPEN_NOTEMPDIR: i32 = 270; +pub const SQLITE_CANTOPEN_ISDIR: i32 = 526; +pub const SQLITE_CANTOPEN_FULLPATH: i32 = 782; +pub const SQLITE_CANTOPEN_CONVPATH: i32 = 1038; +pub const SQLITE_CORRUPT_VTAB: i32 = 267; +pub const SQLITE_READONLY_RECOVERY: i32 = 264; +pub const SQLITE_READONLY_CANTLOCK: i32 = 520; +pub const SQLITE_READONLY_ROLLBACK: i32 = 776; +pub const SQLITE_READONLY_DBMOVED: i32 = 1032; +pub const SQLITE_ABORT_ROLLBACK: i32 = 516; +pub const SQLITE_CONSTRAINT_CHECK: i32 = 275; +pub const SQLITE_CONSTRAINT_COMMITHOOK: i32 = 531; +pub const SQLITE_CONSTRAINT_FOREIGNKEY: i32 = 787; +pub const SQLITE_CONSTRAINT_FUNCTION: i32 = 1043; +pub const SQLITE_CONSTRAINT_NOTNULL: i32 = 1299; +pub const SQLITE_CONSTRAINT_PRIMARYKEY: i32 = 1555; +pub const SQLITE_CONSTRAINT_TRIGGER: i32 = 1811; +pub const SQLITE_CONSTRAINT_UNIQUE: i32 = 2067; +pub const SQLITE_CONSTRAINT_VTAB: i32 = 2323; +pub const SQLITE_CONSTRAINT_ROWID: i32 = 2579; +pub const SQLITE_NOTICE_RECOVER_WAL: i32 = 283; +pub const SQLITE_NOTICE_RECOVER_ROLLBACK: i32 = 539; +pub const SQLITE_WARNING_AUTOINDEX: i32 = 284; +pub const SQLITE_AUTH_USER: i32 = 279; +pub const SQLITE_OK_LOAD_PERMANENTLY: i32 = 256; +pub const SQLITE_OPEN_READONLY: i32 = 1; +pub const SQLITE_OPEN_READWRITE: i32 = 2; +pub const SQLITE_OPEN_CREATE: i32 = 4; +pub const SQLITE_OPEN_DELETEONCLOSE: i32 = 8; +pub const SQLITE_OPEN_EXCLUSIVE: i32 = 16; +pub const SQLITE_OPEN_AUTOPROXY: i32 = 32; +pub const SQLITE_OPEN_URI: i32 = 64; +pub const SQLITE_OPEN_MEMORY: i32 = 128; +pub const SQLITE_OPEN_MAIN_DB: i32 = 256; +pub const SQLITE_OPEN_TEMP_DB: i32 = 512; +pub const SQLITE_OPEN_TRANSIENT_DB: i32 = 1024; +pub const SQLITE_OPEN_MAIN_JOURNAL: i32 = 2048; +pub const SQLITE_OPEN_TEMP_JOURNAL: i32 = 4096; +pub const SQLITE_OPEN_SUBJOURNAL: i32 = 8192; +pub const SQLITE_OPEN_MASTER_JOURNAL: i32 = 16384; +pub const SQLITE_OPEN_NOMUTEX: i32 = 32768; +pub const SQLITE_OPEN_FULLMUTEX: i32 = 65536; +pub const SQLITE_OPEN_SHAREDCACHE: i32 = 131072; +pub const SQLITE_OPEN_PRIVATECACHE: i32 = 262144; +pub const SQLITE_OPEN_WAL: i32 = 524288; +pub const SQLITE_IOCAP_ATOMIC: i32 = 1; +pub const SQLITE_IOCAP_ATOMIC512: i32 = 2; +pub const SQLITE_IOCAP_ATOMIC1K: i32 = 4; +pub const SQLITE_IOCAP_ATOMIC2K: i32 = 8; +pub const SQLITE_IOCAP_ATOMIC4K: i32 = 16; +pub const SQLITE_IOCAP_ATOMIC8K: i32 = 32; +pub const SQLITE_IOCAP_ATOMIC16K: i32 = 64; +pub const SQLITE_IOCAP_ATOMIC32K: i32 = 128; +pub const SQLITE_IOCAP_ATOMIC64K: i32 = 256; +pub const SQLITE_IOCAP_SAFE_APPEND: i32 = 512; +pub const SQLITE_IOCAP_SEQUENTIAL: i32 = 1024; +pub const SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN: i32 = 2048; +pub const SQLITE_IOCAP_POWERSAFE_OVERWRITE: i32 = 4096; +pub const SQLITE_IOCAP_IMMUTABLE: i32 = 8192; +pub const SQLITE_LOCK_NONE: i32 = 0; +pub const SQLITE_LOCK_SHARED: i32 = 1; +pub const SQLITE_LOCK_RESERVED: i32 = 2; +pub const SQLITE_LOCK_PENDING: i32 = 3; +pub const SQLITE_LOCK_EXCLUSIVE: i32 = 4; +pub const SQLITE_SYNC_NORMAL: i32 = 2; +pub const SQLITE_SYNC_FULL: i32 = 3; +pub const SQLITE_SYNC_DATAONLY: i32 = 16; +pub const SQLITE_FCNTL_LOCKSTATE: i32 = 1; +pub const SQLITE_FCNTL_GET_LOCKPROXYFILE: i32 = 2; +pub const SQLITE_FCNTL_SET_LOCKPROXYFILE: i32 = 3; +pub const SQLITE_FCNTL_LAST_ERRNO: i32 = 4; +pub const SQLITE_FCNTL_SIZE_HINT: i32 = 5; +pub const SQLITE_FCNTL_CHUNK_SIZE: i32 = 6; +pub const SQLITE_FCNTL_FILE_POINTER: i32 = 7; +pub const SQLITE_FCNTL_SYNC_OMITTED: i32 = 8; +pub const SQLITE_FCNTL_WIN32_AV_RETRY: i32 = 9; +pub const SQLITE_FCNTL_PERSIST_WAL: i32 = 10; +pub const SQLITE_FCNTL_OVERWRITE: i32 = 11; +pub const SQLITE_FCNTL_VFSNAME: i32 = 12; +pub const SQLITE_FCNTL_POWERSAFE_OVERWRITE: i32 = 13; +pub const SQLITE_FCNTL_PRAGMA: i32 = 14; +pub const SQLITE_FCNTL_BUSYHANDLER: i32 = 15; +pub const SQLITE_FCNTL_TEMPFILENAME: i32 = 16; +pub const SQLITE_FCNTL_MMAP_SIZE: i32 = 18; +pub const SQLITE_FCNTL_TRACE: i32 = 19; +pub const SQLITE_FCNTL_HAS_MOVED: i32 = 20; +pub const SQLITE_FCNTL_SYNC: i32 = 21; +pub const SQLITE_FCNTL_COMMIT_PHASETWO: i32 = 22; +pub const SQLITE_FCNTL_WIN32_SET_HANDLE: i32 = 23; +pub const SQLITE_FCNTL_WAL_BLOCK: i32 = 24; +pub const SQLITE_FCNTL_ZIPVFS: i32 = 25; +pub const SQLITE_FCNTL_RBU: i32 = 26; +pub const SQLITE_FCNTL_VFS_POINTER: i32 = 27; +pub const SQLITE_FCNTL_JOURNAL_POINTER: i32 = 28; +pub const SQLITE_GET_LOCKPROXYFILE: i32 = 2; +pub const SQLITE_SET_LOCKPROXYFILE: i32 = 3; +pub const SQLITE_LAST_ERRNO: i32 = 4; +pub const SQLITE_ACCESS_EXISTS: i32 = 0; +pub const SQLITE_ACCESS_READWRITE: i32 = 1; +pub const SQLITE_ACCESS_READ: i32 = 2; +pub const SQLITE_SHM_UNLOCK: i32 = 1; +pub const SQLITE_SHM_LOCK: i32 = 2; +pub const SQLITE_SHM_SHARED: i32 = 4; +pub const SQLITE_SHM_EXCLUSIVE: i32 = 8; +pub const SQLITE_SHM_NLOCK: i32 = 8; +pub const SQLITE_CONFIG_SINGLETHREAD: i32 = 1; +pub const SQLITE_CONFIG_MULTITHREAD: i32 = 2; +pub const SQLITE_CONFIG_SERIALIZED: i32 = 3; +pub const SQLITE_CONFIG_MALLOC: i32 = 4; +pub const SQLITE_CONFIG_GETMALLOC: i32 = 5; +pub const SQLITE_CONFIG_SCRATCH: i32 = 6; +pub const SQLITE_CONFIG_PAGECACHE: i32 = 7; +pub const SQLITE_CONFIG_HEAP: i32 = 8; +pub const SQLITE_CONFIG_MEMSTATUS: i32 = 9; +pub const SQLITE_CONFIG_MUTEX: i32 = 10; +pub const SQLITE_CONFIG_GETMUTEX: i32 = 11; +pub const SQLITE_CONFIG_LOOKASIDE: i32 = 13; +pub const SQLITE_CONFIG_PCACHE: i32 = 14; +pub const SQLITE_CONFIG_GETPCACHE: i32 = 15; +pub const SQLITE_CONFIG_LOG: i32 = 16; +pub const SQLITE_CONFIG_URI: i32 = 17; +pub const SQLITE_CONFIG_PCACHE2: i32 = 18; +pub const SQLITE_CONFIG_GETPCACHE2: i32 = 19; +pub const SQLITE_CONFIG_COVERING_INDEX_SCAN: i32 = 20; +pub const SQLITE_CONFIG_SQLLOG: i32 = 21; +pub const SQLITE_CONFIG_MMAP_SIZE: i32 = 22; +pub const SQLITE_CONFIG_WIN32_HEAPSIZE: i32 = 23; +pub const SQLITE_CONFIG_PCACHE_HDRSZ: i32 = 24; +pub const SQLITE_CONFIG_PMASZ: i32 = 25; +pub const SQLITE_CONFIG_STMTJRNL_SPILL: i32 = 26; +pub const SQLITE_DBCONFIG_LOOKASIDE: i32 = 1001; +pub const SQLITE_DBCONFIG_ENABLE_FKEY: i32 = 1002; +pub const SQLITE_DBCONFIG_ENABLE_TRIGGER: i32 = 1003; +pub const SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER: i32 = 1004; +pub const SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION: i32 = 1005; +pub const SQLITE_DENY: i32 = 1; +pub const SQLITE_IGNORE: i32 = 2; +pub const SQLITE_CREATE_INDEX: i32 = 1; +pub const SQLITE_CREATE_TABLE: i32 = 2; +pub const SQLITE_CREATE_TEMP_INDEX: i32 = 3; +pub const SQLITE_CREATE_TEMP_TABLE: i32 = 4; +pub const SQLITE_CREATE_TEMP_TRIGGER: i32 = 5; +pub const SQLITE_CREATE_TEMP_VIEW: i32 = 6; +pub const SQLITE_CREATE_TRIGGER: i32 = 7; +pub const SQLITE_CREATE_VIEW: i32 = 8; +pub const SQLITE_DELETE: i32 = 9; +pub const SQLITE_DROP_INDEX: i32 = 10; +pub const SQLITE_DROP_TABLE: i32 = 11; +pub const SQLITE_DROP_TEMP_INDEX: i32 = 12; +pub const SQLITE_DROP_TEMP_TABLE: i32 = 13; +pub const SQLITE_DROP_TEMP_TRIGGER: i32 = 14; +pub const SQLITE_DROP_TEMP_VIEW: i32 = 15; +pub const SQLITE_DROP_TRIGGER: i32 = 16; +pub const SQLITE_DROP_VIEW: i32 = 17; +pub const SQLITE_INSERT: i32 = 18; +pub const SQLITE_PRAGMA: i32 = 19; +pub const SQLITE_READ: i32 = 20; +pub const SQLITE_SELECT: i32 = 21; +pub const SQLITE_TRANSACTION: i32 = 22; +pub const SQLITE_UPDATE: i32 = 23; +pub const SQLITE_ATTACH: i32 = 24; +pub const SQLITE_DETACH: i32 = 25; +pub const SQLITE_ALTER_TABLE: i32 = 26; +pub const SQLITE_REINDEX: i32 = 27; +pub const SQLITE_ANALYZE: i32 = 28; +pub const SQLITE_CREATE_VTABLE: i32 = 29; +pub const SQLITE_DROP_VTABLE: i32 = 30; +pub const SQLITE_FUNCTION: i32 = 31; +pub const SQLITE_SAVEPOINT: i32 = 32; +pub const SQLITE_COPY: i32 = 0; +pub const SQLITE_RECURSIVE: i32 = 33; +pub const SQLITE_TRACE_STMT: i32 = 1; +pub const SQLITE_TRACE_PROFILE: i32 = 2; +pub const SQLITE_TRACE_ROW: i32 = 4; +pub const SQLITE_TRACE_CLOSE: i32 = 8; +pub const SQLITE_LIMIT_LENGTH: i32 = 0; +pub const SQLITE_LIMIT_SQL_LENGTH: i32 = 1; +pub const SQLITE_LIMIT_COLUMN: i32 = 2; +pub const SQLITE_LIMIT_EXPR_DEPTH: i32 = 3; +pub const SQLITE_LIMIT_COMPOUND_SELECT: i32 = 4; +pub const SQLITE_LIMIT_VDBE_OP: i32 = 5; +pub const SQLITE_LIMIT_FUNCTION_ARG: i32 = 6; +pub const SQLITE_LIMIT_ATTACHED: i32 = 7; +pub const SQLITE_LIMIT_LIKE_PATTERN_LENGTH: i32 = 8; +pub const SQLITE_LIMIT_VARIABLE_NUMBER: i32 = 9; +pub const SQLITE_LIMIT_TRIGGER_DEPTH: i32 = 10; +pub const SQLITE_LIMIT_WORKER_THREADS: i32 = 11; +pub const SQLITE_INTEGER: i32 = 1; +pub const SQLITE_FLOAT: i32 = 2; +pub const SQLITE_BLOB: i32 = 4; +pub const SQLITE_NULL: i32 = 5; +pub const SQLITE_TEXT: i32 = 3; +pub const SQLITE3_TEXT: i32 = 3; +pub const SQLITE_UTF8: i32 = 1; +pub const SQLITE_UTF16LE: i32 = 2; +pub const SQLITE_UTF16BE: i32 = 3; +pub const SQLITE_UTF16: i32 = 4; +pub const SQLITE_ANY: i32 = 5; +pub const SQLITE_UTF16_ALIGNED: i32 = 8; +pub const SQLITE_DETERMINISTIC: i32 = 2048; +pub const SQLITE_INDEX_SCAN_UNIQUE: i32 = 1; +pub const SQLITE_INDEX_CONSTRAINT_EQ: i32 = 2; +pub const SQLITE_INDEX_CONSTRAINT_GT: i32 = 4; +pub const SQLITE_INDEX_CONSTRAINT_LE: i32 = 8; +pub const SQLITE_INDEX_CONSTRAINT_LT: i32 = 16; +pub const SQLITE_INDEX_CONSTRAINT_GE: i32 = 32; +pub const SQLITE_INDEX_CONSTRAINT_MATCH: i32 = 64; +pub const SQLITE_INDEX_CONSTRAINT_LIKE: i32 = 65; +pub const SQLITE_INDEX_CONSTRAINT_GLOB: i32 = 66; +pub const SQLITE_INDEX_CONSTRAINT_REGEXP: i32 = 67; +pub const SQLITE_MUTEX_FAST: i32 = 0; +pub const SQLITE_MUTEX_RECURSIVE: i32 = 1; +pub const SQLITE_MUTEX_STATIC_MASTER: i32 = 2; +pub const SQLITE_MUTEX_STATIC_MEM: i32 = 3; +pub const SQLITE_MUTEX_STATIC_MEM2: i32 = 4; +pub const SQLITE_MUTEX_STATIC_OPEN: i32 = 4; +pub const SQLITE_MUTEX_STATIC_PRNG: i32 = 5; +pub const SQLITE_MUTEX_STATIC_LRU: i32 = 6; +pub const SQLITE_MUTEX_STATIC_LRU2: i32 = 7; +pub const SQLITE_MUTEX_STATIC_PMEM: i32 = 7; +pub const SQLITE_MUTEX_STATIC_APP1: i32 = 8; +pub const SQLITE_MUTEX_STATIC_APP2: i32 = 9; +pub const SQLITE_MUTEX_STATIC_APP3: i32 = 10; +pub const SQLITE_MUTEX_STATIC_VFS1: i32 = 11; +pub const SQLITE_MUTEX_STATIC_VFS2: i32 = 12; +pub const SQLITE_MUTEX_STATIC_VFS3: i32 = 13; +pub const SQLITE_TESTCTRL_FIRST: i32 = 5; +pub const SQLITE_TESTCTRL_PRNG_SAVE: i32 = 5; +pub const SQLITE_TESTCTRL_PRNG_RESTORE: i32 = 6; +pub const SQLITE_TESTCTRL_PRNG_RESET: i32 = 7; +pub const SQLITE_TESTCTRL_BITVEC_TEST: i32 = 8; +pub const SQLITE_TESTCTRL_FAULT_INSTALL: i32 = 9; +pub const SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS: i32 = 10; +pub const SQLITE_TESTCTRL_PENDING_BYTE: i32 = 11; +pub const SQLITE_TESTCTRL_ASSERT: i32 = 12; +pub const SQLITE_TESTCTRL_ALWAYS: i32 = 13; +pub const SQLITE_TESTCTRL_RESERVE: i32 = 14; +pub const SQLITE_TESTCTRL_OPTIMIZATIONS: i32 = 15; +pub const SQLITE_TESTCTRL_ISKEYWORD: i32 = 16; +pub const SQLITE_TESTCTRL_SCRATCHMALLOC: i32 = 17; +pub const SQLITE_TESTCTRL_LOCALTIME_FAULT: i32 = 18; +pub const SQLITE_TESTCTRL_EXPLAIN_STMT: i32 = 19; +pub const SQLITE_TESTCTRL_NEVER_CORRUPT: i32 = 20; +pub const SQLITE_TESTCTRL_VDBE_COVERAGE: i32 = 21; +pub const SQLITE_TESTCTRL_BYTEORDER: i32 = 22; +pub const SQLITE_TESTCTRL_ISINIT: i32 = 23; +pub const SQLITE_TESTCTRL_SORTER_MMAP: i32 = 24; +pub const SQLITE_TESTCTRL_IMPOSTER: i32 = 25; +pub const SQLITE_TESTCTRL_LAST: i32 = 25; +pub const SQLITE_STATUS_MEMORY_USED: i32 = 0; +pub const SQLITE_STATUS_PAGECACHE_USED: i32 = 1; +pub const SQLITE_STATUS_PAGECACHE_OVERFLOW: i32 = 2; +pub const SQLITE_STATUS_SCRATCH_USED: i32 = 3; +pub const SQLITE_STATUS_SCRATCH_OVERFLOW: i32 = 4; +pub const SQLITE_STATUS_MALLOC_SIZE: i32 = 5; +pub const SQLITE_STATUS_PARSER_STACK: i32 = 6; +pub const SQLITE_STATUS_PAGECACHE_SIZE: i32 = 7; +pub const SQLITE_STATUS_SCRATCH_SIZE: i32 = 8; +pub const SQLITE_STATUS_MALLOC_COUNT: i32 = 9; +pub const SQLITE_DBSTATUS_LOOKASIDE_USED: i32 = 0; +pub const SQLITE_DBSTATUS_CACHE_USED: i32 = 1; +pub const SQLITE_DBSTATUS_SCHEMA_USED: i32 = 2; +pub const SQLITE_DBSTATUS_STMT_USED: i32 = 3; +pub const SQLITE_DBSTATUS_LOOKASIDE_HIT: i32 = 4; +pub const SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE: i32 = 5; +pub const SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL: i32 = 6; +pub const SQLITE_DBSTATUS_CACHE_HIT: i32 = 7; +pub const SQLITE_DBSTATUS_CACHE_MISS: i32 = 8; +pub const SQLITE_DBSTATUS_CACHE_WRITE: i32 = 9; +pub const SQLITE_DBSTATUS_DEFERRED_FKS: i32 = 10; +pub const SQLITE_DBSTATUS_CACHE_USED_SHARED: i32 = 11; +pub const SQLITE_DBSTATUS_MAX: i32 = 11; +pub const SQLITE_STMTSTATUS_FULLSCAN_STEP: i32 = 1; +pub const SQLITE_STMTSTATUS_SORT: i32 = 2; +pub const SQLITE_STMTSTATUS_AUTOINDEX: i32 = 3; +pub const SQLITE_STMTSTATUS_VM_STEP: i32 = 4; +pub const SQLITE_CHECKPOINT_PASSIVE: i32 = 0; +pub const SQLITE_CHECKPOINT_FULL: i32 = 1; +pub const SQLITE_CHECKPOINT_RESTART: i32 = 2; +pub const SQLITE_CHECKPOINT_TRUNCATE: i32 = 3; +pub const SQLITE_VTAB_CONSTRAINT_SUPPORT: i32 = 1; +pub const SQLITE_ROLLBACK: i32 = 1; +pub const SQLITE_FAIL: i32 = 3; +pub const SQLITE_REPLACE: i32 = 5; +pub const SQLITE_SCANSTAT_NLOOP: i32 = 0; +pub const SQLITE_SCANSTAT_NVISIT: i32 = 1; +pub const SQLITE_SCANSTAT_EST: i32 = 2; +pub const SQLITE_SCANSTAT_NAME: i32 = 3; +pub const SQLITE_SCANSTAT_EXPLAIN: i32 = 4; +pub const SQLITE_SCANSTAT_SELECTID: i32 = 5; +pub const NOT_WITHIN: i32 = 0; +pub const PARTLY_WITHIN: i32 = 1; +pub const FULLY_WITHIN: i32 = 2; +pub const FTS5_TOKENIZE_QUERY: i32 = 1; +pub const FTS5_TOKENIZE_PREFIX: i32 = 2; +pub const FTS5_TOKENIZE_DOCUMENT: i32 = 4; +pub const FTS5_TOKENIZE_AUX: i32 = 8; +pub const FTS5_TOKEN_COLOCATED: i32 = 1; +extern "C" { + pub static sqlite3_version: [::std::os::raw::c_char; 0usize]; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3 { + _unused: [u8; 0], +} +pub type sqlite_int64 = ::std::os::raw::c_longlong; +pub type sqlite_uint64 = ::std::os::raw::c_ulonglong; +pub type sqlite3_int64 = sqlite_int64; +pub type sqlite3_uint64 = sqlite_uint64; +pub type sqlite3_callback = ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut ::std::os::raw::c_char, + arg4: *mut *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, +>; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_file { + pub pMethods: *const sqlite3_io_methods, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_io_methods { + pub iVersion: ::std::os::raw::c_int, + pub xClose: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_file) -> ::std::os::raw::c_int, + >, + pub xRead: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_file, + arg2: *mut ::std::os::raw::c_void, + iAmt: ::std::os::raw::c_int, + iOfst: sqlite3_int64, + ) -> ::std::os::raw::c_int, + >, + pub xWrite: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_file, + arg2: *const ::std::os::raw::c_void, + iAmt: ::std::os::raw::c_int, + iOfst: sqlite3_int64, + ) -> ::std::os::raw::c_int, + >, + pub xTruncate: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_file, size: sqlite3_int64) -> ::std::os::raw::c_int, + >, + pub xSync: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_file, + flags: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xFileSize: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_file, + pSize: *mut sqlite3_int64, + ) -> ::std::os::raw::c_int, + >, + pub xLock: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_file, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xUnlock: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_file, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xCheckReservedLock: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_file, + pResOut: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xFileControl: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_file, + op: ::std::os::raw::c_int, + pArg: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + pub xSectorSize: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_file) -> ::std::os::raw::c_int, + >, + pub xDeviceCharacteristics: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_file) -> ::std::os::raw::c_int, + >, + pub xShmMap: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_file, + iPg: ::std::os::raw::c_int, + pgsz: ::std::os::raw::c_int, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + pub xShmLock: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_file, + offset: ::std::os::raw::c_int, + n: ::std::os::raw::c_int, + flags: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xShmBarrier: ::std::option::Option, + pub xShmUnmap: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_file, + deleteFlag: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xFetch: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_file, + iOfst: sqlite3_int64, + iAmt: ::std::os::raw::c_int, + pp: *mut *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + pub xUnfetch: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_file, + iOfst: sqlite3_int64, + p: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_mutex { + _unused: [u8; 0], +} +pub type sqlite3_syscall_ptr = ::std::option::Option; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_vfs { + pub iVersion: ::std::os::raw::c_int, + pub szOsFile: ::std::os::raw::c_int, + pub mxPathname: ::std::os::raw::c_int, + pub pNext: *mut sqlite3_vfs, + pub zName: *const ::std::os::raw::c_char, + pub pAppData: *mut ::std::os::raw::c_void, + pub xOpen: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + zName: *const ::std::os::raw::c_char, + arg2: *mut sqlite3_file, + flags: ::std::os::raw::c_int, + pOutFlags: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xDelete: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + zName: *const ::std::os::raw::c_char, + syncDir: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xAccess: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + zName: *const ::std::os::raw::c_char, + flags: ::std::os::raw::c_int, + pResOut: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xFullPathname: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + zName: *const ::std::os::raw::c_char, + nOut: ::std::os::raw::c_int, + zOut: *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub xDlOpen: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + zFilename: *const ::std::os::raw::c_char, + ) -> *mut ::std::os::raw::c_void, + >, + pub xDlError: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + nByte: ::std::os::raw::c_int, + zErrMsg: *mut ::std::os::raw::c_char, + ), + >, + pub xDlSym: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + arg2: *mut ::std::os::raw::c_void, + zSymbol: *const ::std::os::raw::c_char, + ) -> ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + arg2: *mut ::std::os::raw::c_void, + zSymbol: *const ::std::os::raw::c_char, + ), + >, + >, + pub xDlClose: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_vfs, arg2: *mut ::std::os::raw::c_void), + >, + pub xRandomness: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + nByte: ::std::os::raw::c_int, + zOut: *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub xSleep: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + microseconds: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xCurrentTime: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_vfs, arg2: *mut f64) -> ::std::os::raw::c_int, + >, + pub xGetLastError: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + arg2: ::std::os::raw::c_int, + arg3: *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub xCurrentTimeInt64: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + arg2: *mut sqlite3_int64, + ) -> ::std::os::raw::c_int, + >, + pub xSetSystemCall: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + zName: *const ::std::os::raw::c_char, + arg2: sqlite3_syscall_ptr, + ) -> ::std::os::raw::c_int, + >, + pub xGetSystemCall: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + zName: *const ::std::os::raw::c_char, + ) -> sqlite3_syscall_ptr, + >, + pub xNextSystemCall: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + zName: *const ::std::os::raw::c_char, + ) -> *const ::std::os::raw::c_char, + >, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_mem_methods { + pub xMalloc: ::std::option::Option< + unsafe extern "C" fn(arg1: ::std::os::raw::c_int) -> *mut ::std::os::raw::c_void, + >, + pub xFree: ::std::option::Option, + pub xRealloc: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + ) -> *mut ::std::os::raw::c_void, + >, + pub xSize: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int, + >, + pub xRoundup: ::std::option::Option< + unsafe extern "C" fn(arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int, + >, + pub xInit: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int, + >, + pub xShutdown: ::std::option::Option, + pub pAppData: *mut ::std::os::raw::c_void, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_stmt { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Mem { + _unused: [u8; 0], +} +pub type sqlite3_value = Mem; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_context { + _unused: [u8; 0], +} +pub type sqlite3_destructor_type = + ::std::option::Option; +extern "C" { + pub static mut sqlite3_temp_directory: *mut ::std::os::raw::c_char; +} +extern "C" { + pub static mut sqlite3_data_directory: *mut ::std::os::raw::c_char; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_module { + pub iVersion: ::std::os::raw::c_int, + pub xCreate: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + pAux: *mut ::std::os::raw::c_void, + argc: ::std::os::raw::c_int, + argv: *const *const ::std::os::raw::c_char, + ppVTab: *mut *mut sqlite3_vtab, + arg2: *mut *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub xConnect: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + pAux: *mut ::std::os::raw::c_void, + argc: ::std::os::raw::c_int, + argv: *const *const ::std::os::raw::c_char, + ppVTab: *mut *mut sqlite3_vtab, + arg2: *mut *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub xBestIndex: ::std::option::Option< + unsafe extern "C" fn( + pVTab: *mut sqlite3_vtab, + arg1: *mut sqlite3_index_info, + ) -> ::std::os::raw::c_int, + >, + pub xDisconnect: ::std::option::Option< + unsafe extern "C" fn(pVTab: *mut sqlite3_vtab) -> ::std::os::raw::c_int, + >, + pub xDestroy: ::std::option::Option< + unsafe extern "C" fn(pVTab: *mut sqlite3_vtab) -> ::std::os::raw::c_int, + >, + pub xOpen: ::std::option::Option< + unsafe extern "C" fn( + pVTab: *mut sqlite3_vtab, + ppCursor: *mut *mut sqlite3_vtab_cursor, + ) -> ::std::os::raw::c_int, + >, + pub xClose: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_vtab_cursor) -> ::std::os::raw::c_int, + >, + pub xFilter: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vtab_cursor, + idxNum: ::std::os::raw::c_int, + idxStr: *const ::std::os::raw::c_char, + argc: ::std::os::raw::c_int, + argv: *mut *mut sqlite3_value, + ) -> ::std::os::raw::c_int, + >, + pub xNext: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_vtab_cursor) -> ::std::os::raw::c_int, + >, + pub xEof: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_vtab_cursor) -> ::std::os::raw::c_int, + >, + pub xColumn: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vtab_cursor, + arg2: *mut sqlite3_context, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xRowid: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vtab_cursor, + pRowid: *mut sqlite3_int64, + ) -> ::std::os::raw::c_int, + >, + pub xUpdate: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vtab, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + arg4: *mut sqlite3_int64, + ) -> ::std::os::raw::c_int, + >, + pub xBegin: ::std::option::Option< + unsafe extern "C" fn(pVTab: *mut sqlite3_vtab) -> ::std::os::raw::c_int, + >, + pub xSync: ::std::option::Option< + unsafe extern "C" fn(pVTab: *mut sqlite3_vtab) -> ::std::os::raw::c_int, + >, + pub xCommit: ::std::option::Option< + unsafe extern "C" fn(pVTab: *mut sqlite3_vtab) -> ::std::os::raw::c_int, + >, + pub xRollback: ::std::option::Option< + unsafe extern "C" fn(pVTab: *mut sqlite3_vtab) -> ::std::os::raw::c_int, + >, + pub xFindFunction: ::std::option::Option< + unsafe extern "C" fn( + pVtab: *mut sqlite3_vtab, + nArg: ::std::os::raw::c_int, + zName: *const ::std::os::raw::c_char, + pxFunc: *mut ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + ppArg: *mut *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + pub xRename: ::std::option::Option< + unsafe extern "C" fn( + pVtab: *mut sqlite3_vtab, + zNew: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub xSavepoint: ::std::option::Option< + unsafe extern "C" fn( + pVTab: *mut sqlite3_vtab, + arg1: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xRelease: ::std::option::Option< + unsafe extern "C" fn( + pVTab: *mut sqlite3_vtab, + arg1: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xRollbackTo: ::std::option::Option< + unsafe extern "C" fn( + pVTab: *mut sqlite3_vtab, + arg1: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_index_info { + pub nConstraint: ::std::os::raw::c_int, + pub aConstraint: *mut sqlite3_index_constraint, + pub nOrderBy: ::std::os::raw::c_int, + pub aOrderBy: *mut sqlite3_index_orderby, + pub aConstraintUsage: *mut sqlite3_index_constraint_usage, + pub idxNum: ::std::os::raw::c_int, + pub idxStr: *mut ::std::os::raw::c_char, + pub needToFreeIdxStr: ::std::os::raw::c_int, + pub orderByConsumed: ::std::os::raw::c_int, + pub estimatedCost: f64, + pub estimatedRows: sqlite3_int64, + pub idxFlags: ::std::os::raw::c_int, + pub colUsed: sqlite3_uint64, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_index_constraint { + pub iColumn: ::std::os::raw::c_int, + pub op: ::std::os::raw::c_uchar, + pub usable: ::std::os::raw::c_uchar, + pub iTermOffset: ::std::os::raw::c_int, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_index_orderby { + pub iColumn: ::std::os::raw::c_int, + pub desc: ::std::os::raw::c_uchar, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_index_constraint_usage { + pub argvIndex: ::std::os::raw::c_int, + pub omit: ::std::os::raw::c_uchar, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_vtab { + pub pModule: *const sqlite3_module, + pub nRef: ::std::os::raw::c_int, + pub zErrMsg: *mut ::std::os::raw::c_char, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_vtab_cursor { + pub pVtab: *mut sqlite3_vtab, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_blob { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_mutex_methods { + pub xMutexInit: ::std::option::Option ::std::os::raw::c_int>, + pub xMutexEnd: ::std::option::Option ::std::os::raw::c_int>, + pub xMutexAlloc: ::std::option::Option< + unsafe extern "C" fn(arg1: ::std::os::raw::c_int) -> *mut sqlite3_mutex, + >, + pub xMutexFree: ::std::option::Option, + pub xMutexEnter: ::std::option::Option, + pub xMutexTry: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_mutex) -> ::std::os::raw::c_int, + >, + pub xMutexLeave: ::std::option::Option, + pub xMutexHeld: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_mutex) -> ::std::os::raw::c_int, + >, + pub xMutexNotheld: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_mutex) -> ::std::os::raw::c_int, + >, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_pcache { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_pcache_page { + pub pBuf: *mut ::std::os::raw::c_void, + pub pExtra: *mut ::std::os::raw::c_void, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_pcache_methods2 { + pub iVersion: ::std::os::raw::c_int, + pub pArg: *mut ::std::os::raw::c_void, + pub xInit: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int, + >, + pub xShutdown: ::std::option::Option, + pub xCreate: ::std::option::Option< + unsafe extern "C" fn( + szPage: ::std::os::raw::c_int, + szExtra: ::std::os::raw::c_int, + bPurgeable: ::std::os::raw::c_int, + ) -> *mut sqlite3_pcache, + >, + pub xCachesize: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_pcache, nCachesize: ::std::os::raw::c_int), + >, + pub xPagecount: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_pcache) -> ::std::os::raw::c_int, + >, + pub xFetch: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_pcache, + key: ::std::os::raw::c_uint, + createFlag: ::std::os::raw::c_int, + ) -> *mut sqlite3_pcache_page, + >, + pub xUnpin: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_pcache, + arg2: *mut sqlite3_pcache_page, + discard: ::std::os::raw::c_int, + ), + >, + pub xRekey: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_pcache, + arg2: *mut sqlite3_pcache_page, + oldKey: ::std::os::raw::c_uint, + newKey: ::std::os::raw::c_uint, + ), + >, + pub xTruncate: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_pcache, iLimit: ::std::os::raw::c_uint), + >, + pub xDestroy: ::std::option::Option, + pub xShrink: ::std::option::Option, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_pcache_methods { + pub pArg: *mut ::std::os::raw::c_void, + pub xInit: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int, + >, + pub xShutdown: ::std::option::Option, + pub xCreate: ::std::option::Option< + unsafe extern "C" fn( + szPage: ::std::os::raw::c_int, + bPurgeable: ::std::os::raw::c_int, + ) -> *mut sqlite3_pcache, + >, + pub xCachesize: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_pcache, nCachesize: ::std::os::raw::c_int), + >, + pub xPagecount: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_pcache) -> ::std::os::raw::c_int, + >, + pub xFetch: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_pcache, + key: ::std::os::raw::c_uint, + createFlag: ::std::os::raw::c_int, + ) -> *mut ::std::os::raw::c_void, + >, + pub xUnpin: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_pcache, + arg2: *mut ::std::os::raw::c_void, + discard: ::std::os::raw::c_int, + ), + >, + pub xRekey: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_pcache, + arg2: *mut ::std::os::raw::c_void, + oldKey: ::std::os::raw::c_uint, + newKey: ::std::os::raw::c_uint, + ), + >, + pub xTruncate: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_pcache, iLimit: ::std::os::raw::c_uint), + >, + pub xDestroy: ::std::option::Option, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_backup { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_snapshot { + _unused: [u8; 0], +} +pub type sqlite3_rtree_dbl = f64; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_rtree_geometry { + pub pContext: *mut ::std::os::raw::c_void, + pub nParam: ::std::os::raw::c_int, + pub aParam: *mut sqlite3_rtree_dbl, + pub pUser: *mut ::std::os::raw::c_void, + pub xDelUser: ::std::option::Option, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_rtree_query_info { + pub pContext: *mut ::std::os::raw::c_void, + pub nParam: ::std::os::raw::c_int, + pub aParam: *mut sqlite3_rtree_dbl, + pub pUser: *mut ::std::os::raw::c_void, + pub xDelUser: ::std::option::Option, + pub aCoord: *mut sqlite3_rtree_dbl, + pub anQueue: *mut ::std::os::raw::c_uint, + pub nCoord: ::std::os::raw::c_int, + pub iLevel: ::std::os::raw::c_int, + pub mxLevel: ::std::os::raw::c_int, + pub iRowid: sqlite3_int64, + pub rParentScore: sqlite3_rtree_dbl, + pub eParentWithin: ::std::os::raw::c_int, + pub eWithin: ::std::os::raw::c_int, + pub rScore: sqlite3_rtree_dbl, + pub apSqlParam: *mut *mut sqlite3_value, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Fts5Context { + _unused: [u8; 0], +} +pub type fts5_extension_function = ::std::option::Option< + unsafe extern "C" fn( + pApi: *const Fts5ExtensionApi, + pFts: *mut Fts5Context, + pCtx: *mut sqlite3_context, + nVal: ::std::os::raw::c_int, + apVal: *mut *mut sqlite3_value, + ), +>; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Fts5PhraseIter { + pub a: *const ::std::os::raw::c_uchar, + pub b: *const ::std::os::raw::c_uchar, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Fts5ExtensionApi { + pub iVersion: ::std::os::raw::c_int, + pub xUserData: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut Fts5Context) -> *mut ::std::os::raw::c_void, + >, + pub xColumnCount: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut Fts5Context) -> ::std::os::raw::c_int, + >, + pub xRowCount: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + pnRow: *mut sqlite3_int64, + ) -> ::std::os::raw::c_int, + >, + pub xColumnTotalSize: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + iCol: ::std::os::raw::c_int, + pnToken: *mut sqlite3_int64, + ) -> ::std::os::raw::c_int, + >, + pub xTokenize: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + pText: *const ::std::os::raw::c_char, + nText: ::std::os::raw::c_int, + pCtx: *mut ::std::os::raw::c_void, + xToken: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + arg4: ::std::os::raw::c_int, + arg5: ::std::os::raw::c_int, + arg6: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + ) -> ::std::os::raw::c_int, + >, + pub xPhraseCount: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut Fts5Context) -> ::std::os::raw::c_int, + >, + pub xPhraseSize: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + iPhrase: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xInstCount: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + pnInst: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xInst: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + iIdx: ::std::os::raw::c_int, + piPhrase: *mut ::std::os::raw::c_int, + piCol: *mut ::std::os::raw::c_int, + piOff: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xRowid: + ::std::option::Option sqlite3_int64>, + pub xColumnText: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + iCol: ::std::os::raw::c_int, + pz: *mut *const ::std::os::raw::c_char, + pn: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xColumnSize: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + iCol: ::std::os::raw::c_int, + pnToken: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xQueryPhrase: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + iPhrase: ::std::os::raw::c_int, + pUserData: *mut ::std::os::raw::c_void, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *const Fts5ExtensionApi, + arg2: *mut Fts5Context, + arg3: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + ) -> ::std::os::raw::c_int, + >, + pub xSetAuxdata: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + pAux: *mut ::std::os::raw::c_void, + xDelete: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, + pub xGetAuxdata: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + bClear: ::std::os::raw::c_int, + ) -> *mut ::std::os::raw::c_void, + >, + pub xPhraseFirst: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + iPhrase: ::std::os::raw::c_int, + arg2: *mut Fts5PhraseIter, + arg3: *mut ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xPhraseNext: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + arg2: *mut Fts5PhraseIter, + piCol: *mut ::std::os::raw::c_int, + piOff: *mut ::std::os::raw::c_int, + ), + >, + pub xPhraseFirstColumn: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + iPhrase: ::std::os::raw::c_int, + arg2: *mut Fts5PhraseIter, + arg3: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xPhraseNextColumn: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + arg2: *mut Fts5PhraseIter, + piCol: *mut ::std::os::raw::c_int, + ), + >, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Fts5Tokenizer { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct fts5_tokenizer { + pub xCreate: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + azArg: *mut *const ::std::os::raw::c_char, + nArg: ::std::os::raw::c_int, + ppOut: *mut *mut Fts5Tokenizer, + ) -> ::std::os::raw::c_int, + >, + pub xDelete: ::std::option::Option, + pub xTokenize: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Tokenizer, + pCtx: *mut ::std::os::raw::c_void, + flags: ::std::os::raw::c_int, + pText: *const ::std::os::raw::c_char, + nText: ::std::os::raw::c_int, + xToken: ::std::option::Option< + unsafe extern "C" fn( + pCtx: *mut ::std::os::raw::c_void, + tflags: ::std::os::raw::c_int, + pToken: *const ::std::os::raw::c_char, + nToken: ::std::os::raw::c_int, + iStart: ::std::os::raw::c_int, + iEnd: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + ) -> ::std::os::raw::c_int, + >, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct fts5_api { + pub iVersion: ::std::os::raw::c_int, + pub xCreateTokenizer: ::std::option::Option< + unsafe extern "C" fn( + pApi: *mut fts5_api, + zName: *const ::std::os::raw::c_char, + pContext: *mut ::std::os::raw::c_void, + pTokenizer: *mut fts5_tokenizer, + xDestroy: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, + pub xFindTokenizer: ::std::option::Option< + unsafe extern "C" fn( + pApi: *mut fts5_api, + zName: *const ::std::os::raw::c_char, + ppContext: *mut *mut ::std::os::raw::c_void, + pTokenizer: *mut fts5_tokenizer, + ) -> ::std::os::raw::c_int, + >, + pub xCreateFunction: ::std::option::Option< + unsafe extern "C" fn( + pApi: *mut fts5_api, + zName: *const ::std::os::raw::c_char, + pContext: *mut ::std::os::raw::c_void, + xFunction: fts5_extension_function, + xDestroy: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_api_routines { + pub aggregate_context: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + nBytes: ::std::os::raw::c_int, + ) -> *mut ::std::os::raw::c_void, + >, + pub aggregate_count: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_context) -> ::std::os::raw::c_int, + >, + pub bind_blob: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + n: ::std::os::raw::c_int, + arg4: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, + pub bind_double: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: f64, + ) -> ::std::os::raw::c_int, + >, + pub bind_int: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub bind_int64: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: sqlite_int64, + ) -> ::std::os::raw::c_int, + >, + pub bind_null: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub bind_parameter_count: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int, + >, + pub bind_parameter_index: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + zName: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub bind_parameter_name: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, + pub bind_text: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + n: ::std::os::raw::c_int, + arg4: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, + pub bind_text16: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: ::std::os::raw::c_int, + arg5: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, + pub bind_value: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const sqlite3_value, + ) -> ::std::os::raw::c_int, + >, + pub busy_handler: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + pub busy_timeout: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + ms: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub changes: + ::std::option::Option ::std::os::raw::c_int>, + pub close: + ::std::option::Option ::std::os::raw::c_int>, + pub collation_needed: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *mut ::std::os::raw::c_void, + arg3: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut sqlite3, + eTextRep: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + ), + >, + ) -> ::std::os::raw::c_int, + >, + pub collation_needed16: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *mut ::std::os::raw::c_void, + arg3: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut sqlite3, + eTextRep: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + ), + >, + ) -> ::std::os::raw::c_int, + >, + pub column_blob: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void, + >, + pub column_bytes: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub column_bytes16: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub column_count: ::std::option::Option< + unsafe extern "C" fn(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int, + >, + pub column_database_name: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, + pub column_database_name16: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void, + >, + pub column_decltype: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + i: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, + pub column_decltype16: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void, + >, + pub column_double: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_stmt, iCol: ::std::os::raw::c_int) -> f64, + >, + pub column_int: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub column_int64: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_stmt, iCol: ::std::os::raw::c_int) -> sqlite_int64, + >, + pub column_name: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, + pub column_name16: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void, + >, + pub column_origin_name: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, + pub column_origin_name16: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void, + >, + pub column_table_name: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, + pub column_table_name16: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void, + >, + pub column_text: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_uchar, + >, + pub column_text16: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void, + >, + pub column_type: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub column_value: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> *mut sqlite3_value, + >, + pub commit_hook: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void, + >, + pub complete: ::std::option::Option< + unsafe extern "C" fn(sql: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int, + >, + pub complete16: ::std::option::Option< + unsafe extern "C" fn(sql: *const ::std::os::raw::c_void) -> ::std::os::raw::c_int, + >, + pub create_collation: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, + arg5: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: ::std::os::raw::c_int, + arg5: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + ) -> ::std::os::raw::c_int, + >, + pub create_collation16: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, + arg5: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: ::std::os::raw::c_int, + arg5: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + ) -> ::std::os::raw::c_int, + >, + pub create_function: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_void, + xFunc: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xStep: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xFinal: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, + pub create_function16: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_void, + xFunc: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xStep: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xFinal: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, + pub create_module: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const sqlite3_module, + arg4: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + pub data_count: ::std::option::Option< + unsafe extern "C" fn(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int, + >, + pub db_handle: + ::std::option::Option *mut sqlite3>, + pub declare_vtab: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub enable_shared_cache: ::std::option::Option< + unsafe extern "C" fn(arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int, + >, + pub errcode: + ::std::option::Option ::std::os::raw::c_int>, + pub errmsg: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3) -> *const ::std::os::raw::c_char, + >, + pub errmsg16: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3) -> *const ::std::os::raw::c_void, + >, + pub exec: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: sqlite3_callback, + arg4: *mut ::std::os::raw::c_void, + arg5: *mut *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub expired: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int, + >, + pub finalize: ::std::option::Option< + unsafe extern "C" fn(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int, + >, + pub free: ::std::option::Option, + pub free_table: + ::std::option::Option, + pub get_autocommit: + ::std::option::Option ::std::os::raw::c_int>, + pub get_auxdata: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + ) -> *mut ::std::os::raw::c_void, + >, + pub get_table: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *mut *mut *mut ::std::os::raw::c_char, + arg4: *mut ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_int, + arg6: *mut *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub global_recover: ::std::option::Option ::std::os::raw::c_int>, + pub interruptx: ::std::option::Option, + pub last_insert_rowid: + ::std::option::Option sqlite_int64>, + pub libversion: ::std::option::Option *const ::std::os::raw::c_char>, + pub libversion_number: ::std::option::Option ::std::os::raw::c_int>, + pub malloc: ::std::option::Option< + unsafe extern "C" fn(arg1: ::std::os::raw::c_int) -> *mut ::std::os::raw::c_void, + >, + pub mprintf: ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + ... + ) -> *mut ::std::os::raw::c_char, + >, + pub open: ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *mut *mut sqlite3, + ) -> ::std::os::raw::c_int, + >, + pub open16: ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_void, + arg2: *mut *mut sqlite3, + ) -> ::std::os::raw::c_int, + >, + pub prepare: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut *mut sqlite3_stmt, + arg5: *mut *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub prepare16: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: *mut *mut sqlite3_stmt, + arg5: *mut *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + pub profile: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *const ::std::os::raw::c_char, + arg3: sqlite_uint64, + ), + >, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void, + >, + pub progress_handler: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + arg3: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int, + >, + arg4: *mut ::std::os::raw::c_void, + ), + >, + pub realloc: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + ) -> *mut ::std::os::raw::c_void, + >, + pub reset: ::std::option::Option< + unsafe extern "C" fn(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int, + >, + pub result_blob: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option, + ), + >, + pub result_double: + ::std::option::Option, + pub result_error: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + ), + >, + pub result_error16: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + ), + >, + pub result_int: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_context, arg2: ::std::os::raw::c_int), + >, + pub result_int64: + ::std::option::Option, + pub result_null: ::std::option::Option, + pub result_text: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option, + ), + >, + pub result_text16: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option, + ), + >, + pub result_text16be: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option, + ), + >, + pub result_text16le: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option, + ), + >, + pub result_value: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_context, arg2: *mut sqlite3_value), + >, + pub rollback_hook: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void, + >, + pub set_authorizer: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + arg4: *const ::std::os::raw::c_char, + arg5: *const ::std::os::raw::c_char, + arg6: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + pub set_auxdata: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut ::std::os::raw::c_void, + arg4: ::std::option::Option, + ), + >, + pub snprintf: ::std::option::Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + arg2: *mut ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + ... + ) -> *mut ::std::os::raw::c_char, + >, + pub step: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int, + >, + pub table_column_metadata: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: *const ::std::os::raw::c_char, + arg5: *mut *const ::std::os::raw::c_char, + arg6: *mut *const ::std::os::raw::c_char, + arg7: *mut ::std::os::raw::c_int, + arg8: *mut ::std::os::raw::c_int, + arg9: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub thread_cleanup: ::std::option::Option, + pub total_changes: + ::std::option::Option ::std::os::raw::c_int>, + pub trace: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + xTrace: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *const ::std::os::raw::c_char, + ), + >, + arg2: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void, + >, + pub transfer_bindings: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: *mut sqlite3_stmt, + ) -> ::std::os::raw::c_int, + >, + pub update_hook: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + arg4: *const ::std::os::raw::c_char, + arg5: sqlite_int64, + ), + >, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void, + >, + pub user_data: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_context) -> *mut ::std::os::raw::c_void, + >, + pub value_blob: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> *const ::std::os::raw::c_void, + >, + pub value_bytes: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int, + >, + pub value_bytes16: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int, + >, + pub value_double: ::std::option::Option f64>, + pub value_int: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int, + >, + pub value_int64: + ::std::option::Option sqlite_int64>, + pub value_numeric_type: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int, + >, + pub value_text: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> *const ::std::os::raw::c_uchar, + >, + pub value_text16: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> *const ::std::os::raw::c_void, + >, + pub value_text16be: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> *const ::std::os::raw::c_void, + >, + pub value_text16le: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> *const ::std::os::raw::c_void, + >, + pub value_type: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int, + >, + pub vmprintf: ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_char, + >, + pub overload_function: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + zFuncName: *const ::std::os::raw::c_char, + nArg: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub prepare_v2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut *mut sqlite3_stmt, + arg5: *mut *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub prepare16_v2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: *mut *mut sqlite3_stmt, + arg5: *mut *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + pub clear_bindings: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int, + >, + pub create_module_v2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const sqlite3_module, + arg4: *mut ::std::os::raw::c_void, + xDestroy: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, + pub bind_zeroblob: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub blob_bytes: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_blob) -> ::std::os::raw::c_int, + >, + pub blob_close: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_blob) -> ::std::os::raw::c_int, + >, + pub blob_open: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: *const ::std::os::raw::c_char, + arg5: sqlite3_int64, + arg6: ::std::os::raw::c_int, + arg7: *mut *mut sqlite3_blob, + ) -> ::std::os::raw::c_int, + >, + pub blob_read: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_blob, + arg2: *mut ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub blob_write: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_blob, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub create_collation_v2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, + arg5: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: ::std::os::raw::c_int, + arg5: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + arg6: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, + pub file_control: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + pub memory_highwater: + ::std::option::Option sqlite3_int64>, + pub memory_used: ::std::option::Option sqlite3_int64>, + pub mutex_alloc: ::std::option::Option< + unsafe extern "C" fn(arg1: ::std::os::raw::c_int) -> *mut sqlite3_mutex, + >, + pub mutex_enter: ::std::option::Option, + pub mutex_free: ::std::option::Option, + pub mutex_leave: ::std::option::Option, + pub mutex_try: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_mutex) -> ::std::os::raw::c_int, + >, + pub open_v2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *mut *mut sqlite3, + arg3: ::std::os::raw::c_int, + arg4: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub release_memory: ::std::option::Option< + unsafe extern "C" fn(arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int, + >, + pub result_error_nomem: ::std::option::Option, + pub result_error_toobig: + ::std::option::Option, + pub sleep: ::std::option::Option< + unsafe extern "C" fn(arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int, + >, + pub soft_heap_limit: ::std::option::Option, + pub vfs_find: ::std::option::Option< + unsafe extern "C" fn(arg1: *const ::std::os::raw::c_char) -> *mut sqlite3_vfs, + >, + pub vfs_register: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub vfs_unregister: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_vfs) -> ::std::os::raw::c_int, + >, + pub xthreadsafe: ::std::option::Option ::std::os::raw::c_int>, + pub result_zeroblob: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_context, arg2: ::std::os::raw::c_int), + >, + pub result_error_code: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_context, arg2: ::std::os::raw::c_int), + >, + pub test_control: ::std::option::Option< + unsafe extern "C" fn(arg1: ::std::os::raw::c_int, ...) -> ::std::os::raw::c_int, + >, + pub randomness: ::std::option::Option< + unsafe extern "C" fn(arg1: ::std::os::raw::c_int, arg2: *mut ::std::os::raw::c_void), + >, + pub context_db_handle: + ::std::option::Option *mut sqlite3>, + pub extended_result_codes: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub limit: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub next_stmt: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3, arg2: *mut sqlite3_stmt) -> *mut sqlite3_stmt, + >, + pub sql: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> *const ::std::os::raw::c_char, + >, + pub status: ::std::option::Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + arg2: *mut ::std::os::raw::c_int, + arg3: *mut ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub backup_finish: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_backup) -> ::std::os::raw::c_int, + >, + pub backup_init: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *mut sqlite3, + arg4: *const ::std::os::raw::c_char, + ) -> *mut sqlite3_backup, + >, + pub backup_pagecount: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_backup) -> ::std::os::raw::c_int, + >, + pub backup_remaining: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_backup) -> ::std::os::raw::c_int, + >, + pub backup_step: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_backup, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub compileoption_get: ::std::option::Option< + unsafe extern "C" fn(arg1: ::std::os::raw::c_int) -> *const ::std::os::raw::c_char, + >, + pub compileoption_used: ::std::option::Option< + unsafe extern "C" fn(arg1: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int, + >, + pub create_function_v2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_void, + xFunc: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xStep: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xFinal: ::std::option::Option, + xDestroy: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, + pub db_config: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + ... + ) -> ::std::os::raw::c_int, + >, + pub db_mutex: + ::std::option::Option *mut sqlite3_mutex>, + pub db_status: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + arg3: *mut ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_int, + arg5: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub extended_errcode: + ::std::option::Option ::std::os::raw::c_int>, + pub log: ::std::option::Option< + unsafe extern "C" fn(arg1: ::std::os::raw::c_int, arg2: *const ::std::os::raw::c_char, ...), + >, + pub soft_heap_limit64: + ::std::option::Option sqlite3_int64>, + pub sourceid: ::std::option::Option *const ::std::os::raw::c_char>, + pub stmt_status: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub strnicmp: ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub unlock_notify: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + ), + >, + arg3: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + pub wal_autocheckpoint: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub wal_checkpoint: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub wal_hook: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut sqlite3, + arg3: *const ::std::os::raw::c_char, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void, + >, + pub blob_reopen: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_blob, arg2: sqlite3_int64) -> ::std::os::raw::c_int, + >, + pub vtab_config: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + op: ::std::os::raw::c_int, + ... + ) -> ::std::os::raw::c_int, + >, + pub vtab_on_conflict: + ::std::option::Option ::std::os::raw::c_int>, + pub close_v2: + ::std::option::Option ::std::os::raw::c_int>, + pub db_filename: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + ) -> *const ::std::os::raw::c_char, + >, + pub db_readonly: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub db_release_memory: + ::std::option::Option ::std::os::raw::c_int>, + pub errstr: ::std::option::Option< + unsafe extern "C" fn(arg1: ::std::os::raw::c_int) -> *const ::std::os::raw::c_char, + >, + pub stmt_busy: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int, + >, + pub stmt_readonly: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int, + >, + pub stricmp: ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub uri_boolean: ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub uri_int64: ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: sqlite3_int64, + ) -> sqlite3_int64, + >, + pub uri_parameter: ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + ) -> *const ::std::os::raw::c_char, + >, + pub vsnprintf: ::std::option::Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + arg2: *mut ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_char, + >, + pub wal_checkpoint_v2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub auto_extension: ::std::option::Option< + unsafe extern "C" fn( + arg1: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, + pub bind_blob64: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: sqlite3_uint64, + arg5: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, + pub bind_text64: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + arg4: sqlite3_uint64, + arg5: ::std::option::Option, + arg6: ::std::os::raw::c_uchar, + ) -> ::std::os::raw::c_int, + >, + pub cancel_auto_extension: ::std::option::Option< + unsafe extern "C" fn( + arg1: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, + pub load_extension: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: *mut *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub malloc64: ::std::option::Option< + unsafe extern "C" fn(arg1: sqlite3_uint64) -> *mut ::std::os::raw::c_void, + >, + pub msize: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void) -> sqlite3_uint64, + >, + pub realloc64: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: sqlite3_uint64, + ) -> *mut ::std::os::raw::c_void, + >, + pub reset_auto_extension: ::std::option::Option, + pub result_blob64: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: sqlite3_uint64, + arg4: ::std::option::Option, + ), + >, + pub result_text64: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_char, + arg3: sqlite3_uint64, + arg4: ::std::option::Option, + arg5: ::std::os::raw::c_uchar, + ), + >, + pub strglob: ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub value_dup: ::std::option::Option< + unsafe extern "C" fn(arg1: *const sqlite3_value) -> *mut sqlite3_value, + >, + pub value_free: ::std::option::Option, + pub result_zeroblob64: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: sqlite3_uint64, + ) -> ::std::os::raw::c_int, + >, + pub bind_zeroblob64: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: sqlite3_uint64, + ) -> ::std::os::raw::c_int, + >, + pub value_subtype: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> ::std::os::raw::c_uint, + >, + pub result_subtype: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_context, arg2: ::std::os::raw::c_uint), + >, + pub status64: ::std::option::Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + arg2: *mut sqlite3_int64, + arg3: *mut sqlite3_int64, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub strlike: ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_uint, + ) -> ::std::os::raw::c_int, + >, + pub db_cacheflush: + ::std::option::Option ::std::os::raw::c_int>, + pub system_errno: + ::std::option::Option ::std::os::raw::c_int>, + pub trace_v2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_uint, + arg3: ::std::option::Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_uint, + arg2: *mut ::std::os::raw::c_void, + arg3: *mut ::std::os::raw::c_void, + arg4: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + arg4: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + pub expanded_sql: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> *mut ::std::os::raw::c_char, + >, +} +pub type sqlite3_loadext_entry = ::std::option::Option< + unsafe extern "C" fn( + db: *mut sqlite3, + pzErrMsg: *mut *mut ::std::os::raw::c_char, + pThunk: *const sqlite3_api_routines, + ) -> ::std::os::raw::c_int, +>; +static __SQLITE3_AGGREGATE_CONTEXT: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + nBytes: ::std::os::raw::c_int, + ) -> *mut ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_aggregate_context( + arg1: *mut sqlite3_context, + nBytes: ::std::os::raw::c_int, +) -> *mut ::std::os::raw::c_void { + let fun = __SQLITE3_AGGREGATE_CONTEXT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, nBytes) +} + +static __SQLITE3_AGGREGATE_COUNT: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_aggregate_count( + arg1: *mut sqlite3_context, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_AGGREGATE_COUNT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_BIND_BLOB: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + n: ::std::os::raw::c_int, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_bind_blob( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + n: ::std::os::raw::c_int, + arg4: ::std::option::Option, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BIND_BLOB + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, n, arg4) +} + +static __SQLITE3_BIND_DOUBLE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: f64, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_bind_double( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: f64, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BIND_DOUBLE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_BIND_INT: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_bind_int( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BIND_INT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_BIND_INT64: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: sqlite_int64, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_bind_int64( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: sqlite_int64, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BIND_INT64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_BIND_NULL: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_bind_null( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BIND_NULL + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_BIND_PARAMETER_COUNT: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_bind_parameter_count( + arg1: *mut sqlite3_stmt, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BIND_PARAMETER_COUNT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_BIND_PARAMETER_INDEX: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + zName: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_bind_parameter_index( + arg1: *mut sqlite3_stmt, + zName: *const ::std::os::raw::c_char, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BIND_PARAMETER_INDEX + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, zName) +} + +static __SQLITE3_BIND_PARAMETER_NAME: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_bind_parameter_name( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_BIND_PARAMETER_NAME + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_BIND_TEXT: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + n: ::std::os::raw::c_int, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_bind_text( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + n: ::std::os::raw::c_int, + arg4: ::std::option::Option, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BIND_TEXT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, n, arg4) +} + +static __SQLITE3_BIND_TEXT16: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: ::std::os::raw::c_int, + arg5: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_bind_text16( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: ::std::os::raw::c_int, + arg5: ::std::option::Option, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BIND_TEXT16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5) +} + +static __SQLITE3_BIND_VALUE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const sqlite3_value, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_bind_value( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const sqlite3_value, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BIND_VALUE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_BUSY_HANDLER: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_busy_handler( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BUSY_HANDLER + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_BUSY_TIMEOUT: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + ms: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_busy_timeout( + arg1: *mut sqlite3, + ms: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BUSY_TIMEOUT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, ms) +} + +static __SQLITE3_CHANGES: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_changes(arg1: *mut sqlite3) -> ::std::os::raw::c_int { + let fun = __SQLITE3_CHANGES + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_CLOSE: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_close(arg1: *mut sqlite3) -> ::std::os::raw::c_int { + let fun = __SQLITE3_CLOSE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_COLLATION_NEEDED: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *mut ::std::os::raw::c_void, + arg3: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut sqlite3, + eTextRep: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + ), + >, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_collation_needed( + arg1: *mut sqlite3, + arg2: *mut ::std::os::raw::c_void, + arg3: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut sqlite3, + eTextRep: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + ), + >, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_COLLATION_NEEDED + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_COLLATION_NEEDED16: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *mut ::std::os::raw::c_void, + arg3: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut sqlite3, + eTextRep: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + ), + >, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_collation_needed16( + arg1: *mut sqlite3, + arg2: *mut ::std::os::raw::c_void, + arg3: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut sqlite3, + eTextRep: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + ), + >, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_COLLATION_NEEDED16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_COLUMN_BLOB: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_blob( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_void { + let fun = __SQLITE3_COLUMN_BLOB + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, iCol) +} + +static __SQLITE3_COLUMN_BYTES: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_bytes( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_COLUMN_BYTES + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, iCol) +} + +static __SQLITE3_COLUMN_BYTES16: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_bytes16( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_COLUMN_BYTES16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, iCol) +} + +static __SQLITE3_COLUMN_COUNT: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_count(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int { + let fun = __SQLITE3_COLUMN_COUNT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(pStmt) +} + +static __SQLITE3_COLUMN_DATABASE_NAME: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_database_name( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_COLUMN_DATABASE_NAME + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_COLUMN_DATABASE_NAME16: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_database_name16( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_void { + let fun = __SQLITE3_COLUMN_DATABASE_NAME16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_COLUMN_DECLTYPE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + i: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_decltype( + arg1: *mut sqlite3_stmt, + i: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_COLUMN_DECLTYPE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, i) +} + +static __SQLITE3_COLUMN_DECLTYPE16: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_decltype16( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_void { + let fun = __SQLITE3_COLUMN_DECLTYPE16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_COLUMN_DOUBLE: ::atomic::Atomic< + Option< + unsafe extern "C" fn(arg1: *mut sqlite3_stmt, iCol: ::std::os::raw::c_int) -> f64, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_double( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, +) -> f64 { + let fun = __SQLITE3_COLUMN_DOUBLE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, iCol) +} + +static __SQLITE3_COLUMN_INT: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_int( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_COLUMN_INT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, iCol) +} + +static __SQLITE3_COLUMN_INT64: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> sqlite_int64, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_int64( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, +) -> sqlite_int64 { + let fun = __SQLITE3_COLUMN_INT64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, iCol) +} + +static __SQLITE3_COLUMN_NAME: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_name( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_COLUMN_NAME + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_COLUMN_NAME16: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_name16( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_void { + let fun = __SQLITE3_COLUMN_NAME16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_COLUMN_ORIGIN_NAME: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_origin_name( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_COLUMN_ORIGIN_NAME + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_COLUMN_ORIGIN_NAME16: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_origin_name16( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_void { + let fun = __SQLITE3_COLUMN_ORIGIN_NAME16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_COLUMN_TABLE_NAME: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_table_name( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_COLUMN_TABLE_NAME + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_COLUMN_TABLE_NAME16: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_table_name16( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_void { + let fun = __SQLITE3_COLUMN_TABLE_NAME16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_COLUMN_TEXT: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_uchar, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_text( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_uchar { + let fun = __SQLITE3_COLUMN_TEXT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, iCol) +} + +static __SQLITE3_COLUMN_TEXT16: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_text16( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_void { + let fun = __SQLITE3_COLUMN_TEXT16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, iCol) +} + +static __SQLITE3_COLUMN_TYPE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_type( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_COLUMN_TYPE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, iCol) +} + +static __SQLITE3_COLUMN_VALUE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> *mut sqlite3_value, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_value( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, +) -> *mut sqlite3_value { + let fun = __SQLITE3_COLUMN_VALUE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, iCol) +} + +static __SQLITE3_COMMIT_HOOK: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_commit_hook( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, +) -> *mut ::std::os::raw::c_void { + let fun = __SQLITE3_COMMIT_HOOK + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_COMPLETE: ::atomic::Atomic< + Option< + unsafe extern "C" fn(sql: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_complete( + sql: *const ::std::os::raw::c_char, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_COMPLETE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(sql) +} + +static __SQLITE3_COMPLETE16: ::atomic::Atomic< + Option< + unsafe extern "C" fn(sql: *const ::std::os::raw::c_void) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_complete16( + sql: *const ::std::os::raw::c_void, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_COMPLETE16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(sql) +} + +static __SQLITE3_CREATE_COLLATION: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, + arg5: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: ::std::os::raw::c_int, + arg5: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_create_collation( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, + arg5: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: ::std::os::raw::c_int, + arg5: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_CREATE_COLLATION + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5) +} + +static __SQLITE3_CREATE_COLLATION16: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, + arg5: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: ::std::os::raw::c_int, + arg5: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_create_collation16( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, + arg5: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: ::std::os::raw::c_int, + arg5: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_CREATE_COLLATION16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5) +} + +static __SQLITE3_CREATE_FUNCTION: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_void, + xFunc: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xStep: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xFinal: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_context), + >, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_create_function( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_void, + xFunc: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xStep: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xFinal: ::std::option::Option, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_CREATE_FUNCTION + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5, xFunc, xStep, xFinal) +} + +static __SQLITE3_CREATE_FUNCTION16: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_void, + xFunc: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xStep: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xFinal: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_context), + >, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_create_function16( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_void, + xFunc: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xStep: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xFinal: ::std::option::Option, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_CREATE_FUNCTION16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5, xFunc, xStep, xFinal) +} + +static __SQLITE3_CREATE_MODULE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const sqlite3_module, + arg4: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_create_module( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const sqlite3_module, + arg4: *mut ::std::os::raw::c_void, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_CREATE_MODULE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_DATA_COUNT: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_data_count(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int { + let fun = __SQLITE3_DATA_COUNT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(pStmt) +} + +static __SQLITE3_DB_HANDLE: ::atomic::Atomic< + Option *mut sqlite3>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_db_handle(arg1: *mut sqlite3_stmt) -> *mut sqlite3 { + let fun = __SQLITE3_DB_HANDLE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_DECLARE_VTAB: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_declare_vtab( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_DECLARE_VTAB + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_ENABLE_SHARED_CACHE: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_enable_shared_cache( + arg1: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_ENABLE_SHARED_CACHE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_ERRCODE: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_errcode(db: *mut sqlite3) -> ::std::os::raw::c_int { + let fun = __SQLITE3_ERRCODE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(db) +} + +static __SQLITE3_ERRMSG: ::atomic::Atomic< + Option *const ::std::os::raw::c_char>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_errmsg(arg1: *mut sqlite3) -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_ERRMSG + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_ERRMSG16: ::atomic::Atomic< + Option *const ::std::os::raw::c_void>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_errmsg16(arg1: *mut sqlite3) -> *const ::std::os::raw::c_void { + let fun = __SQLITE3_ERRMSG16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_EXEC: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: sqlite3_callback, + arg4: *mut ::std::os::raw::c_void, + arg5: *mut *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_exec( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: sqlite3_callback, + arg4: *mut ::std::os::raw::c_void, + arg5: *mut *mut ::std::os::raw::c_char, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_EXEC + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5) +} + +static __SQLITE3_EXPIRED: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_expired(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int { + let fun = __SQLITE3_EXPIRED + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_FINALIZE: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_finalize(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int { + let fun = __SQLITE3_FINALIZE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(pStmt) +} + +static __SQLITE3_FREE: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_free(arg1: *mut ::std::os::raw::c_void) { + let fun = __SQLITE3_FREE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_FREE_TABLE: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_free_table(result: *mut *mut ::std::os::raw::c_char) { + let fun = __SQLITE3_FREE_TABLE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(result) +} + +static __SQLITE3_GET_AUTOCOMMIT: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_get_autocommit(arg1: *mut sqlite3) -> ::std::os::raw::c_int { + let fun = __SQLITE3_GET_AUTOCOMMIT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_GET_AUXDATA: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + ) -> *mut ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_get_auxdata( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, +) -> *mut ::std::os::raw::c_void { + let fun = __SQLITE3_GET_AUXDATA + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_GET_TABLE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *mut *mut *mut ::std::os::raw::c_char, + arg4: *mut ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_int, + arg6: *mut *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_get_table( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *mut *mut *mut ::std::os::raw::c_char, + arg4: *mut ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_int, + arg6: *mut *mut ::std::os::raw::c_char, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_GET_TABLE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5, arg6) +} + +static __SQLITE3_GLOBAL_RECOVER: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_global_recover() -> ::std::os::raw::c_int { + let fun = __SQLITE3_GLOBAL_RECOVER + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)() +} + +static __SQLITE3_INTERRUPT: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_interrupt(arg1: *mut sqlite3) { + let fun = __SQLITE3_INTERRUPT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_LAST_INSERT_ROWID: ::atomic::Atomic< + Option sqlite_int64>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_last_insert_rowid(arg1: *mut sqlite3) -> sqlite_int64 { + let fun = __SQLITE3_LAST_INSERT_ROWID + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_LIBVERSION: ::atomic::Atomic< + Option *const ::std::os::raw::c_char>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_libversion() -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_LIBVERSION + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)() +} + +static __SQLITE3_LIBVERSION_NUMBER: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_libversion_number() -> ::std::os::raw::c_int { + let fun = __SQLITE3_LIBVERSION_NUMBER + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)() +} + +static __SQLITE3_MALLOC: ::atomic::Atomic< + Option< + unsafe extern "C" fn(arg1: ::std::os::raw::c_int) -> *mut ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_malloc( + arg1: ::std::os::raw::c_int, +) -> *mut ::std::os::raw::c_void { + let fun = __SQLITE3_MALLOC + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_OPEN: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *mut *mut sqlite3, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_open( + arg1: *const ::std::os::raw::c_char, + arg2: *mut *mut sqlite3, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_OPEN + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_OPEN16: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_void, + arg2: *mut *mut sqlite3, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_open16( + arg1: *const ::std::os::raw::c_void, + arg2: *mut *mut sqlite3, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_OPEN16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_PREPARE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut *mut sqlite3_stmt, + arg5: *mut *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_prepare( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut *mut sqlite3_stmt, + arg5: *mut *const ::std::os::raw::c_char, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_PREPARE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5) +} + +static __SQLITE3_PREPARE16: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: *mut *mut sqlite3_stmt, + arg5: *mut *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_prepare16( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: *mut *mut sqlite3_stmt, + arg5: *mut *const ::std::os::raw::c_void, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_PREPARE16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5) +} + +static __SQLITE3_PROFILE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *const ::std::os::raw::c_char, + arg3: sqlite_uint64, + ), + >, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_profile( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *const ::std::os::raw::c_char, + arg3: sqlite_uint64, + ), + >, + arg3: *mut ::std::os::raw::c_void, +) -> *mut ::std::os::raw::c_void { + let fun = __SQLITE3_PROFILE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_PROGRESS_HANDLER: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + arg3: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + arg4: *mut ::std::os::raw::c_void, + ), + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_progress_handler( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + arg3: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int, + >, + arg4: *mut ::std::os::raw::c_void, +) { + let fun = __SQLITE3_PROGRESS_HANDLER + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_REALLOC: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + ) -> *mut ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_realloc( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, +) -> *mut ::std::os::raw::c_void { + let fun = __SQLITE3_REALLOC + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_RESET: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_reset(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int { + let fun = __SQLITE3_RESET + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(pStmt) +} + +static __SQLITE3_RESULT_BLOB: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ), + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_blob( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option, +) { + let fun = __SQLITE3_RESULT_BLOB + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_RESULT_DOUBLE: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_double(arg1: *mut sqlite3_context, arg2: f64) { + let fun = __SQLITE3_RESULT_DOUBLE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_RESULT_ERROR: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + ), + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_error( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, +) { + let fun = __SQLITE3_RESULT_ERROR + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_RESULT_ERROR16: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + ), + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_error16( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, +) { + let fun = __SQLITE3_RESULT_ERROR16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_RESULT_INT: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_int( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, +) { + let fun = __SQLITE3_RESULT_INT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_RESULT_INT64: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_int64(arg1: *mut sqlite3_context, arg2: sqlite_int64) { + let fun = __SQLITE3_RESULT_INT64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_RESULT_NULL: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_null(arg1: *mut sqlite3_context) { + let fun = __SQLITE3_RESULT_NULL + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_RESULT_TEXT: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ), + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_text( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option, +) { + let fun = __SQLITE3_RESULT_TEXT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_RESULT_TEXT16: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ), + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_text16( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option, +) { + let fun = __SQLITE3_RESULT_TEXT16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_RESULT_TEXT16BE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ), + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_text16be( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option, +) { + let fun = __SQLITE3_RESULT_TEXT16BE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_RESULT_TEXT16LE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ), + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_text16le( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option, +) { + let fun = __SQLITE3_RESULT_TEXT16LE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_RESULT_VALUE: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_value( + arg1: *mut sqlite3_context, + arg2: *mut sqlite3_value, +) { + let fun = __SQLITE3_RESULT_VALUE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_ROLLBACK_HOOK: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_rollback_hook( + arg1: *mut sqlite3, + arg2: ::std::option::Option, + arg3: *mut ::std::os::raw::c_void, +) -> *mut ::std::os::raw::c_void { + let fun = __SQLITE3_ROLLBACK_HOOK + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_SET_AUTHORIZER: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + arg4: *const ::std::os::raw::c_char, + arg5: *const ::std::os::raw::c_char, + arg6: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_set_authorizer( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + arg4: *const ::std::os::raw::c_char, + arg5: *const ::std::os::raw::c_char, + arg6: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_SET_AUTHORIZER + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_SET_AUXDATA: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut ::std::os::raw::c_void, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ), + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_set_auxdata( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut ::std::os::raw::c_void, + arg4: ::std::option::Option, +) { + let fun = __SQLITE3_SET_AUXDATA + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_STEP: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_step(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int { + let fun = __SQLITE3_STEP + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_TABLE_COLUMN_METADATA: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: *const ::std::os::raw::c_char, + arg5: *mut *const ::std::os::raw::c_char, + arg6: *mut *const ::std::os::raw::c_char, + arg7: *mut ::std::os::raw::c_int, + arg8: *mut ::std::os::raw::c_int, + arg9: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_table_column_metadata( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: *const ::std::os::raw::c_char, + arg5: *mut *const ::std::os::raw::c_char, + arg6: *mut *const ::std::os::raw::c_char, + arg7: *mut ::std::os::raw::c_int, + arg8: *mut ::std::os::raw::c_int, + arg9: *mut ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_TABLE_COLUMN_METADATA + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) +} + +static __SQLITE3_THREAD_CLEANUP: ::atomic::Atomic> = ::atomic::Atomic::new( + None, +); +pub unsafe fn sqlite3_thread_cleanup() { + let fun = __SQLITE3_THREAD_CLEANUP + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)() +} + +static __SQLITE3_TOTAL_CHANGES: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_total_changes(arg1: *mut sqlite3) -> ::std::os::raw::c_int { + let fun = __SQLITE3_TOTAL_CHANGES + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_TRACE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + xTrace: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *const ::std::os::raw::c_char, + ), + >, + arg2: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_trace( + arg1: *mut sqlite3, + xTrace: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *const ::std::os::raw::c_char, + ), + >, + arg2: *mut ::std::os::raw::c_void, +) -> *mut ::std::os::raw::c_void { + let fun = __SQLITE3_TRACE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, xTrace, arg2) +} + +static __SQLITE3_TRANSFER_BINDINGS: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: *mut sqlite3_stmt, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_transfer_bindings( + arg1: *mut sqlite3_stmt, + arg2: *mut sqlite3_stmt, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_TRANSFER_BINDINGS + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_UPDATE_HOOK: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + arg4: *const ::std::os::raw::c_char, + arg5: sqlite_int64, + ), + >, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_update_hook( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + arg4: *const ::std::os::raw::c_char, + arg5: sqlite_int64, + ), + >, + arg3: *mut ::std::os::raw::c_void, +) -> *mut ::std::os::raw::c_void { + let fun = __SQLITE3_UPDATE_HOOK + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_USER_DATA: ::atomic::Atomic< + Option< + unsafe extern "C" fn(arg1: *mut sqlite3_context) -> *mut ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_user_data( + arg1: *mut sqlite3_context, +) -> *mut ::std::os::raw::c_void { + let fun = __SQLITE3_USER_DATA + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VALUE_BLOB: ::atomic::Atomic< + Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> *const ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_blob( + arg1: *mut sqlite3_value, +) -> *const ::std::os::raw::c_void { + let fun = __SQLITE3_VALUE_BLOB + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VALUE_BYTES: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_bytes(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int { + let fun = __SQLITE3_VALUE_BYTES + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VALUE_BYTES16: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_bytes16(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int { + let fun = __SQLITE3_VALUE_BYTES16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VALUE_DOUBLE: ::atomic::Atomic< + Option f64>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_double(arg1: *mut sqlite3_value) -> f64 { + let fun = __SQLITE3_VALUE_DOUBLE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VALUE_INT: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_int(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int { + let fun = __SQLITE3_VALUE_INT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VALUE_INT64: ::atomic::Atomic< + Option sqlite_int64>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_int64(arg1: *mut sqlite3_value) -> sqlite_int64 { + let fun = __SQLITE3_VALUE_INT64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VALUE_NUMERIC_TYPE: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_numeric_type( + arg1: *mut sqlite3_value, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_VALUE_NUMERIC_TYPE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VALUE_TEXT: ::atomic::Atomic< + Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> *const ::std::os::raw::c_uchar, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_text( + arg1: *mut sqlite3_value, +) -> *const ::std::os::raw::c_uchar { + let fun = __SQLITE3_VALUE_TEXT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VALUE_TEXT16: ::atomic::Atomic< + Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> *const ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_text16( + arg1: *mut sqlite3_value, +) -> *const ::std::os::raw::c_void { + let fun = __SQLITE3_VALUE_TEXT16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VALUE_TEXT16BE: ::atomic::Atomic< + Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> *const ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_text16be( + arg1: *mut sqlite3_value, +) -> *const ::std::os::raw::c_void { + let fun = __SQLITE3_VALUE_TEXT16BE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VALUE_TEXT16LE: ::atomic::Atomic< + Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> *const ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_text16le( + arg1: *mut sqlite3_value, +) -> *const ::std::os::raw::c_void { + let fun = __SQLITE3_VALUE_TEXT16LE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VALUE_TYPE: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_type(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int { + let fun = __SQLITE3_VALUE_TYPE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_OVERLOAD_FUNCTION: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + zFuncName: *const ::std::os::raw::c_char, + nArg: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_overload_function( + arg1: *mut sqlite3, + zFuncName: *const ::std::os::raw::c_char, + nArg: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_OVERLOAD_FUNCTION + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, zFuncName, nArg) +} + +static __SQLITE3_PREPARE_V2: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut *mut sqlite3_stmt, + arg5: *mut *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_prepare_v2( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut *mut sqlite3_stmt, + arg5: *mut *const ::std::os::raw::c_char, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_PREPARE_V2 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5) +} + +static __SQLITE3_PREPARE16_V2: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: *mut *mut sqlite3_stmt, + arg5: *mut *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_prepare16_v2( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: *mut *mut sqlite3_stmt, + arg5: *mut *const ::std::os::raw::c_void, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_PREPARE16_V2 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5) +} + +static __SQLITE3_CLEAR_BINDINGS: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_clear_bindings(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int { + let fun = __SQLITE3_CLEAR_BINDINGS + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_CREATE_MODULE_V2: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const sqlite3_module, + arg4: *mut ::std::os::raw::c_void, + xDestroy: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_create_module_v2( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const sqlite3_module, + arg4: *mut ::std::os::raw::c_void, + xDestroy: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_CREATE_MODULE_V2 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, xDestroy) +} + +static __SQLITE3_BIND_ZEROBLOB: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_bind_zeroblob( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BIND_ZEROBLOB + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_BLOB_BYTES: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_blob_bytes(arg1: *mut sqlite3_blob) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BLOB_BYTES + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_BLOB_CLOSE: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_blob_close(arg1: *mut sqlite3_blob) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BLOB_CLOSE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_BLOB_OPEN: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: *const ::std::os::raw::c_char, + arg5: sqlite3_int64, + arg6: ::std::os::raw::c_int, + arg7: *mut *mut sqlite3_blob, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_blob_open( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: *const ::std::os::raw::c_char, + arg5: sqlite3_int64, + arg6: ::std::os::raw::c_int, + arg7: *mut *mut sqlite3_blob, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BLOB_OPEN + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5, arg6, arg7) +} + +static __SQLITE3_BLOB_READ: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_blob, + arg2: *mut ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_blob_read( + arg1: *mut sqlite3_blob, + arg2: *mut ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BLOB_READ + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_BLOB_WRITE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_blob, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_blob_write( + arg1: *mut sqlite3_blob, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BLOB_WRITE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_CREATE_COLLATION_V2: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, + arg5: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: ::std::os::raw::c_int, + arg5: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + arg6: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_create_collation_v2( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, + arg5: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: ::std::os::raw::c_int, + arg5: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + arg6: ::std::option::Option, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_CREATE_COLLATION_V2 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5, arg6) +} + +static __SQLITE3_FILE_CONTROL: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_file_control( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_FILE_CONTROL + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_MEMORY_HIGHWATER: ::atomic::Atomic< + Option sqlite3_int64>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_memory_highwater(arg1: ::std::os::raw::c_int) -> sqlite3_int64 { + let fun = __SQLITE3_MEMORY_HIGHWATER + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_MEMORY_USED: ::atomic::Atomic< + Option sqlite3_int64>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_memory_used() -> sqlite3_int64 { + let fun = __SQLITE3_MEMORY_USED + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)() +} + +static __SQLITE3_MUTEX_ALLOC: ::atomic::Atomic< + Option *mut sqlite3_mutex>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_mutex_alloc(arg1: ::std::os::raw::c_int) -> *mut sqlite3_mutex { + let fun = __SQLITE3_MUTEX_ALLOC + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_MUTEX_ENTER: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_mutex_enter(arg1: *mut sqlite3_mutex) { + let fun = __SQLITE3_MUTEX_ENTER + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_MUTEX_FREE: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_mutex_free(arg1: *mut sqlite3_mutex) { + let fun = __SQLITE3_MUTEX_FREE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_MUTEX_LEAVE: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_mutex_leave(arg1: *mut sqlite3_mutex) { + let fun = __SQLITE3_MUTEX_LEAVE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_MUTEX_TRY: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_mutex_try(arg1: *mut sqlite3_mutex) -> ::std::os::raw::c_int { + let fun = __SQLITE3_MUTEX_TRY + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_OPEN_V2: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *mut *mut sqlite3, + arg3: ::std::os::raw::c_int, + arg4: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_open_v2( + arg1: *const ::std::os::raw::c_char, + arg2: *mut *mut sqlite3, + arg3: ::std::os::raw::c_int, + arg4: *const ::std::os::raw::c_char, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_OPEN_V2 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_RELEASE_MEMORY: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_release_memory( + arg1: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_RELEASE_MEMORY + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_RESULT_ERROR_NOMEM: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_error_nomem(arg1: *mut sqlite3_context) { + let fun = __SQLITE3_RESULT_ERROR_NOMEM + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_RESULT_ERROR_TOOBIG: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_error_toobig(arg1: *mut sqlite3_context) { + let fun = __SQLITE3_RESULT_ERROR_TOOBIG + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_SLEEP: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_sleep(arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int { + let fun = __SQLITE3_SLEEP + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_SOFT_HEAP_LIMIT: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_soft_heap_limit(arg1: ::std::os::raw::c_int) { + let fun = __SQLITE3_SOFT_HEAP_LIMIT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VFS_FIND: ::atomic::Atomic< + Option *mut sqlite3_vfs>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_vfs_find(arg1: *const ::std::os::raw::c_char) -> *mut sqlite3_vfs { + let fun = __SQLITE3_VFS_FIND + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VFS_REGISTER: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_vfs_register( + arg1: *mut sqlite3_vfs, + arg2: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_VFS_REGISTER + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_VFS_UNREGISTER: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_vfs_unregister(arg1: *mut sqlite3_vfs) -> ::std::os::raw::c_int { + let fun = __SQLITE3_VFS_UNREGISTER + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_THREADSAFE: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_threadsafe() -> ::std::os::raw::c_int { + let fun = __SQLITE3_THREADSAFE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)() +} + +static __SQLITE3_RESULT_ZEROBLOB: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_zeroblob( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, +) { + let fun = __SQLITE3_RESULT_ZEROBLOB + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_RESULT_ERROR_CODE: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_error_code( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, +) { + let fun = __SQLITE3_RESULT_ERROR_CODE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_RANDOMNESS: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + arg2: *mut ::std::os::raw::c_void, + ), + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_randomness( + arg1: ::std::os::raw::c_int, + arg2: *mut ::std::os::raw::c_void, +) { + let fun = __SQLITE3_RANDOMNESS + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_CONTEXT_DB_HANDLE: ::atomic::Atomic< + Option *mut sqlite3>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_context_db_handle(arg1: *mut sqlite3_context) -> *mut sqlite3 { + let fun = __SQLITE3_CONTEXT_DB_HANDLE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_EXTENDED_RESULT_CODES: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_extended_result_codes( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_EXTENDED_RESULT_CODES + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_LIMIT: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_limit( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_LIMIT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_NEXT_STMT: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *mut sqlite3_stmt, + ) -> *mut sqlite3_stmt, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_next_stmt( + arg1: *mut sqlite3, + arg2: *mut sqlite3_stmt, +) -> *mut sqlite3_stmt { + let fun = __SQLITE3_NEXT_STMT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_SQL: ::atomic::Atomic< + Option< + unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> *const ::std::os::raw::c_char, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_sql(arg1: *mut sqlite3_stmt) -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_SQL + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_STATUS: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + arg2: *mut ::std::os::raw::c_int, + arg3: *mut ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_status( + arg1: ::std::os::raw::c_int, + arg2: *mut ::std::os::raw::c_int, + arg3: *mut ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_STATUS + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_BACKUP_FINISH: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_backup_finish(arg1: *mut sqlite3_backup) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BACKUP_FINISH + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_BACKUP_INIT: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *mut sqlite3, + arg4: *const ::std::os::raw::c_char, + ) -> *mut sqlite3_backup, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_backup_init( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *mut sqlite3, + arg4: *const ::std::os::raw::c_char, +) -> *mut sqlite3_backup { + let fun = __SQLITE3_BACKUP_INIT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_BACKUP_PAGECOUNT: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_backup_pagecount( + arg1: *mut sqlite3_backup, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BACKUP_PAGECOUNT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_BACKUP_REMAINING: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_backup_remaining( + arg1: *mut sqlite3_backup, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BACKUP_REMAINING + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_BACKUP_STEP: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_backup, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_backup_step( + arg1: *mut sqlite3_backup, + arg2: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BACKUP_STEP + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_COMPILEOPTION_GET: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_compileoption_get( + arg1: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_COMPILEOPTION_GET + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_COMPILEOPTION_USED: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_compileoption_used( + arg1: *const ::std::os::raw::c_char, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_COMPILEOPTION_USED + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_CREATE_FUNCTION_V2: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_void, + xFunc: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xStep: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xFinal: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_context), + >, + xDestroy: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_create_function_v2( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_void, + xFunc: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xStep: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xFinal: ::std::option::Option, + xDestroy: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_CREATE_FUNCTION_V2 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5, xFunc, xStep, xFinal, xDestroy) +} + +static __SQLITE3_DB_CONFIG: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + ... + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_db_config( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_DB_CONFIG + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_DB_MUTEX: ::atomic::Atomic< + Option *mut sqlite3_mutex>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_db_mutex(arg1: *mut sqlite3) -> *mut sqlite3_mutex { + let fun = __SQLITE3_DB_MUTEX + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_DB_STATUS: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + arg3: *mut ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_int, + arg5: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_db_status( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + arg3: *mut ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_int, + arg5: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_DB_STATUS + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5) +} + +static __SQLITE3_EXTENDED_ERRCODE: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_extended_errcode(arg1: *mut sqlite3) -> ::std::os::raw::c_int { + let fun = __SQLITE3_EXTENDED_ERRCODE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_LOG: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + arg2: *const ::std::os::raw::c_char, + ... + ), + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_log( + arg1: ::std::os::raw::c_int, + arg2: *const ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, +) { + let fun = __SQLITE3_LOG + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_SOFT_HEAP_LIMIT64: ::atomic::Atomic< + Option sqlite3_int64>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_soft_heap_limit64(arg1: sqlite3_int64) -> sqlite3_int64 { + let fun = __SQLITE3_SOFT_HEAP_LIMIT64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_SOURCEID: ::atomic::Atomic< + Option *const ::std::os::raw::c_char>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_sourceid() -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_SOURCEID + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)() +} + +static __SQLITE3_STMT_STATUS: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_stmt_status( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_STMT_STATUS + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_STRNICMP: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_strnicmp( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_STRNICMP + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_UNLOCK_NOTIFY: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + ), + >, + arg3: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_unlock_notify( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + ), + >, + arg3: *mut ::std::os::raw::c_void, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_UNLOCK_NOTIFY + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_WAL_AUTOCHECKPOINT: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_wal_autocheckpoint( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_WAL_AUTOCHECKPOINT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_WAL_CHECKPOINT: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_wal_checkpoint( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_WAL_CHECKPOINT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_WAL_HOOK: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut sqlite3, + arg3: *const ::std::os::raw::c_char, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_wal_hook( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut sqlite3, + arg3: *const ::std::os::raw::c_char, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, +) -> *mut ::std::os::raw::c_void { + let fun = __SQLITE3_WAL_HOOK + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_BLOB_REOPEN: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_blob, + arg2: sqlite3_int64, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_blob_reopen( + arg1: *mut sqlite3_blob, + arg2: sqlite3_int64, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BLOB_REOPEN + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_VTAB_CONFIG: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + op: ::std::os::raw::c_int, + ... + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_vtab_config( + arg1: *mut sqlite3, + op: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_VTAB_CONFIG + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, op) +} + +static __SQLITE3_VTAB_ON_CONFLICT: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_vtab_on_conflict(arg1: *mut sqlite3) -> ::std::os::raw::c_int { + let fun = __SQLITE3_VTAB_ON_CONFLICT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_CLOSE_V2: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_close_v2(arg1: *mut sqlite3) -> ::std::os::raw::c_int { + let fun = __SQLITE3_CLOSE_V2 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_DB_FILENAME: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + ) -> *const ::std::os::raw::c_char, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_db_filename( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, +) -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_DB_FILENAME + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_DB_READONLY: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_db_readonly( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_DB_READONLY + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_DB_RELEASE_MEMORY: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_db_release_memory(arg1: *mut sqlite3) -> ::std::os::raw::c_int { + let fun = __SQLITE3_DB_RELEASE_MEMORY + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_ERRSTR: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_errstr( + arg1: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_ERRSTR + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_STMT_BUSY: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_stmt_busy(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int { + let fun = __SQLITE3_STMT_BUSY + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_STMT_READONLY: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_stmt_readonly(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int { + let fun = __SQLITE3_STMT_READONLY + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_STRICMP: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_stricmp( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_STRICMP + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_URI_BOOLEAN: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_uri_boolean( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_URI_BOOLEAN + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_URI_INT64: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: sqlite3_int64, + ) -> sqlite3_int64, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_uri_int64( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: sqlite3_int64, +) -> sqlite3_int64 { + let fun = __SQLITE3_URI_INT64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_URI_PARAMETER: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + ) -> *const ::std::os::raw::c_char, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_uri_parameter( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, +) -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_URI_PARAMETER + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_URI_VSNPRINTF: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + arg2: *mut ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_char, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_uri_vsnprintf( + arg1: ::std::os::raw::c_int, + arg2: *mut ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: *mut ::std::os::raw::c_void, +) -> *mut ::std::os::raw::c_char { + let fun = __SQLITE3_URI_VSNPRINTF + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_WAL_CHECKPOINT_V2: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_wal_checkpoint_v2( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_WAL_CHECKPOINT_V2 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5) +} + +static __SQLITE3_AUTO_EXTENSION: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_auto_extension( + arg1: ::std::option::Option, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_AUTO_EXTENSION + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_BIND_BLOB64: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: sqlite3_uint64, + arg5: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_bind_blob64( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: sqlite3_uint64, + arg5: ::std::option::Option, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BIND_BLOB64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5) +} + +static __SQLITE3_BIND_TEXT64: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + arg4: sqlite3_uint64, + arg5: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + arg6: ::std::os::raw::c_uchar, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_bind_text64( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + arg4: sqlite3_uint64, + arg5: ::std::option::Option, + arg6: ::std::os::raw::c_uchar, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BIND_TEXT64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5, arg6) +} + +static __SQLITE3_CANCEL_AUTO_EXTENSION: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_cancel_auto_extension( + arg1: ::std::option::Option, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_CANCEL_AUTO_EXTENSION + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_LOAD_EXTENSION: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: *mut *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_load_extension( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: *mut *mut ::std::os::raw::c_char, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_LOAD_EXTENSION + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_MALLOC64: ::atomic::Atomic< + Option *mut ::std::os::raw::c_void>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_malloc64(arg1: sqlite3_uint64) -> *mut ::std::os::raw::c_void { + let fun = __SQLITE3_MALLOC64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_MSIZE: ::atomic::Atomic< + Option sqlite3_uint64>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_msize(arg1: *mut ::std::os::raw::c_void) -> sqlite3_uint64 { + let fun = __SQLITE3_MSIZE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_REALLOC64: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: sqlite3_uint64, + ) -> *mut ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_realloc64( + arg1: *mut ::std::os::raw::c_void, + arg2: sqlite3_uint64, +) -> *mut ::std::os::raw::c_void { + let fun = __SQLITE3_REALLOC64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_RESET_AUTO_EXTENSION: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_reset_auto_extension() { + let fun = __SQLITE3_RESET_AUTO_EXTENSION + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)() +} + +static __SQLITE3_RESULT_BLOB64: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: sqlite3_uint64, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ), + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_blob64( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: sqlite3_uint64, + arg4: ::std::option::Option, +) { + let fun = __SQLITE3_RESULT_BLOB64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_RESULT_TEXT64: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_char, + arg3: sqlite3_uint64, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + arg5: ::std::os::raw::c_uchar, + ), + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_text64( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_char, + arg3: sqlite3_uint64, + arg4: ::std::option::Option, + arg5: ::std::os::raw::c_uchar, +) { + let fun = __SQLITE3_RESULT_TEXT64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5) +} + +static __SQLITE3_STRGLOB: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_strglob( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_STRGLOB + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_VALUE_DUP: ::atomic::Atomic< + Option *mut sqlite3_value>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_dup(arg1: *const sqlite3_value) -> *mut sqlite3_value { + let fun = __SQLITE3_VALUE_DUP + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VALUE_FREE: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_free(arg1: *mut sqlite3_value) { + let fun = __SQLITE3_VALUE_FREE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_RESULT_ZEROBLOB64: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: sqlite3_uint64, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_zeroblob64( + arg1: *mut sqlite3_context, + arg2: sqlite3_uint64, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_RESULT_ZEROBLOB64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_BIND_ZEROBLOB64: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: sqlite3_uint64, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_bind_zeroblob64( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: sqlite3_uint64, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BIND_ZEROBLOB64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_VALUE_SUBTYPE: ::atomic::Atomic< + Option ::std::os::raw::c_uint>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_subtype(arg1: *mut sqlite3_value) -> ::std::os::raw::c_uint { + let fun = __SQLITE3_VALUE_SUBTYPE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_RESULT_SUBTYPE: ::atomic::Atomic< + Option< + unsafe extern "C" fn(arg1: *mut sqlite3_context, arg2: ::std::os::raw::c_uint), + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_subtype( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_uint, +) { + let fun = __SQLITE3_RESULT_SUBTYPE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_STATUS64: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + arg2: *mut sqlite3_int64, + arg3: *mut sqlite3_int64, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_status64( + arg1: ::std::os::raw::c_int, + arg2: *mut sqlite3_int64, + arg3: *mut sqlite3_int64, + arg4: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_STATUS64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_STRLIKE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_uint, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_strlike( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_uint, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_STRLIKE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_DB_CACHEFLUSH: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_db_cacheflush(arg1: *mut sqlite3) -> ::std::os::raw::c_int { + let fun = __SQLITE3_DB_CACHEFLUSH + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_SYSTEM_ERRNO: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_system_errno(arg1: *mut sqlite3) -> ::std::os::raw::c_int { + let fun = __SQLITE3_SYSTEM_ERRNO + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_TRACE_V2: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_uint, + arg3: ::std::option::Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_uint, + arg2: *mut ::std::os::raw::c_void, + arg3: *mut ::std::os::raw::c_void, + arg4: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + arg4: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_trace_v2( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_uint, + arg3: ::std::option::Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_uint, + arg2: *mut ::std::os::raw::c_void, + arg3: *mut ::std::os::raw::c_void, + arg4: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + arg4: *mut ::std::os::raw::c_void, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_TRACE_V2 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_EXPANDED_SQL: ::atomic::Atomic< + Option *mut ::std::os::raw::c_char>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_expanded_sql( + arg1: *mut sqlite3_stmt, +) -> *mut ::std::os::raw::c_char { + let fun = __SQLITE3_EXPANDED_SQL + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +/// Loadable extension initialization error +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[non_exhaustive] +pub enum InitError { + /// Invalid sqlite3_api_routines pointer + NullApiPointer, + /// Version mismatch between the extension and the SQLite3 library + VersionMismatch { compile_time: i32, runtime: i32 }, + /// Invalid function pointer in one of sqlite3_api_routines fields + NullFunctionPointer, +} +impl ::std::fmt::Display for InitError { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + match *self { + InitError::NullApiPointer => { + write!(f, "Invalid sqlite3_api_routines pointer") + } + InitError::VersionMismatch { compile_time, runtime } => { + write!(f, "SQLite version mismatch: {runtime} < {compile_time}") + } + InitError::NullFunctionPointer => { + write!(f, "Some sqlite3_api_routines fields are null") + } + } + } +} +/// Like SQLITE_EXTENSION_INIT2 macro +pub unsafe fn rusqlite_extension_init2( + p_api: *mut sqlite3_api_routines, +) -> ::std::result::Result<(), InitError> { + if p_api.is_null() { + return Err(InitError::NullApiPointer); + } + if let Some(fun) = (*p_api).libversion_number { + let version = fun(); + if SQLITE_VERSION_NUMBER > version { + return Err(InitError::VersionMismatch { + compile_time: SQLITE_VERSION_NUMBER, + runtime: version, + }); + } + } else { + return Err(InitError::NullFunctionPointer); + } + __SQLITE3_AGGREGATE_CONTEXT + .store((*p_api).aggregate_context, ::atomic::Ordering::Release); + __SQLITE3_AGGREGATE_COUNT + .store((*p_api).aggregate_count, ::atomic::Ordering::Release); + __SQLITE3_BIND_BLOB.store((*p_api).bind_blob, ::atomic::Ordering::Release); + __SQLITE3_BIND_DOUBLE.store((*p_api).bind_double, ::atomic::Ordering::Release); + __SQLITE3_BIND_INT.store((*p_api).bind_int, ::atomic::Ordering::Release); + __SQLITE3_BIND_INT64.store((*p_api).bind_int64, ::atomic::Ordering::Release); + __SQLITE3_BIND_NULL.store((*p_api).bind_null, ::atomic::Ordering::Release); + __SQLITE3_BIND_PARAMETER_COUNT + .store((*p_api).bind_parameter_count, ::atomic::Ordering::Release); + __SQLITE3_BIND_PARAMETER_INDEX + .store((*p_api).bind_parameter_index, ::atomic::Ordering::Release); + __SQLITE3_BIND_PARAMETER_NAME + .store((*p_api).bind_parameter_name, ::atomic::Ordering::Release); + __SQLITE3_BIND_TEXT.store((*p_api).bind_text, ::atomic::Ordering::Release); + __SQLITE3_BIND_TEXT16.store((*p_api).bind_text16, ::atomic::Ordering::Release); + __SQLITE3_BIND_VALUE.store((*p_api).bind_value, ::atomic::Ordering::Release); + __SQLITE3_BUSY_HANDLER.store((*p_api).busy_handler, ::atomic::Ordering::Release); + __SQLITE3_BUSY_TIMEOUT.store((*p_api).busy_timeout, ::atomic::Ordering::Release); + __SQLITE3_CHANGES.store((*p_api).changes, ::atomic::Ordering::Release); + __SQLITE3_CLOSE.store((*p_api).close, ::atomic::Ordering::Release); + __SQLITE3_COLLATION_NEEDED + .store((*p_api).collation_needed, ::atomic::Ordering::Release); + __SQLITE3_COLLATION_NEEDED16 + .store((*p_api).collation_needed16, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_BLOB.store((*p_api).column_blob, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_BYTES.store((*p_api).column_bytes, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_BYTES16.store((*p_api).column_bytes16, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_COUNT.store((*p_api).column_count, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_DATABASE_NAME + .store((*p_api).column_database_name, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_DATABASE_NAME16 + .store((*p_api).column_database_name16, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_DECLTYPE + .store((*p_api).column_decltype, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_DECLTYPE16 + .store((*p_api).column_decltype16, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_DOUBLE.store((*p_api).column_double, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_INT.store((*p_api).column_int, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_INT64.store((*p_api).column_int64, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_NAME.store((*p_api).column_name, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_NAME16.store((*p_api).column_name16, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_ORIGIN_NAME + .store((*p_api).column_origin_name, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_ORIGIN_NAME16 + .store((*p_api).column_origin_name16, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_TABLE_NAME + .store((*p_api).column_table_name, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_TABLE_NAME16 + .store((*p_api).column_table_name16, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_TEXT.store((*p_api).column_text, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_TEXT16.store((*p_api).column_text16, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_TYPE.store((*p_api).column_type, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_VALUE.store((*p_api).column_value, ::atomic::Ordering::Release); + __SQLITE3_COMMIT_HOOK.store((*p_api).commit_hook, ::atomic::Ordering::Release); + __SQLITE3_COMPLETE.store((*p_api).complete, ::atomic::Ordering::Release); + __SQLITE3_COMPLETE16.store((*p_api).complete16, ::atomic::Ordering::Release); + __SQLITE3_CREATE_COLLATION + .store((*p_api).create_collation, ::atomic::Ordering::Release); + __SQLITE3_CREATE_COLLATION16 + .store((*p_api).create_collation16, ::atomic::Ordering::Release); + __SQLITE3_CREATE_FUNCTION + .store((*p_api).create_function, ::atomic::Ordering::Release); + __SQLITE3_CREATE_FUNCTION16 + .store((*p_api).create_function16, ::atomic::Ordering::Release); + __SQLITE3_CREATE_MODULE.store((*p_api).create_module, ::atomic::Ordering::Release); + __SQLITE3_DATA_COUNT.store((*p_api).data_count, ::atomic::Ordering::Release); + __SQLITE3_DB_HANDLE.store((*p_api).db_handle, ::atomic::Ordering::Release); + __SQLITE3_DECLARE_VTAB.store((*p_api).declare_vtab, ::atomic::Ordering::Release); + __SQLITE3_ENABLE_SHARED_CACHE + .store((*p_api).enable_shared_cache, ::atomic::Ordering::Release); + __SQLITE3_ERRCODE.store((*p_api).errcode, ::atomic::Ordering::Release); + __SQLITE3_ERRMSG.store((*p_api).errmsg, ::atomic::Ordering::Release); + __SQLITE3_ERRMSG16.store((*p_api).errmsg16, ::atomic::Ordering::Release); + __SQLITE3_EXEC.store((*p_api).exec, ::atomic::Ordering::Release); + __SQLITE3_EXPIRED.store((*p_api).expired, ::atomic::Ordering::Release); + __SQLITE3_FINALIZE.store((*p_api).finalize, ::atomic::Ordering::Release); + __SQLITE3_FREE.store((*p_api).free, ::atomic::Ordering::Release); + __SQLITE3_FREE_TABLE.store((*p_api).free_table, ::atomic::Ordering::Release); + __SQLITE3_GET_AUTOCOMMIT.store((*p_api).get_autocommit, ::atomic::Ordering::Release); + __SQLITE3_GET_AUXDATA.store((*p_api).get_auxdata, ::atomic::Ordering::Release); + __SQLITE3_GET_TABLE.store((*p_api).get_table, ::atomic::Ordering::Release); + __SQLITE3_GLOBAL_RECOVER.store((*p_api).global_recover, ::atomic::Ordering::Release); + __SQLITE3_INTERRUPT.store((*p_api).interruptx, ::atomic::Ordering::Release); + __SQLITE3_LAST_INSERT_ROWID + .store((*p_api).last_insert_rowid, ::atomic::Ordering::Release); + __SQLITE3_LIBVERSION.store((*p_api).libversion, ::atomic::Ordering::Release); + __SQLITE3_LIBVERSION_NUMBER + .store((*p_api).libversion_number, ::atomic::Ordering::Release); + __SQLITE3_MALLOC.store((*p_api).malloc, ::atomic::Ordering::Release); + __SQLITE3_OPEN.store((*p_api).open, ::atomic::Ordering::Release); + __SQLITE3_OPEN16.store((*p_api).open16, ::atomic::Ordering::Release); + __SQLITE3_PREPARE.store((*p_api).prepare, ::atomic::Ordering::Release); + __SQLITE3_PREPARE16.store((*p_api).prepare16, ::atomic::Ordering::Release); + __SQLITE3_PROFILE.store((*p_api).profile, ::atomic::Ordering::Release); + __SQLITE3_PROGRESS_HANDLER + .store((*p_api).progress_handler, ::atomic::Ordering::Release); + __SQLITE3_REALLOC.store((*p_api).realloc, ::atomic::Ordering::Release); + __SQLITE3_RESET.store((*p_api).reset, ::atomic::Ordering::Release); + __SQLITE3_RESULT_BLOB.store((*p_api).result_blob, ::atomic::Ordering::Release); + __SQLITE3_RESULT_DOUBLE.store((*p_api).result_double, ::atomic::Ordering::Release); + __SQLITE3_RESULT_ERROR.store((*p_api).result_error, ::atomic::Ordering::Release); + __SQLITE3_RESULT_ERROR16.store((*p_api).result_error16, ::atomic::Ordering::Release); + __SQLITE3_RESULT_INT.store((*p_api).result_int, ::atomic::Ordering::Release); + __SQLITE3_RESULT_INT64.store((*p_api).result_int64, ::atomic::Ordering::Release); + __SQLITE3_RESULT_NULL.store((*p_api).result_null, ::atomic::Ordering::Release); + __SQLITE3_RESULT_TEXT.store((*p_api).result_text, ::atomic::Ordering::Release); + __SQLITE3_RESULT_TEXT16.store((*p_api).result_text16, ::atomic::Ordering::Release); + __SQLITE3_RESULT_TEXT16BE + .store((*p_api).result_text16be, ::atomic::Ordering::Release); + __SQLITE3_RESULT_TEXT16LE + .store((*p_api).result_text16le, ::atomic::Ordering::Release); + __SQLITE3_RESULT_VALUE.store((*p_api).result_value, ::atomic::Ordering::Release); + __SQLITE3_ROLLBACK_HOOK.store((*p_api).rollback_hook, ::atomic::Ordering::Release); + __SQLITE3_SET_AUTHORIZER.store((*p_api).set_authorizer, ::atomic::Ordering::Release); + __SQLITE3_SET_AUXDATA.store((*p_api).set_auxdata, ::atomic::Ordering::Release); + __SQLITE3_STEP.store((*p_api).step, ::atomic::Ordering::Release); + __SQLITE3_TABLE_COLUMN_METADATA + .store((*p_api).table_column_metadata, ::atomic::Ordering::Release); + __SQLITE3_THREAD_CLEANUP.store((*p_api).thread_cleanup, ::atomic::Ordering::Release); + __SQLITE3_TOTAL_CHANGES.store((*p_api).total_changes, ::atomic::Ordering::Release); + __SQLITE3_TRACE.store((*p_api).trace, ::atomic::Ordering::Release); + __SQLITE3_TRANSFER_BINDINGS + .store((*p_api).transfer_bindings, ::atomic::Ordering::Release); + __SQLITE3_UPDATE_HOOK.store((*p_api).update_hook, ::atomic::Ordering::Release); + __SQLITE3_USER_DATA.store((*p_api).user_data, ::atomic::Ordering::Release); + __SQLITE3_VALUE_BLOB.store((*p_api).value_blob, ::atomic::Ordering::Release); + __SQLITE3_VALUE_BYTES.store((*p_api).value_bytes, ::atomic::Ordering::Release); + __SQLITE3_VALUE_BYTES16.store((*p_api).value_bytes16, ::atomic::Ordering::Release); + __SQLITE3_VALUE_DOUBLE.store((*p_api).value_double, ::atomic::Ordering::Release); + __SQLITE3_VALUE_INT.store((*p_api).value_int, ::atomic::Ordering::Release); + __SQLITE3_VALUE_INT64.store((*p_api).value_int64, ::atomic::Ordering::Release); + __SQLITE3_VALUE_NUMERIC_TYPE + .store((*p_api).value_numeric_type, ::atomic::Ordering::Release); + __SQLITE3_VALUE_TEXT.store((*p_api).value_text, ::atomic::Ordering::Release); + __SQLITE3_VALUE_TEXT16.store((*p_api).value_text16, ::atomic::Ordering::Release); + __SQLITE3_VALUE_TEXT16BE.store((*p_api).value_text16be, ::atomic::Ordering::Release); + __SQLITE3_VALUE_TEXT16LE.store((*p_api).value_text16le, ::atomic::Ordering::Release); + __SQLITE3_VALUE_TYPE.store((*p_api).value_type, ::atomic::Ordering::Release); + __SQLITE3_OVERLOAD_FUNCTION + .store((*p_api).overload_function, ::atomic::Ordering::Release); + __SQLITE3_PREPARE_V2.store((*p_api).prepare_v2, ::atomic::Ordering::Release); + __SQLITE3_PREPARE16_V2.store((*p_api).prepare16_v2, ::atomic::Ordering::Release); + __SQLITE3_CLEAR_BINDINGS.store((*p_api).clear_bindings, ::atomic::Ordering::Release); + __SQLITE3_CREATE_MODULE_V2 + .store((*p_api).create_module_v2, ::atomic::Ordering::Release); + __SQLITE3_BIND_ZEROBLOB.store((*p_api).bind_zeroblob, ::atomic::Ordering::Release); + __SQLITE3_BLOB_BYTES.store((*p_api).blob_bytes, ::atomic::Ordering::Release); + __SQLITE3_BLOB_CLOSE.store((*p_api).blob_close, ::atomic::Ordering::Release); + __SQLITE3_BLOB_OPEN.store((*p_api).blob_open, ::atomic::Ordering::Release); + __SQLITE3_BLOB_READ.store((*p_api).blob_read, ::atomic::Ordering::Release); + __SQLITE3_BLOB_WRITE.store((*p_api).blob_write, ::atomic::Ordering::Release); + __SQLITE3_CREATE_COLLATION_V2 + .store((*p_api).create_collation_v2, ::atomic::Ordering::Release); + __SQLITE3_FILE_CONTROL.store((*p_api).file_control, ::atomic::Ordering::Release); + __SQLITE3_MEMORY_HIGHWATER + .store((*p_api).memory_highwater, ::atomic::Ordering::Release); + __SQLITE3_MEMORY_USED.store((*p_api).memory_used, ::atomic::Ordering::Release); + __SQLITE3_MUTEX_ALLOC.store((*p_api).mutex_alloc, ::atomic::Ordering::Release); + __SQLITE3_MUTEX_ENTER.store((*p_api).mutex_enter, ::atomic::Ordering::Release); + __SQLITE3_MUTEX_FREE.store((*p_api).mutex_free, ::atomic::Ordering::Release); + __SQLITE3_MUTEX_LEAVE.store((*p_api).mutex_leave, ::atomic::Ordering::Release); + __SQLITE3_MUTEX_TRY.store((*p_api).mutex_try, ::atomic::Ordering::Release); + __SQLITE3_OPEN_V2.store((*p_api).open_v2, ::atomic::Ordering::Release); + __SQLITE3_RELEASE_MEMORY.store((*p_api).release_memory, ::atomic::Ordering::Release); + __SQLITE3_RESULT_ERROR_NOMEM + .store((*p_api).result_error_nomem, ::atomic::Ordering::Release); + __SQLITE3_RESULT_ERROR_TOOBIG + .store((*p_api).result_error_toobig, ::atomic::Ordering::Release); + __SQLITE3_SLEEP.store((*p_api).sleep, ::atomic::Ordering::Release); + __SQLITE3_SOFT_HEAP_LIMIT + .store((*p_api).soft_heap_limit, ::atomic::Ordering::Release); + __SQLITE3_VFS_FIND.store((*p_api).vfs_find, ::atomic::Ordering::Release); + __SQLITE3_VFS_REGISTER.store((*p_api).vfs_register, ::atomic::Ordering::Release); + __SQLITE3_VFS_UNREGISTER.store((*p_api).vfs_unregister, ::atomic::Ordering::Release); + __SQLITE3_THREADSAFE.store((*p_api).xthreadsafe, ::atomic::Ordering::Release); + __SQLITE3_RESULT_ZEROBLOB + .store((*p_api).result_zeroblob, ::atomic::Ordering::Release); + __SQLITE3_RESULT_ERROR_CODE + .store((*p_api).result_error_code, ::atomic::Ordering::Release); + __SQLITE3_RANDOMNESS.store((*p_api).randomness, ::atomic::Ordering::Release); + __SQLITE3_CONTEXT_DB_HANDLE + .store((*p_api).context_db_handle, ::atomic::Ordering::Release); + __SQLITE3_EXTENDED_RESULT_CODES + .store((*p_api).extended_result_codes, ::atomic::Ordering::Release); + __SQLITE3_LIMIT.store((*p_api).limit, ::atomic::Ordering::Release); + __SQLITE3_NEXT_STMT.store((*p_api).next_stmt, ::atomic::Ordering::Release); + __SQLITE3_SQL.store((*p_api).sql, ::atomic::Ordering::Release); + __SQLITE3_STATUS.store((*p_api).status, ::atomic::Ordering::Release); + __SQLITE3_BACKUP_FINISH.store((*p_api).backup_finish, ::atomic::Ordering::Release); + __SQLITE3_BACKUP_INIT.store((*p_api).backup_init, ::atomic::Ordering::Release); + __SQLITE3_BACKUP_PAGECOUNT + .store((*p_api).backup_pagecount, ::atomic::Ordering::Release); + __SQLITE3_BACKUP_REMAINING + .store((*p_api).backup_remaining, ::atomic::Ordering::Release); + __SQLITE3_BACKUP_STEP.store((*p_api).backup_step, ::atomic::Ordering::Release); + __SQLITE3_COMPILEOPTION_GET + .store((*p_api).compileoption_get, ::atomic::Ordering::Release); + __SQLITE3_COMPILEOPTION_USED + .store((*p_api).compileoption_used, ::atomic::Ordering::Release); + __SQLITE3_CREATE_FUNCTION_V2 + .store((*p_api).create_function_v2, ::atomic::Ordering::Release); + __SQLITE3_DB_CONFIG.store((*p_api).db_config, ::atomic::Ordering::Release); + __SQLITE3_DB_MUTEX.store((*p_api).db_mutex, ::atomic::Ordering::Release); + __SQLITE3_DB_STATUS.store((*p_api).db_status, ::atomic::Ordering::Release); + __SQLITE3_EXTENDED_ERRCODE + .store((*p_api).extended_errcode, ::atomic::Ordering::Release); + __SQLITE3_LOG.store((*p_api).log, ::atomic::Ordering::Release); + __SQLITE3_SOFT_HEAP_LIMIT64 + .store((*p_api).soft_heap_limit64, ::atomic::Ordering::Release); + __SQLITE3_SOURCEID.store((*p_api).sourceid, ::atomic::Ordering::Release); + __SQLITE3_STMT_STATUS.store((*p_api).stmt_status, ::atomic::Ordering::Release); + __SQLITE3_STRNICMP.store((*p_api).strnicmp, ::atomic::Ordering::Release); + __SQLITE3_UNLOCK_NOTIFY.store((*p_api).unlock_notify, ::atomic::Ordering::Release); + __SQLITE3_WAL_AUTOCHECKPOINT + .store((*p_api).wal_autocheckpoint, ::atomic::Ordering::Release); + __SQLITE3_WAL_CHECKPOINT.store((*p_api).wal_checkpoint, ::atomic::Ordering::Release); + __SQLITE3_WAL_HOOK.store((*p_api).wal_hook, ::atomic::Ordering::Release); + __SQLITE3_BLOB_REOPEN.store((*p_api).blob_reopen, ::atomic::Ordering::Release); + __SQLITE3_VTAB_CONFIG.store((*p_api).vtab_config, ::atomic::Ordering::Release); + __SQLITE3_VTAB_ON_CONFLICT + .store((*p_api).vtab_on_conflict, ::atomic::Ordering::Release); + __SQLITE3_CLOSE_V2.store((*p_api).close_v2, ::atomic::Ordering::Release); + __SQLITE3_DB_FILENAME.store((*p_api).db_filename, ::atomic::Ordering::Release); + __SQLITE3_DB_READONLY.store((*p_api).db_readonly, ::atomic::Ordering::Release); + __SQLITE3_DB_RELEASE_MEMORY + .store((*p_api).db_release_memory, ::atomic::Ordering::Release); + __SQLITE3_ERRSTR.store((*p_api).errstr, ::atomic::Ordering::Release); + __SQLITE3_STMT_BUSY.store((*p_api).stmt_busy, ::atomic::Ordering::Release); + __SQLITE3_STMT_READONLY.store((*p_api).stmt_readonly, ::atomic::Ordering::Release); + __SQLITE3_STRICMP.store((*p_api).stricmp, ::atomic::Ordering::Release); + __SQLITE3_URI_BOOLEAN.store((*p_api).uri_boolean, ::atomic::Ordering::Release); + __SQLITE3_URI_INT64.store((*p_api).uri_int64, ::atomic::Ordering::Release); + __SQLITE3_URI_PARAMETER.store((*p_api).uri_parameter, ::atomic::Ordering::Release); + __SQLITE3_URI_VSNPRINTF.store((*p_api).vsnprintf, ::atomic::Ordering::Release); + __SQLITE3_WAL_CHECKPOINT_V2 + .store((*p_api).wal_checkpoint_v2, ::atomic::Ordering::Release); + __SQLITE3_AUTO_EXTENSION.store((*p_api).auto_extension, ::atomic::Ordering::Release); + __SQLITE3_BIND_BLOB64.store((*p_api).bind_blob64, ::atomic::Ordering::Release); + __SQLITE3_BIND_TEXT64.store((*p_api).bind_text64, ::atomic::Ordering::Release); + __SQLITE3_CANCEL_AUTO_EXTENSION + .store((*p_api).cancel_auto_extension, ::atomic::Ordering::Release); + __SQLITE3_LOAD_EXTENSION.store((*p_api).load_extension, ::atomic::Ordering::Release); + __SQLITE3_MALLOC64.store((*p_api).malloc64, ::atomic::Ordering::Release); + __SQLITE3_MSIZE.store((*p_api).msize, ::atomic::Ordering::Release); + __SQLITE3_REALLOC64.store((*p_api).realloc64, ::atomic::Ordering::Release); + __SQLITE3_RESET_AUTO_EXTENSION + .store((*p_api).reset_auto_extension, ::atomic::Ordering::Release); + __SQLITE3_RESULT_BLOB64.store((*p_api).result_blob64, ::atomic::Ordering::Release); + __SQLITE3_RESULT_TEXT64.store((*p_api).result_text64, ::atomic::Ordering::Release); + __SQLITE3_STRGLOB.store((*p_api).strglob, ::atomic::Ordering::Release); + __SQLITE3_VALUE_DUP.store((*p_api).value_dup, ::atomic::Ordering::Release); + __SQLITE3_VALUE_FREE.store((*p_api).value_free, ::atomic::Ordering::Release); + __SQLITE3_RESULT_ZEROBLOB64 + .store((*p_api).result_zeroblob64, ::atomic::Ordering::Release); + __SQLITE3_BIND_ZEROBLOB64 + .store((*p_api).bind_zeroblob64, ::atomic::Ordering::Release); + __SQLITE3_VALUE_SUBTYPE.store((*p_api).value_subtype, ::atomic::Ordering::Release); + __SQLITE3_RESULT_SUBTYPE.store((*p_api).result_subtype, ::atomic::Ordering::Release); + __SQLITE3_STATUS64.store((*p_api).status64, ::atomic::Ordering::Release); + __SQLITE3_STRLIKE.store((*p_api).strlike, ::atomic::Ordering::Release); + __SQLITE3_DB_CACHEFLUSH.store((*p_api).db_cacheflush, ::atomic::Ordering::Release); + __SQLITE3_SYSTEM_ERRNO.store((*p_api).system_errno, ::atomic::Ordering::Release); + __SQLITE3_TRACE_V2.store((*p_api).trace_v2, ::atomic::Ordering::Release); + __SQLITE3_EXPANDED_SQL.store((*p_api).expanded_sql, ::atomic::Ordering::Release); + Ok(()) +} + diff --git a/libsqlite3-sys/build.rs b/libsqlite3-sys/build.rs index e3aefad..93a1a8d 100644 --- a/libsqlite3-sys/build.rs +++ b/libsqlite3-sys/build.rs @@ -28,8 +28,12 @@ fn is_compiler(compiler_name: &str) -> bool { /// Copy bindgen file from `dir` to `out_path`. fn copy_bindings>(dir: &str, bindgen_name: &str, out_path: T) { - std::fs::copy(format!("{dir}/{bindgen_name}"), out_path) - .expect("Could not copy bindings to output directory"); + let from = if cfg!(feature = "loadable_extension") { + format!("{dir}/{bindgen_name}_ext.rs") + } else { + format!("{dir}/{bindgen_name}.rs") + }; + std::fs::copy(from, out_path).expect("Could not copy bindings to output directory"); } fn main() { @@ -38,12 +42,14 @@ fn main() { if cfg!(feature = "in_gecko") { // When inside mozilla-central, we are included into the build with // sqlite3.o directly, so we don't want to provide any linker arguments. - copy_bindings("sqlite3", "bindgen_bundled_version.rs", out_path); + copy_bindings("sqlite3", "bindgen_bundled_version", out_path); return; } println!("cargo:rerun-if-env-changed=LIBSQLITE3_SYS_USE_PKG_CONFIG"); - if env::var_os("LIBSQLITE3_SYS_USE_PKG_CONFIG").map_or(false, |s| s != "0") { + if env::var_os("LIBSQLITE3_SYS_USE_PKG_CONFIG").map_or(false, |s| s != "0") + || cfg!(feature = "loadable_extension") + { build_linked::main(&out_dir, &out_path); } else if cfg!(all( feature = "sqlcipher", @@ -106,7 +112,7 @@ mod build_bundled { } #[cfg(not(feature = "buildtime_bindgen"))] { - super::copy_bindings(lib_name, "bindgen_bundled_version.rs", out_path); + super::copy_bindings(lib_name, "bindgen_bundled_version", out_path); } println!("cargo:rerun-if-changed={lib_name}/sqlite3.c"); println!("cargo:rerun-if-changed=sqlite3/wasm32-wasi-vfs.c"); @@ -344,11 +350,28 @@ impl From for String { prefix, prefix ) }); - header.push_str("/sqlite3.h"); + header.push_str(if cfg!(feature = "loadable_extension") { + "/sqlite3ext.h" + } else { + "/sqlite3.h" + }); header } - HeaderLocation::Wrapper => "wrapper.h".into(), - HeaderLocation::FromPath(path) => format!("{}/sqlite3.h", path), + HeaderLocation::Wrapper => if cfg!(feature = "loadable_extension") { + "wrapper_ext.h" + } else { + "wrapper.h" + } + .into(), + HeaderLocation::FromPath(path) => format!( + "{}/{}", + path, + if cfg!(feature = "loadable_extension") { + "sqlite3ext.h" + } else { + "sqlite3.h" + } + ), } } } @@ -375,12 +398,13 @@ mod build_linked { // on buildtime_bindgen instead, but this is still supported as we // have runtime version checks and there are good reasons to not // want to run bindgen. - super::copy_bindings(lib_name(), "bindgen_bundled_version.rs", out_path); + super::copy_bindings(lib_name(), "bindgen_bundled_version", out_path); } else { bindings::write_to_out_dir(header, out_path); } } + #[cfg(not(feature = "loadable_extension"))] fn find_link_mode() -> &'static str { // If the user specifies SQLITE3_STATIC (or SQLCIPHER_STATIC), do static // linking, unless it's explicitly set to 0. @@ -404,9 +428,11 @@ mod build_linked { // `links=` value in our Cargo.toml) to get this value. This might be // useful if you need to ensure whatever crypto library sqlcipher relies // on is available, for example. + #[cfg(not(feature = "loadable_extension"))] println!("cargo:link-target={link_lib}"); if win_target() && cfg!(feature = "winsqlite3") { + #[cfg(not(feature = "loadable_extension"))] println!("cargo:rustc-link-lib=dylib={link_lib}"); return HeaderLocation::Wrapper; } @@ -416,6 +442,7 @@ mod build_linked { // Try to use pkg-config to determine link commands let pkgconfig_path = Path::new(&dir).join("pkgconfig"); env::set_var("PKG_CONFIG_PATH", pkgconfig_path); + #[cfg(not(feature = "loadable_extension"))] if pkg_config::Config::new().probe(link_lib).is_err() { // Otherwise just emit the bare minimum link commands. println!("cargo:rustc-link-lib={}={link_lib}", find_link_mode()); @@ -443,6 +470,7 @@ mod build_linked { // request and hope that the library exists on the system paths. We used to // output /usr/lib explicitly, but that can introduce other linking problems; // see https://github.com/rusqlite/rusqlite/issues/207. + #[cfg(not(feature = "loadable_extension"))] println!("cargo:rustc-link-lib={}={link_lib}", find_link_mode()); HeaderLocation::Wrapper } @@ -470,7 +498,7 @@ mod bindings { use std::path::Path; - static PREBUILT_BINDGENS: &[&str] = &["bindgen_3.14.0.rs"]; + static PREBUILT_BINDGENS: &[&str] = &["bindgen_3.14.0"]; pub fn write_to_out_dir(_header: HeaderLocation, out_path: &Path) { let name = PREBUILT_BINDGENS[PREBUILT_BINDGENS.len() - 1]; @@ -522,10 +550,14 @@ mod bindings { .disable_nested_struct_naming() .trust_clang_mangling(false) .header(header.clone()) - .parse_callbacks(Box::new(SqliteTypeChooser)) - .blocklist_function("sqlite3_auto_extension") - .raw_line( - r#"extern "C" { + .parse_callbacks(Box::new(SqliteTypeChooser)); + if cfg!(feature = "loadable_extension") { + bindings = bindings.ignore_functions(); // see generate_functions + } else { + bindings = bindings + .blocklist_function("sqlite3_auto_extension") + .raw_line( + r#"extern "C" { pub fn sqlite3_auto_extension( xEntryPoint: ::std::option::Option< unsafe extern "C" fn( @@ -536,10 +568,10 @@ mod bindings { >, ) -> ::std::os::raw::c_int; }"#, - ) - .blocklist_function("sqlite3_cancel_auto_extension") - .raw_line( - r#"extern "C" { + ) + .blocklist_function("sqlite3_cancel_auto_extension") + .raw_line( + r#"extern "C" { pub fn sqlite3_cancel_auto_extension( xEntryPoint: ::std::option::Option< unsafe extern "C" fn( @@ -550,7 +582,8 @@ mod bindings { >, ) -> ::std::os::raw::c_int; }"#, - ); + ); + } if cfg!(any(feature = "sqlcipher", feature = "bundled-sqlcipher")) { bindings = bindings.clang_arg("-DSQLITE_HAS_CODEC"); @@ -621,11 +654,204 @@ mod bindings { .blocklist_item("__.*"); } - bindings + let bindings = bindings .layout_tests(false) .generate() - .unwrap_or_else(|_| panic!("could not run bindgen on header {}", header)) - .write_to_file(out_path) - .unwrap_or_else(|_| panic!("Could not write to {:?}", out_path)); + .unwrap_or_else(|_| panic!("could not run bindgen on header {}", header)); + + if cfg!(feature = "loadable_extension") { + let mut output = Vec::new(); + bindings + .write(Box::new(&mut output)) + .expect("could not write output of bindgen"); + let mut output = String::from_utf8(output).expect("bindgen output was not UTF-8?!"); + super::loadable_extension::generate_functions(&header, &mut output); + std::fs::write(out_path, output.as_bytes()) + } else { + bindings.write_to_file(out_path) + } + .unwrap_or_else(|_| panic!("Could not write to {:?}", out_path)); + } +} + +#[cfg(all(feature = "buildtime_bindgen", feature = "loadable_extension"))] +mod loadable_extension { + use std::collections::HashMap; + + /// try to generate similar rust code for all `#define sqlite3_xyz + /// sqlite3_api->abc` macros` in sqlite3ext.h + pub fn generate_functions(header: &str, output: &mut String) { + // (1) parse macros in sqlite3ext.h + let mappings = parse_macros(header); + // (2) parse sqlite3_api_routines fields from bindgen output + let ast: syn::File = syn::parse_str(output).expect("could not parse bindgen output"); + let sqlite3_api_routines: syn::ItemStruct = ast + .items + .into_iter() + .find_map(|i| { + if let syn::Item::Struct(s) = i { + if s.ident == "sqlite3_api_routines" { + Some(s) + } else { + None + } + } else { + None + } + }) + .expect("could not find sqlite3_api_routines"); + let sqlite3_api_routines_ident = sqlite3_api_routines.ident; + let p_api = quote::format_ident!("p_api"); + let mut stores = Vec::new(); + // (3) `#define sqlite3_xyz sqlite3_api->abc` => `pub unsafe fn + // sqlite3_xyz(args) -> ty {...}` for each `abc` field: + for field in sqlite3_api_routines.fields { + let ident = field.ident.expect("unamed field"); + let span = ident.span(); + let name = ident.to_string(); + if name == "vmprintf" || name == "xvsnprintf" || name == "str_vappendf" { + continue; // skip va_list + } + let sqlite3_name = mappings + .get(&name) + .unwrap_or_else(|| panic!("no mapping for {name}")); + let ptr_name = + syn::Ident::new(format!("__{}", sqlite3_name.to_uppercase()).as_ref(), span); + let sqlite3_fn_name = syn::Ident::new(sqlite3_name, span); + let method = + extract_method(&field.ty).unwrap_or_else(|| panic!("unexpected type for {name}")); + let arg_names: syn::punctuated::Punctuated<&syn::Ident, syn::token::Comma> = method + .inputs + .iter() + .map(|i| &i.name.as_ref().unwrap().0) + .collect(); + let args = &method.inputs; + // vtab_config/sqlite3_vtab_config: ok + let varargs = &method.variadic; + if varargs.is_some() && "db_config" != name && "log" != name && "vtab_config" != name { + continue; // skip ... + } + let ty = &method.output; + let tokens = if "db_config" == name { + quote::quote! { + static #ptr_name: ::atomic::Atomic> = ::atomic::Atomic::new(None); + pub unsafe fn #sqlite3_fn_name(#args arg3: ::std::os::raw::c_int, arg4: *mut ::std::os::raw::c_int) #ty { + let fun = #ptr_name.load(::atomic::Ordering::Acquire).expect("SQLite API not initialized"); + (fun)(#arg_names, arg3, arg4) + } + } + } else if "log" == name { + quote::quote! { + static #ptr_name: ::atomic::Atomic> = ::atomic::Atomic::new(None); + pub unsafe fn #sqlite3_fn_name(#args arg3: *const ::std::os::raw::c_char) #ty { + let fun = #ptr_name.load(::atomic::Ordering::Acquire).expect("SQLite API not initialized"); + (fun)(#arg_names, arg3) + } + } + } else { + quote::quote! { + static #ptr_name: ::atomic::Atomic> = ::atomic::Atomic::new(None); + pub unsafe fn #sqlite3_fn_name(#args) #ty { + let fun = #ptr_name.load(::atomic::Ordering::Acquire).expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(#arg_names) + } + } + }; + output.push_str(&prettyplease::unparse( + &syn::parse2(tokens).expect("could not parse quote output"), + )); + output.push('\n'); + stores.push(quote::quote! { + #ptr_name.store( + (*#p_api).#ident, + ::atomic::Ordering::Release, + ); + }); + } + // (4) generate rust code similar to SQLITE_EXTENSION_INIT2 macro + let tokens = quote::quote! { + /// Loadable extension initialization error + #[derive(Clone, Copy, Debug, PartialEq, Eq)] + #[non_exhaustive] + pub enum InitError { + /// Invalid sqlite3_api_routines pointer + NullApiPointer, + /// Version mismatch between the extension and the SQLite3 library + VersionMismatch{compile_time: i32, runtime: i32}, + /// Invalid function pointer in one of sqlite3_api_routines fields + NullFunctionPointer, + } + impl ::std::fmt::Display for InitError { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + match *self { + InitError::NullApiPointer => write!(f, "Invalid sqlite3_api_routines pointer"), + InitError::VersionMismatch{compile_time, runtime} => write!(f, "SQLite version mismatch: {runtime} < {compile_time}"), + InitError::NullFunctionPointer => write!(f, "Some sqlite3_api_routines fields are null"), + } + } + } + /// Like SQLITE_EXTENSION_INIT2 macro + pub unsafe fn rusqlite_extension_init2(#p_api: *mut #sqlite3_api_routines_ident) -> ::std::result::Result<(),InitError> { + if #p_api.is_null() { + return Err(InitError::NullApiPointer); + } + if let Some(fun) = (*#p_api).libversion_number { + let version = fun(); + if SQLITE_VERSION_NUMBER > version { + return Err(InitError::VersionMismatch{compile_time: SQLITE_VERSION_NUMBER, runtime: version}); + } + } else { + return Err(InitError::NullFunctionPointer); + } + #(#stores)* + Ok(()) + } + }; + output.push_str(&prettyplease::unparse( + &syn::parse2(tokens).expect("could not parse quote output"), + )); + output.push('\n'); + } + + // Load all `#define sqlite3_xyz sqlite3_api->abc` in sqlite3ext.h + // as a map `{abc => sqlite3_xyz}` + // See https://github.com/rust-lang/rust-bindgen/issues/2544 + fn parse_macros(header: &str) -> HashMap { + use regex::Regex; + use std::fs::File; + use std::io::{BufRead, BufReader}; + let re = Regex::new(r"^#define\s+(sqlite3_\w+)\s+sqlite3_api->(\w+)").unwrap(); + let f = File::open(header).expect("could not read sqlite3ext.h"); + let f = BufReader::new(f); + let mut mappings = HashMap::new(); + for line in f.lines() { + let line = line.expect("could not read line"); + if let Some(caps) = re.captures(&line) { + mappings.insert( + caps.get(2).unwrap().as_str().to_owned(), + caps.get(1).unwrap().as_str().to_owned(), + ); + } + } + mappings + } + + fn extract_method(ty: &syn::Type) -> Option<&syn::TypeBareFn> { + match ty { + syn::Type::Path(tp) => tp.path.segments.last(), + _ => None, + } + .map(|seg| match &seg.arguments { + syn::PathArguments::AngleBracketed(args) => args.args.first(), + _ => None, + })? + .map(|arg| match arg { + syn::GenericArgument::Type(t) => Some(t), + _ => None, + })? + .map(|ty| match ty { + syn::Type::BareFn(r) => Some(r), + _ => None, + })? } } diff --git a/libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs b/libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs new file mode 100644 index 0000000..c0a371d --- /dev/null +++ b/libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs @@ -0,0 +1,7831 @@ +/* automatically generated by rust-bindgen 0.66.1 */ + +pub const SQLITE_VERSION: &[u8; 7] = b"3.42.0\0"; +pub const SQLITE_VERSION_NUMBER: i32 = 3042000; +pub const SQLITE_SOURCE_ID: &[u8; 85] = + b"2023-05-16 12:36:15 831d0fb2836b71c9bc51067c49fee4b8f18047814f2ff22d817d25195cf350b0\0"; +pub const SQLITE_OK: i32 = 0; +pub const SQLITE_ERROR: i32 = 1; +pub const SQLITE_INTERNAL: i32 = 2; +pub const SQLITE_PERM: i32 = 3; +pub const SQLITE_ABORT: i32 = 4; +pub const SQLITE_BUSY: i32 = 5; +pub const SQLITE_LOCKED: i32 = 6; +pub const SQLITE_NOMEM: i32 = 7; +pub const SQLITE_READONLY: i32 = 8; +pub const SQLITE_INTERRUPT: i32 = 9; +pub const SQLITE_IOERR: i32 = 10; +pub const SQLITE_CORRUPT: i32 = 11; +pub const SQLITE_NOTFOUND: i32 = 12; +pub const SQLITE_FULL: i32 = 13; +pub const SQLITE_CANTOPEN: i32 = 14; +pub const SQLITE_PROTOCOL: i32 = 15; +pub const SQLITE_EMPTY: i32 = 16; +pub const SQLITE_SCHEMA: i32 = 17; +pub const SQLITE_TOOBIG: i32 = 18; +pub const SQLITE_CONSTRAINT: i32 = 19; +pub const SQLITE_MISMATCH: i32 = 20; +pub const SQLITE_MISUSE: i32 = 21; +pub const SQLITE_NOLFS: i32 = 22; +pub const SQLITE_AUTH: i32 = 23; +pub const SQLITE_FORMAT: i32 = 24; +pub const SQLITE_RANGE: i32 = 25; +pub const SQLITE_NOTADB: i32 = 26; +pub const SQLITE_NOTICE: i32 = 27; +pub const SQLITE_WARNING: i32 = 28; +pub const SQLITE_ROW: i32 = 100; +pub const SQLITE_DONE: i32 = 101; +pub const SQLITE_ERROR_MISSING_COLLSEQ: i32 = 257; +pub const SQLITE_ERROR_RETRY: i32 = 513; +pub const SQLITE_ERROR_SNAPSHOT: i32 = 769; +pub const SQLITE_IOERR_READ: i32 = 266; +pub const SQLITE_IOERR_SHORT_READ: i32 = 522; +pub const SQLITE_IOERR_WRITE: i32 = 778; +pub const SQLITE_IOERR_FSYNC: i32 = 1034; +pub const SQLITE_IOERR_DIR_FSYNC: i32 = 1290; +pub const SQLITE_IOERR_TRUNCATE: i32 = 1546; +pub const SQLITE_IOERR_FSTAT: i32 = 1802; +pub const SQLITE_IOERR_UNLOCK: i32 = 2058; +pub const SQLITE_IOERR_RDLOCK: i32 = 2314; +pub const SQLITE_IOERR_DELETE: i32 = 2570; +pub const SQLITE_IOERR_BLOCKED: i32 = 2826; +pub const SQLITE_IOERR_NOMEM: i32 = 3082; +pub const SQLITE_IOERR_ACCESS: i32 = 3338; +pub const SQLITE_IOERR_CHECKRESERVEDLOCK: i32 = 3594; +pub const SQLITE_IOERR_LOCK: i32 = 3850; +pub const SQLITE_IOERR_CLOSE: i32 = 4106; +pub const SQLITE_IOERR_DIR_CLOSE: i32 = 4362; +pub const SQLITE_IOERR_SHMOPEN: i32 = 4618; +pub const SQLITE_IOERR_SHMSIZE: i32 = 4874; +pub const SQLITE_IOERR_SHMLOCK: i32 = 5130; +pub const SQLITE_IOERR_SHMMAP: i32 = 5386; +pub const SQLITE_IOERR_SEEK: i32 = 5642; +pub const SQLITE_IOERR_DELETE_NOENT: i32 = 5898; +pub const SQLITE_IOERR_MMAP: i32 = 6154; +pub const SQLITE_IOERR_GETTEMPPATH: i32 = 6410; +pub const SQLITE_IOERR_CONVPATH: i32 = 6666; +pub const SQLITE_IOERR_VNODE: i32 = 6922; +pub const SQLITE_IOERR_AUTH: i32 = 7178; +pub const SQLITE_IOERR_BEGIN_ATOMIC: i32 = 7434; +pub const SQLITE_IOERR_COMMIT_ATOMIC: i32 = 7690; +pub const SQLITE_IOERR_ROLLBACK_ATOMIC: i32 = 7946; +pub const SQLITE_IOERR_DATA: i32 = 8202; +pub const SQLITE_IOERR_CORRUPTFS: i32 = 8458; +pub const SQLITE_LOCKED_SHAREDCACHE: i32 = 262; +pub const SQLITE_LOCKED_VTAB: i32 = 518; +pub const SQLITE_BUSY_RECOVERY: i32 = 261; +pub const SQLITE_BUSY_SNAPSHOT: i32 = 517; +pub const SQLITE_BUSY_TIMEOUT: i32 = 773; +pub const SQLITE_CANTOPEN_NOTEMPDIR: i32 = 270; +pub const SQLITE_CANTOPEN_ISDIR: i32 = 526; +pub const SQLITE_CANTOPEN_FULLPATH: i32 = 782; +pub const SQLITE_CANTOPEN_CONVPATH: i32 = 1038; +pub const SQLITE_CANTOPEN_DIRTYWAL: i32 = 1294; +pub const SQLITE_CANTOPEN_SYMLINK: i32 = 1550; +pub const SQLITE_CORRUPT_VTAB: i32 = 267; +pub const SQLITE_CORRUPT_SEQUENCE: i32 = 523; +pub const SQLITE_CORRUPT_INDEX: i32 = 779; +pub const SQLITE_READONLY_RECOVERY: i32 = 264; +pub const SQLITE_READONLY_CANTLOCK: i32 = 520; +pub const SQLITE_READONLY_ROLLBACK: i32 = 776; +pub const SQLITE_READONLY_DBMOVED: i32 = 1032; +pub const SQLITE_READONLY_CANTINIT: i32 = 1288; +pub const SQLITE_READONLY_DIRECTORY: i32 = 1544; +pub const SQLITE_ABORT_ROLLBACK: i32 = 516; +pub const SQLITE_CONSTRAINT_CHECK: i32 = 275; +pub const SQLITE_CONSTRAINT_COMMITHOOK: i32 = 531; +pub const SQLITE_CONSTRAINT_FOREIGNKEY: i32 = 787; +pub const SQLITE_CONSTRAINT_FUNCTION: i32 = 1043; +pub const SQLITE_CONSTRAINT_NOTNULL: i32 = 1299; +pub const SQLITE_CONSTRAINT_PRIMARYKEY: i32 = 1555; +pub const SQLITE_CONSTRAINT_TRIGGER: i32 = 1811; +pub const SQLITE_CONSTRAINT_UNIQUE: i32 = 2067; +pub const SQLITE_CONSTRAINT_VTAB: i32 = 2323; +pub const SQLITE_CONSTRAINT_ROWID: i32 = 2579; +pub const SQLITE_CONSTRAINT_PINNED: i32 = 2835; +pub const SQLITE_CONSTRAINT_DATATYPE: i32 = 3091; +pub const SQLITE_NOTICE_RECOVER_WAL: i32 = 283; +pub const SQLITE_NOTICE_RECOVER_ROLLBACK: i32 = 539; +pub const SQLITE_NOTICE_RBU: i32 = 795; +pub const SQLITE_WARNING_AUTOINDEX: i32 = 284; +pub const SQLITE_AUTH_USER: i32 = 279; +pub const SQLITE_OK_LOAD_PERMANENTLY: i32 = 256; +pub const SQLITE_OK_SYMLINK: i32 = 512; +pub const SQLITE_OPEN_READONLY: i32 = 1; +pub const SQLITE_OPEN_READWRITE: i32 = 2; +pub const SQLITE_OPEN_CREATE: i32 = 4; +pub const SQLITE_OPEN_DELETEONCLOSE: i32 = 8; +pub const SQLITE_OPEN_EXCLUSIVE: i32 = 16; +pub const SQLITE_OPEN_AUTOPROXY: i32 = 32; +pub const SQLITE_OPEN_URI: i32 = 64; +pub const SQLITE_OPEN_MEMORY: i32 = 128; +pub const SQLITE_OPEN_MAIN_DB: i32 = 256; +pub const SQLITE_OPEN_TEMP_DB: i32 = 512; +pub const SQLITE_OPEN_TRANSIENT_DB: i32 = 1024; +pub const SQLITE_OPEN_MAIN_JOURNAL: i32 = 2048; +pub const SQLITE_OPEN_TEMP_JOURNAL: i32 = 4096; +pub const SQLITE_OPEN_SUBJOURNAL: i32 = 8192; +pub const SQLITE_OPEN_SUPER_JOURNAL: i32 = 16384; +pub const SQLITE_OPEN_NOMUTEX: i32 = 32768; +pub const SQLITE_OPEN_FULLMUTEX: i32 = 65536; +pub const SQLITE_OPEN_SHAREDCACHE: i32 = 131072; +pub const SQLITE_OPEN_PRIVATECACHE: i32 = 262144; +pub const SQLITE_OPEN_WAL: i32 = 524288; +pub const SQLITE_OPEN_NOFOLLOW: i32 = 16777216; +pub const SQLITE_OPEN_EXRESCODE: i32 = 33554432; +pub const SQLITE_OPEN_MASTER_JOURNAL: i32 = 16384; +pub const SQLITE_IOCAP_ATOMIC: i32 = 1; +pub const SQLITE_IOCAP_ATOMIC512: i32 = 2; +pub const SQLITE_IOCAP_ATOMIC1K: i32 = 4; +pub const SQLITE_IOCAP_ATOMIC2K: i32 = 8; +pub const SQLITE_IOCAP_ATOMIC4K: i32 = 16; +pub const SQLITE_IOCAP_ATOMIC8K: i32 = 32; +pub const SQLITE_IOCAP_ATOMIC16K: i32 = 64; +pub const SQLITE_IOCAP_ATOMIC32K: i32 = 128; +pub const SQLITE_IOCAP_ATOMIC64K: i32 = 256; +pub const SQLITE_IOCAP_SAFE_APPEND: i32 = 512; +pub const SQLITE_IOCAP_SEQUENTIAL: i32 = 1024; +pub const SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN: i32 = 2048; +pub const SQLITE_IOCAP_POWERSAFE_OVERWRITE: i32 = 4096; +pub const SQLITE_IOCAP_IMMUTABLE: i32 = 8192; +pub const SQLITE_IOCAP_BATCH_ATOMIC: i32 = 16384; +pub const SQLITE_LOCK_NONE: i32 = 0; +pub const SQLITE_LOCK_SHARED: i32 = 1; +pub const SQLITE_LOCK_RESERVED: i32 = 2; +pub const SQLITE_LOCK_PENDING: i32 = 3; +pub const SQLITE_LOCK_EXCLUSIVE: i32 = 4; +pub const SQLITE_SYNC_NORMAL: i32 = 2; +pub const SQLITE_SYNC_FULL: i32 = 3; +pub const SQLITE_SYNC_DATAONLY: i32 = 16; +pub const SQLITE_FCNTL_LOCKSTATE: i32 = 1; +pub const SQLITE_FCNTL_GET_LOCKPROXYFILE: i32 = 2; +pub const SQLITE_FCNTL_SET_LOCKPROXYFILE: i32 = 3; +pub const SQLITE_FCNTL_LAST_ERRNO: i32 = 4; +pub const SQLITE_FCNTL_SIZE_HINT: i32 = 5; +pub const SQLITE_FCNTL_CHUNK_SIZE: i32 = 6; +pub const SQLITE_FCNTL_FILE_POINTER: i32 = 7; +pub const SQLITE_FCNTL_SYNC_OMITTED: i32 = 8; +pub const SQLITE_FCNTL_WIN32_AV_RETRY: i32 = 9; +pub const SQLITE_FCNTL_PERSIST_WAL: i32 = 10; +pub const SQLITE_FCNTL_OVERWRITE: i32 = 11; +pub const SQLITE_FCNTL_VFSNAME: i32 = 12; +pub const SQLITE_FCNTL_POWERSAFE_OVERWRITE: i32 = 13; +pub const SQLITE_FCNTL_PRAGMA: i32 = 14; +pub const SQLITE_FCNTL_BUSYHANDLER: i32 = 15; +pub const SQLITE_FCNTL_TEMPFILENAME: i32 = 16; +pub const SQLITE_FCNTL_MMAP_SIZE: i32 = 18; +pub const SQLITE_FCNTL_TRACE: i32 = 19; +pub const SQLITE_FCNTL_HAS_MOVED: i32 = 20; +pub const SQLITE_FCNTL_SYNC: i32 = 21; +pub const SQLITE_FCNTL_COMMIT_PHASETWO: i32 = 22; +pub const SQLITE_FCNTL_WIN32_SET_HANDLE: i32 = 23; +pub const SQLITE_FCNTL_WAL_BLOCK: i32 = 24; +pub const SQLITE_FCNTL_ZIPVFS: i32 = 25; +pub const SQLITE_FCNTL_RBU: i32 = 26; +pub const SQLITE_FCNTL_VFS_POINTER: i32 = 27; +pub const SQLITE_FCNTL_JOURNAL_POINTER: i32 = 28; +pub const SQLITE_FCNTL_WIN32_GET_HANDLE: i32 = 29; +pub const SQLITE_FCNTL_PDB: i32 = 30; +pub const SQLITE_FCNTL_BEGIN_ATOMIC_WRITE: i32 = 31; +pub const SQLITE_FCNTL_COMMIT_ATOMIC_WRITE: i32 = 32; +pub const SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE: i32 = 33; +pub const SQLITE_FCNTL_LOCK_TIMEOUT: i32 = 34; +pub const SQLITE_FCNTL_DATA_VERSION: i32 = 35; +pub const SQLITE_FCNTL_SIZE_LIMIT: i32 = 36; +pub const SQLITE_FCNTL_CKPT_DONE: i32 = 37; +pub const SQLITE_FCNTL_RESERVE_BYTES: i32 = 38; +pub const SQLITE_FCNTL_CKPT_START: i32 = 39; +pub const SQLITE_FCNTL_EXTERNAL_READER: i32 = 40; +pub const SQLITE_FCNTL_CKSM_FILE: i32 = 41; +pub const SQLITE_FCNTL_RESET_CACHE: i32 = 42; +pub const SQLITE_GET_LOCKPROXYFILE: i32 = 2; +pub const SQLITE_SET_LOCKPROXYFILE: i32 = 3; +pub const SQLITE_LAST_ERRNO: i32 = 4; +pub const SQLITE_ACCESS_EXISTS: i32 = 0; +pub const SQLITE_ACCESS_READWRITE: i32 = 1; +pub const SQLITE_ACCESS_READ: i32 = 2; +pub const SQLITE_SHM_UNLOCK: i32 = 1; +pub const SQLITE_SHM_LOCK: i32 = 2; +pub const SQLITE_SHM_SHARED: i32 = 4; +pub const SQLITE_SHM_EXCLUSIVE: i32 = 8; +pub const SQLITE_SHM_NLOCK: i32 = 8; +pub const SQLITE_CONFIG_SINGLETHREAD: i32 = 1; +pub const SQLITE_CONFIG_MULTITHREAD: i32 = 2; +pub const SQLITE_CONFIG_SERIALIZED: i32 = 3; +pub const SQLITE_CONFIG_MALLOC: i32 = 4; +pub const SQLITE_CONFIG_GETMALLOC: i32 = 5; +pub const SQLITE_CONFIG_SCRATCH: i32 = 6; +pub const SQLITE_CONFIG_PAGECACHE: i32 = 7; +pub const SQLITE_CONFIG_HEAP: i32 = 8; +pub const SQLITE_CONFIG_MEMSTATUS: i32 = 9; +pub const SQLITE_CONFIG_MUTEX: i32 = 10; +pub const SQLITE_CONFIG_GETMUTEX: i32 = 11; +pub const SQLITE_CONFIG_LOOKASIDE: i32 = 13; +pub const SQLITE_CONFIG_PCACHE: i32 = 14; +pub const SQLITE_CONFIG_GETPCACHE: i32 = 15; +pub const SQLITE_CONFIG_LOG: i32 = 16; +pub const SQLITE_CONFIG_URI: i32 = 17; +pub const SQLITE_CONFIG_PCACHE2: i32 = 18; +pub const SQLITE_CONFIG_GETPCACHE2: i32 = 19; +pub const SQLITE_CONFIG_COVERING_INDEX_SCAN: i32 = 20; +pub const SQLITE_CONFIG_SQLLOG: i32 = 21; +pub const SQLITE_CONFIG_MMAP_SIZE: i32 = 22; +pub const SQLITE_CONFIG_WIN32_HEAPSIZE: i32 = 23; +pub const SQLITE_CONFIG_PCACHE_HDRSZ: i32 = 24; +pub const SQLITE_CONFIG_PMASZ: i32 = 25; +pub const SQLITE_CONFIG_STMTJRNL_SPILL: i32 = 26; +pub const SQLITE_CONFIG_SMALL_MALLOC: i32 = 27; +pub const SQLITE_CONFIG_SORTERREF_SIZE: i32 = 28; +pub const SQLITE_CONFIG_MEMDB_MAXSIZE: i32 = 29; +pub const SQLITE_DBCONFIG_MAINDBNAME: i32 = 1000; +pub const SQLITE_DBCONFIG_LOOKASIDE: i32 = 1001; +pub const SQLITE_DBCONFIG_ENABLE_FKEY: i32 = 1002; +pub const SQLITE_DBCONFIG_ENABLE_TRIGGER: i32 = 1003; +pub const SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER: i32 = 1004; +pub const SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION: i32 = 1005; +pub const SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE: i32 = 1006; +pub const SQLITE_DBCONFIG_ENABLE_QPSG: i32 = 1007; +pub const SQLITE_DBCONFIG_TRIGGER_EQP: i32 = 1008; +pub const SQLITE_DBCONFIG_RESET_DATABASE: i32 = 1009; +pub const SQLITE_DBCONFIG_DEFENSIVE: i32 = 1010; +pub const SQLITE_DBCONFIG_WRITABLE_SCHEMA: i32 = 1011; +pub const SQLITE_DBCONFIG_LEGACY_ALTER_TABLE: i32 = 1012; +pub const SQLITE_DBCONFIG_DQS_DML: i32 = 1013; +pub const SQLITE_DBCONFIG_DQS_DDL: i32 = 1014; +pub const SQLITE_DBCONFIG_ENABLE_VIEW: i32 = 1015; +pub const SQLITE_DBCONFIG_LEGACY_FILE_FORMAT: i32 = 1016; +pub const SQLITE_DBCONFIG_TRUSTED_SCHEMA: i32 = 1017; +pub const SQLITE_DBCONFIG_STMT_SCANSTATUS: i32 = 1018; +pub const SQLITE_DBCONFIG_REVERSE_SCANORDER: i32 = 1019; +pub const SQLITE_DBCONFIG_MAX: i32 = 1019; +pub const SQLITE_DENY: i32 = 1; +pub const SQLITE_IGNORE: i32 = 2; +pub const SQLITE_CREATE_INDEX: i32 = 1; +pub const SQLITE_CREATE_TABLE: i32 = 2; +pub const SQLITE_CREATE_TEMP_INDEX: i32 = 3; +pub const SQLITE_CREATE_TEMP_TABLE: i32 = 4; +pub const SQLITE_CREATE_TEMP_TRIGGER: i32 = 5; +pub const SQLITE_CREATE_TEMP_VIEW: i32 = 6; +pub const SQLITE_CREATE_TRIGGER: i32 = 7; +pub const SQLITE_CREATE_VIEW: i32 = 8; +pub const SQLITE_DELETE: i32 = 9; +pub const SQLITE_DROP_INDEX: i32 = 10; +pub const SQLITE_DROP_TABLE: i32 = 11; +pub const SQLITE_DROP_TEMP_INDEX: i32 = 12; +pub const SQLITE_DROP_TEMP_TABLE: i32 = 13; +pub const SQLITE_DROP_TEMP_TRIGGER: i32 = 14; +pub const SQLITE_DROP_TEMP_VIEW: i32 = 15; +pub const SQLITE_DROP_TRIGGER: i32 = 16; +pub const SQLITE_DROP_VIEW: i32 = 17; +pub const SQLITE_INSERT: i32 = 18; +pub const SQLITE_PRAGMA: i32 = 19; +pub const SQLITE_READ: i32 = 20; +pub const SQLITE_SELECT: i32 = 21; +pub const SQLITE_TRANSACTION: i32 = 22; +pub const SQLITE_UPDATE: i32 = 23; +pub const SQLITE_ATTACH: i32 = 24; +pub const SQLITE_DETACH: i32 = 25; +pub const SQLITE_ALTER_TABLE: i32 = 26; +pub const SQLITE_REINDEX: i32 = 27; +pub const SQLITE_ANALYZE: i32 = 28; +pub const SQLITE_CREATE_VTABLE: i32 = 29; +pub const SQLITE_DROP_VTABLE: i32 = 30; +pub const SQLITE_FUNCTION: i32 = 31; +pub const SQLITE_SAVEPOINT: i32 = 32; +pub const SQLITE_COPY: i32 = 0; +pub const SQLITE_RECURSIVE: i32 = 33; +pub const SQLITE_TRACE_STMT: i32 = 1; +pub const SQLITE_TRACE_PROFILE: i32 = 2; +pub const SQLITE_TRACE_ROW: i32 = 4; +pub const SQLITE_TRACE_CLOSE: i32 = 8; +pub const SQLITE_LIMIT_LENGTH: i32 = 0; +pub const SQLITE_LIMIT_SQL_LENGTH: i32 = 1; +pub const SQLITE_LIMIT_COLUMN: i32 = 2; +pub const SQLITE_LIMIT_EXPR_DEPTH: i32 = 3; +pub const SQLITE_LIMIT_COMPOUND_SELECT: i32 = 4; +pub const SQLITE_LIMIT_VDBE_OP: i32 = 5; +pub const SQLITE_LIMIT_FUNCTION_ARG: i32 = 6; +pub const SQLITE_LIMIT_ATTACHED: i32 = 7; +pub const SQLITE_LIMIT_LIKE_PATTERN_LENGTH: i32 = 8; +pub const SQLITE_LIMIT_VARIABLE_NUMBER: i32 = 9; +pub const SQLITE_LIMIT_TRIGGER_DEPTH: i32 = 10; +pub const SQLITE_LIMIT_WORKER_THREADS: i32 = 11; +pub const SQLITE_PREPARE_PERSISTENT: ::std::os::raw::c_uint = 1; +pub const SQLITE_PREPARE_NORMALIZE: ::std::os::raw::c_uint = 2; +pub const SQLITE_PREPARE_NO_VTAB: ::std::os::raw::c_uint = 4; +pub const SQLITE_INTEGER: i32 = 1; +pub const SQLITE_FLOAT: i32 = 2; +pub const SQLITE_BLOB: i32 = 4; +pub const SQLITE_NULL: i32 = 5; +pub const SQLITE_TEXT: i32 = 3; +pub const SQLITE3_TEXT: i32 = 3; +pub const SQLITE_UTF8: i32 = 1; +pub const SQLITE_UTF16LE: i32 = 2; +pub const SQLITE_UTF16BE: i32 = 3; +pub const SQLITE_UTF16: i32 = 4; +pub const SQLITE_ANY: i32 = 5; +pub const SQLITE_UTF16_ALIGNED: i32 = 8; +pub const SQLITE_DETERMINISTIC: i32 = 2048; +pub const SQLITE_DIRECTONLY: i32 = 524288; +pub const SQLITE_SUBTYPE: i32 = 1048576; +pub const SQLITE_INNOCUOUS: i32 = 2097152; +pub const SQLITE_WIN32_DATA_DIRECTORY_TYPE: i32 = 1; +pub const SQLITE_WIN32_TEMP_DIRECTORY_TYPE: i32 = 2; +pub const SQLITE_TXN_NONE: i32 = 0; +pub const SQLITE_TXN_READ: i32 = 1; +pub const SQLITE_TXN_WRITE: i32 = 2; +pub const SQLITE_INDEX_SCAN_UNIQUE: i32 = 1; +pub const SQLITE_INDEX_CONSTRAINT_EQ: i32 = 2; +pub const SQLITE_INDEX_CONSTRAINT_GT: i32 = 4; +pub const SQLITE_INDEX_CONSTRAINT_LE: i32 = 8; +pub const SQLITE_INDEX_CONSTRAINT_LT: i32 = 16; +pub const SQLITE_INDEX_CONSTRAINT_GE: i32 = 32; +pub const SQLITE_INDEX_CONSTRAINT_MATCH: i32 = 64; +pub const SQLITE_INDEX_CONSTRAINT_LIKE: i32 = 65; +pub const SQLITE_INDEX_CONSTRAINT_GLOB: i32 = 66; +pub const SQLITE_INDEX_CONSTRAINT_REGEXP: i32 = 67; +pub const SQLITE_INDEX_CONSTRAINT_NE: i32 = 68; +pub const SQLITE_INDEX_CONSTRAINT_ISNOT: i32 = 69; +pub const SQLITE_INDEX_CONSTRAINT_ISNOTNULL: i32 = 70; +pub const SQLITE_INDEX_CONSTRAINT_ISNULL: i32 = 71; +pub const SQLITE_INDEX_CONSTRAINT_IS: i32 = 72; +pub const SQLITE_INDEX_CONSTRAINT_LIMIT: i32 = 73; +pub const SQLITE_INDEX_CONSTRAINT_OFFSET: i32 = 74; +pub const SQLITE_INDEX_CONSTRAINT_FUNCTION: i32 = 150; +pub const SQLITE_MUTEX_FAST: i32 = 0; +pub const SQLITE_MUTEX_RECURSIVE: i32 = 1; +pub const SQLITE_MUTEX_STATIC_MAIN: i32 = 2; +pub const SQLITE_MUTEX_STATIC_MEM: i32 = 3; +pub const SQLITE_MUTEX_STATIC_MEM2: i32 = 4; +pub const SQLITE_MUTEX_STATIC_OPEN: i32 = 4; +pub const SQLITE_MUTEX_STATIC_PRNG: i32 = 5; +pub const SQLITE_MUTEX_STATIC_LRU: i32 = 6; +pub const SQLITE_MUTEX_STATIC_LRU2: i32 = 7; +pub const SQLITE_MUTEX_STATIC_PMEM: i32 = 7; +pub const SQLITE_MUTEX_STATIC_APP1: i32 = 8; +pub const SQLITE_MUTEX_STATIC_APP2: i32 = 9; +pub const SQLITE_MUTEX_STATIC_APP3: i32 = 10; +pub const SQLITE_MUTEX_STATIC_VFS1: i32 = 11; +pub const SQLITE_MUTEX_STATIC_VFS2: i32 = 12; +pub const SQLITE_MUTEX_STATIC_VFS3: i32 = 13; +pub const SQLITE_MUTEX_STATIC_MASTER: i32 = 2; +pub const SQLITE_TESTCTRL_FIRST: i32 = 5; +pub const SQLITE_TESTCTRL_PRNG_SAVE: i32 = 5; +pub const SQLITE_TESTCTRL_PRNG_RESTORE: i32 = 6; +pub const SQLITE_TESTCTRL_PRNG_RESET: i32 = 7; +pub const SQLITE_TESTCTRL_BITVEC_TEST: i32 = 8; +pub const SQLITE_TESTCTRL_FAULT_INSTALL: i32 = 9; +pub const SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS: i32 = 10; +pub const SQLITE_TESTCTRL_PENDING_BYTE: i32 = 11; +pub const SQLITE_TESTCTRL_ASSERT: i32 = 12; +pub const SQLITE_TESTCTRL_ALWAYS: i32 = 13; +pub const SQLITE_TESTCTRL_RESERVE: i32 = 14; +pub const SQLITE_TESTCTRL_OPTIMIZATIONS: i32 = 15; +pub const SQLITE_TESTCTRL_ISKEYWORD: i32 = 16; +pub const SQLITE_TESTCTRL_SCRATCHMALLOC: i32 = 17; +pub const SQLITE_TESTCTRL_INTERNAL_FUNCTIONS: i32 = 17; +pub const SQLITE_TESTCTRL_LOCALTIME_FAULT: i32 = 18; +pub const SQLITE_TESTCTRL_EXPLAIN_STMT: i32 = 19; +pub const SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD: i32 = 19; +pub const SQLITE_TESTCTRL_NEVER_CORRUPT: i32 = 20; +pub const SQLITE_TESTCTRL_VDBE_COVERAGE: i32 = 21; +pub const SQLITE_TESTCTRL_BYTEORDER: i32 = 22; +pub const SQLITE_TESTCTRL_ISINIT: i32 = 23; +pub const SQLITE_TESTCTRL_SORTER_MMAP: i32 = 24; +pub const SQLITE_TESTCTRL_IMPOSTER: i32 = 25; +pub const SQLITE_TESTCTRL_PARSER_COVERAGE: i32 = 26; +pub const SQLITE_TESTCTRL_RESULT_INTREAL: i32 = 27; +pub const SQLITE_TESTCTRL_PRNG_SEED: i32 = 28; +pub const SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS: i32 = 29; +pub const SQLITE_TESTCTRL_SEEK_COUNT: i32 = 30; +pub const SQLITE_TESTCTRL_TRACEFLAGS: i32 = 31; +pub const SQLITE_TESTCTRL_TUNE: i32 = 32; +pub const SQLITE_TESTCTRL_LOGEST: i32 = 33; +pub const SQLITE_TESTCTRL_LAST: i32 = 33; +pub const SQLITE_STATUS_MEMORY_USED: i32 = 0; +pub const SQLITE_STATUS_PAGECACHE_USED: i32 = 1; +pub const SQLITE_STATUS_PAGECACHE_OVERFLOW: i32 = 2; +pub const SQLITE_STATUS_SCRATCH_USED: i32 = 3; +pub const SQLITE_STATUS_SCRATCH_OVERFLOW: i32 = 4; +pub const SQLITE_STATUS_MALLOC_SIZE: i32 = 5; +pub const SQLITE_STATUS_PARSER_STACK: i32 = 6; +pub const SQLITE_STATUS_PAGECACHE_SIZE: i32 = 7; +pub const SQLITE_STATUS_SCRATCH_SIZE: i32 = 8; +pub const SQLITE_STATUS_MALLOC_COUNT: i32 = 9; +pub const SQLITE_DBSTATUS_LOOKASIDE_USED: i32 = 0; +pub const SQLITE_DBSTATUS_CACHE_USED: i32 = 1; +pub const SQLITE_DBSTATUS_SCHEMA_USED: i32 = 2; +pub const SQLITE_DBSTATUS_STMT_USED: i32 = 3; +pub const SQLITE_DBSTATUS_LOOKASIDE_HIT: i32 = 4; +pub const SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE: i32 = 5; +pub const SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL: i32 = 6; +pub const SQLITE_DBSTATUS_CACHE_HIT: i32 = 7; +pub const SQLITE_DBSTATUS_CACHE_MISS: i32 = 8; +pub const SQLITE_DBSTATUS_CACHE_WRITE: i32 = 9; +pub const SQLITE_DBSTATUS_DEFERRED_FKS: i32 = 10; +pub const SQLITE_DBSTATUS_CACHE_USED_SHARED: i32 = 11; +pub const SQLITE_DBSTATUS_CACHE_SPILL: i32 = 12; +pub const SQLITE_DBSTATUS_MAX: i32 = 12; +pub const SQLITE_STMTSTATUS_FULLSCAN_STEP: i32 = 1; +pub const SQLITE_STMTSTATUS_SORT: i32 = 2; +pub const SQLITE_STMTSTATUS_AUTOINDEX: i32 = 3; +pub const SQLITE_STMTSTATUS_VM_STEP: i32 = 4; +pub const SQLITE_STMTSTATUS_REPREPARE: i32 = 5; +pub const SQLITE_STMTSTATUS_RUN: i32 = 6; +pub const SQLITE_STMTSTATUS_FILTER_MISS: i32 = 7; +pub const SQLITE_STMTSTATUS_FILTER_HIT: i32 = 8; +pub const SQLITE_STMTSTATUS_MEMUSED: i32 = 99; +pub const SQLITE_CHECKPOINT_PASSIVE: i32 = 0; +pub const SQLITE_CHECKPOINT_FULL: i32 = 1; +pub const SQLITE_CHECKPOINT_RESTART: i32 = 2; +pub const SQLITE_CHECKPOINT_TRUNCATE: i32 = 3; +pub const SQLITE_VTAB_CONSTRAINT_SUPPORT: i32 = 1; +pub const SQLITE_VTAB_INNOCUOUS: i32 = 2; +pub const SQLITE_VTAB_DIRECTONLY: i32 = 3; +pub const SQLITE_VTAB_USES_ALL_SCHEMAS: i32 = 4; +pub const SQLITE_ROLLBACK: i32 = 1; +pub const SQLITE_FAIL: i32 = 3; +pub const SQLITE_REPLACE: i32 = 5; +pub const SQLITE_SCANSTAT_NLOOP: i32 = 0; +pub const SQLITE_SCANSTAT_NVISIT: i32 = 1; +pub const SQLITE_SCANSTAT_EST: i32 = 2; +pub const SQLITE_SCANSTAT_NAME: i32 = 3; +pub const SQLITE_SCANSTAT_EXPLAIN: i32 = 4; +pub const SQLITE_SCANSTAT_SELECTID: i32 = 5; +pub const SQLITE_SCANSTAT_PARENTID: i32 = 6; +pub const SQLITE_SCANSTAT_NCYCLE: i32 = 7; +pub const SQLITE_SCANSTAT_COMPLEX: i32 = 1; +pub const SQLITE_SERIALIZE_NOCOPY: ::std::os::raw::c_uint = 1; +pub const SQLITE_DESERIALIZE_FREEONCLOSE: ::std::os::raw::c_uint = 1; +pub const SQLITE_DESERIALIZE_RESIZEABLE: ::std::os::raw::c_uint = 2; +pub const SQLITE_DESERIALIZE_READONLY: ::std::os::raw::c_uint = 4; +pub const NOT_WITHIN: i32 = 0; +pub const PARTLY_WITHIN: i32 = 1; +pub const FULLY_WITHIN: i32 = 2; +pub const FTS5_TOKENIZE_QUERY: i32 = 1; +pub const FTS5_TOKENIZE_PREFIX: i32 = 2; +pub const FTS5_TOKENIZE_DOCUMENT: i32 = 4; +pub const FTS5_TOKENIZE_AUX: i32 = 8; +pub const FTS5_TOKEN_COLOCATED: i32 = 1; +extern "C" { + pub static sqlite3_version: [::std::os::raw::c_char; 0usize]; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3 { + _unused: [u8; 0], +} +pub type sqlite_int64 = ::std::os::raw::c_longlong; +pub type sqlite_uint64 = ::std::os::raw::c_ulonglong; +pub type sqlite3_int64 = sqlite_int64; +pub type sqlite3_uint64 = sqlite_uint64; +pub type sqlite3_callback = ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut ::std::os::raw::c_char, + arg4: *mut *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, +>; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_file { + pub pMethods: *const sqlite3_io_methods, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_io_methods { + pub iVersion: ::std::os::raw::c_int, + pub xClose: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_file) -> ::std::os::raw::c_int, + >, + pub xRead: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_file, + arg2: *mut ::std::os::raw::c_void, + iAmt: ::std::os::raw::c_int, + iOfst: sqlite3_int64, + ) -> ::std::os::raw::c_int, + >, + pub xWrite: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_file, + arg2: *const ::std::os::raw::c_void, + iAmt: ::std::os::raw::c_int, + iOfst: sqlite3_int64, + ) -> ::std::os::raw::c_int, + >, + pub xTruncate: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_file, size: sqlite3_int64) -> ::std::os::raw::c_int, + >, + pub xSync: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_file, + flags: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xFileSize: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_file, + pSize: *mut sqlite3_int64, + ) -> ::std::os::raw::c_int, + >, + pub xLock: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_file, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xUnlock: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_file, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xCheckReservedLock: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_file, + pResOut: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xFileControl: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_file, + op: ::std::os::raw::c_int, + pArg: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + pub xSectorSize: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_file) -> ::std::os::raw::c_int, + >, + pub xDeviceCharacteristics: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_file) -> ::std::os::raw::c_int, + >, + pub xShmMap: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_file, + iPg: ::std::os::raw::c_int, + pgsz: ::std::os::raw::c_int, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + pub xShmLock: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_file, + offset: ::std::os::raw::c_int, + n: ::std::os::raw::c_int, + flags: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xShmBarrier: ::std::option::Option, + pub xShmUnmap: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_file, + deleteFlag: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xFetch: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_file, + iOfst: sqlite3_int64, + iAmt: ::std::os::raw::c_int, + pp: *mut *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + pub xUnfetch: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_file, + iOfst: sqlite3_int64, + p: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_mutex { + _unused: [u8; 0], +} +pub type sqlite3_filename = *const ::std::os::raw::c_char; +pub type sqlite3_syscall_ptr = ::std::option::Option; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_vfs { + pub iVersion: ::std::os::raw::c_int, + pub szOsFile: ::std::os::raw::c_int, + pub mxPathname: ::std::os::raw::c_int, + pub pNext: *mut sqlite3_vfs, + pub zName: *const ::std::os::raw::c_char, + pub pAppData: *mut ::std::os::raw::c_void, + pub xOpen: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + zName: sqlite3_filename, + arg2: *mut sqlite3_file, + flags: ::std::os::raw::c_int, + pOutFlags: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xDelete: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + zName: *const ::std::os::raw::c_char, + syncDir: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xAccess: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + zName: *const ::std::os::raw::c_char, + flags: ::std::os::raw::c_int, + pResOut: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xFullPathname: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + zName: *const ::std::os::raw::c_char, + nOut: ::std::os::raw::c_int, + zOut: *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub xDlOpen: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + zFilename: *const ::std::os::raw::c_char, + ) -> *mut ::std::os::raw::c_void, + >, + pub xDlError: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + nByte: ::std::os::raw::c_int, + zErrMsg: *mut ::std::os::raw::c_char, + ), + >, + pub xDlSym: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + arg2: *mut ::std::os::raw::c_void, + zSymbol: *const ::std::os::raw::c_char, + ) -> ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + arg2: *mut ::std::os::raw::c_void, + zSymbol: *const ::std::os::raw::c_char, + ), + >, + >, + pub xDlClose: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_vfs, arg2: *mut ::std::os::raw::c_void), + >, + pub xRandomness: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + nByte: ::std::os::raw::c_int, + zOut: *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub xSleep: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + microseconds: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xCurrentTime: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_vfs, arg2: *mut f64) -> ::std::os::raw::c_int, + >, + pub xGetLastError: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + arg2: ::std::os::raw::c_int, + arg3: *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub xCurrentTimeInt64: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + arg2: *mut sqlite3_int64, + ) -> ::std::os::raw::c_int, + >, + pub xSetSystemCall: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + zName: *const ::std::os::raw::c_char, + arg2: sqlite3_syscall_ptr, + ) -> ::std::os::raw::c_int, + >, + pub xGetSystemCall: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + zName: *const ::std::os::raw::c_char, + ) -> sqlite3_syscall_ptr, + >, + pub xNextSystemCall: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + zName: *const ::std::os::raw::c_char, + ) -> *const ::std::os::raw::c_char, + >, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_mem_methods { + pub xMalloc: ::std::option::Option< + unsafe extern "C" fn(arg1: ::std::os::raw::c_int) -> *mut ::std::os::raw::c_void, + >, + pub xFree: ::std::option::Option, + pub xRealloc: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + ) -> *mut ::std::os::raw::c_void, + >, + pub xSize: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int, + >, + pub xRoundup: ::std::option::Option< + unsafe extern "C" fn(arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int, + >, + pub xInit: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int, + >, + pub xShutdown: ::std::option::Option, + pub pAppData: *mut ::std::os::raw::c_void, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_stmt { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_value { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_context { + _unused: [u8; 0], +} +pub type sqlite3_destructor_type = + ::std::option::Option; +extern "C" { + pub static mut sqlite3_temp_directory: *mut ::std::os::raw::c_char; +} +extern "C" { + pub static mut sqlite3_data_directory: *mut ::std::os::raw::c_char; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_module { + pub iVersion: ::std::os::raw::c_int, + pub xCreate: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + pAux: *mut ::std::os::raw::c_void, + argc: ::std::os::raw::c_int, + argv: *const *const ::std::os::raw::c_char, + ppVTab: *mut *mut sqlite3_vtab, + arg2: *mut *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub xConnect: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + pAux: *mut ::std::os::raw::c_void, + argc: ::std::os::raw::c_int, + argv: *const *const ::std::os::raw::c_char, + ppVTab: *mut *mut sqlite3_vtab, + arg2: *mut *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub xBestIndex: ::std::option::Option< + unsafe extern "C" fn( + pVTab: *mut sqlite3_vtab, + arg1: *mut sqlite3_index_info, + ) -> ::std::os::raw::c_int, + >, + pub xDisconnect: ::std::option::Option< + unsafe extern "C" fn(pVTab: *mut sqlite3_vtab) -> ::std::os::raw::c_int, + >, + pub xDestroy: ::std::option::Option< + unsafe extern "C" fn(pVTab: *mut sqlite3_vtab) -> ::std::os::raw::c_int, + >, + pub xOpen: ::std::option::Option< + unsafe extern "C" fn( + pVTab: *mut sqlite3_vtab, + ppCursor: *mut *mut sqlite3_vtab_cursor, + ) -> ::std::os::raw::c_int, + >, + pub xClose: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_vtab_cursor) -> ::std::os::raw::c_int, + >, + pub xFilter: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vtab_cursor, + idxNum: ::std::os::raw::c_int, + idxStr: *const ::std::os::raw::c_char, + argc: ::std::os::raw::c_int, + argv: *mut *mut sqlite3_value, + ) -> ::std::os::raw::c_int, + >, + pub xNext: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_vtab_cursor) -> ::std::os::raw::c_int, + >, + pub xEof: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_vtab_cursor) -> ::std::os::raw::c_int, + >, + pub xColumn: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vtab_cursor, + arg2: *mut sqlite3_context, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xRowid: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vtab_cursor, + pRowid: *mut sqlite3_int64, + ) -> ::std::os::raw::c_int, + >, + pub xUpdate: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vtab, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + arg4: *mut sqlite3_int64, + ) -> ::std::os::raw::c_int, + >, + pub xBegin: ::std::option::Option< + unsafe extern "C" fn(pVTab: *mut sqlite3_vtab) -> ::std::os::raw::c_int, + >, + pub xSync: ::std::option::Option< + unsafe extern "C" fn(pVTab: *mut sqlite3_vtab) -> ::std::os::raw::c_int, + >, + pub xCommit: ::std::option::Option< + unsafe extern "C" fn(pVTab: *mut sqlite3_vtab) -> ::std::os::raw::c_int, + >, + pub xRollback: ::std::option::Option< + unsafe extern "C" fn(pVTab: *mut sqlite3_vtab) -> ::std::os::raw::c_int, + >, + pub xFindFunction: ::std::option::Option< + unsafe extern "C" fn( + pVtab: *mut sqlite3_vtab, + nArg: ::std::os::raw::c_int, + zName: *const ::std::os::raw::c_char, + pxFunc: *mut ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + ppArg: *mut *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + pub xRename: ::std::option::Option< + unsafe extern "C" fn( + pVtab: *mut sqlite3_vtab, + zNew: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub xSavepoint: ::std::option::Option< + unsafe extern "C" fn( + pVTab: *mut sqlite3_vtab, + arg1: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xRelease: ::std::option::Option< + unsafe extern "C" fn( + pVTab: *mut sqlite3_vtab, + arg1: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xRollbackTo: ::std::option::Option< + unsafe extern "C" fn( + pVTab: *mut sqlite3_vtab, + arg1: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xShadowName: ::std::option::Option< + unsafe extern "C" fn(arg1: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int, + >, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_index_info { + pub nConstraint: ::std::os::raw::c_int, + pub aConstraint: *mut sqlite3_index_constraint, + pub nOrderBy: ::std::os::raw::c_int, + pub aOrderBy: *mut sqlite3_index_orderby, + pub aConstraintUsage: *mut sqlite3_index_constraint_usage, + pub idxNum: ::std::os::raw::c_int, + pub idxStr: *mut ::std::os::raw::c_char, + pub needToFreeIdxStr: ::std::os::raw::c_int, + pub orderByConsumed: ::std::os::raw::c_int, + pub estimatedCost: f64, + pub estimatedRows: sqlite3_int64, + pub idxFlags: ::std::os::raw::c_int, + pub colUsed: sqlite3_uint64, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_index_constraint { + pub iColumn: ::std::os::raw::c_int, + pub op: ::std::os::raw::c_uchar, + pub usable: ::std::os::raw::c_uchar, + pub iTermOffset: ::std::os::raw::c_int, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_index_orderby { + pub iColumn: ::std::os::raw::c_int, + pub desc: ::std::os::raw::c_uchar, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_index_constraint_usage { + pub argvIndex: ::std::os::raw::c_int, + pub omit: ::std::os::raw::c_uchar, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_vtab { + pub pModule: *const sqlite3_module, + pub nRef: ::std::os::raw::c_int, + pub zErrMsg: *mut ::std::os::raw::c_char, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_vtab_cursor { + pub pVtab: *mut sqlite3_vtab, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_blob { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_mutex_methods { + pub xMutexInit: ::std::option::Option ::std::os::raw::c_int>, + pub xMutexEnd: ::std::option::Option ::std::os::raw::c_int>, + pub xMutexAlloc: ::std::option::Option< + unsafe extern "C" fn(arg1: ::std::os::raw::c_int) -> *mut sqlite3_mutex, + >, + pub xMutexFree: ::std::option::Option, + pub xMutexEnter: ::std::option::Option, + pub xMutexTry: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_mutex) -> ::std::os::raw::c_int, + >, + pub xMutexLeave: ::std::option::Option, + pub xMutexHeld: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_mutex) -> ::std::os::raw::c_int, + >, + pub xMutexNotheld: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_mutex) -> ::std::os::raw::c_int, + >, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_str { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_pcache { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_pcache_page { + pub pBuf: *mut ::std::os::raw::c_void, + pub pExtra: *mut ::std::os::raw::c_void, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_pcache_methods2 { + pub iVersion: ::std::os::raw::c_int, + pub pArg: *mut ::std::os::raw::c_void, + pub xInit: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int, + >, + pub xShutdown: ::std::option::Option, + pub xCreate: ::std::option::Option< + unsafe extern "C" fn( + szPage: ::std::os::raw::c_int, + szExtra: ::std::os::raw::c_int, + bPurgeable: ::std::os::raw::c_int, + ) -> *mut sqlite3_pcache, + >, + pub xCachesize: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_pcache, nCachesize: ::std::os::raw::c_int), + >, + pub xPagecount: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_pcache) -> ::std::os::raw::c_int, + >, + pub xFetch: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_pcache, + key: ::std::os::raw::c_uint, + createFlag: ::std::os::raw::c_int, + ) -> *mut sqlite3_pcache_page, + >, + pub xUnpin: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_pcache, + arg2: *mut sqlite3_pcache_page, + discard: ::std::os::raw::c_int, + ), + >, + pub xRekey: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_pcache, + arg2: *mut sqlite3_pcache_page, + oldKey: ::std::os::raw::c_uint, + newKey: ::std::os::raw::c_uint, + ), + >, + pub xTruncate: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_pcache, iLimit: ::std::os::raw::c_uint), + >, + pub xDestroy: ::std::option::Option, + pub xShrink: ::std::option::Option, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_pcache_methods { + pub pArg: *mut ::std::os::raw::c_void, + pub xInit: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int, + >, + pub xShutdown: ::std::option::Option, + pub xCreate: ::std::option::Option< + unsafe extern "C" fn( + szPage: ::std::os::raw::c_int, + bPurgeable: ::std::os::raw::c_int, + ) -> *mut sqlite3_pcache, + >, + pub xCachesize: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_pcache, nCachesize: ::std::os::raw::c_int), + >, + pub xPagecount: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_pcache) -> ::std::os::raw::c_int, + >, + pub xFetch: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_pcache, + key: ::std::os::raw::c_uint, + createFlag: ::std::os::raw::c_int, + ) -> *mut ::std::os::raw::c_void, + >, + pub xUnpin: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_pcache, + arg2: *mut ::std::os::raw::c_void, + discard: ::std::os::raw::c_int, + ), + >, + pub xRekey: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_pcache, + arg2: *mut ::std::os::raw::c_void, + oldKey: ::std::os::raw::c_uint, + newKey: ::std::os::raw::c_uint, + ), + >, + pub xTruncate: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_pcache, iLimit: ::std::os::raw::c_uint), + >, + pub xDestroy: ::std::option::Option, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_backup { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_snapshot { + pub hidden: [::std::os::raw::c_uchar; 48usize], +} +pub type sqlite3_rtree_dbl = f64; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_rtree_geometry { + pub pContext: *mut ::std::os::raw::c_void, + pub nParam: ::std::os::raw::c_int, + pub aParam: *mut sqlite3_rtree_dbl, + pub pUser: *mut ::std::os::raw::c_void, + pub xDelUser: ::std::option::Option, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_rtree_query_info { + pub pContext: *mut ::std::os::raw::c_void, + pub nParam: ::std::os::raw::c_int, + pub aParam: *mut sqlite3_rtree_dbl, + pub pUser: *mut ::std::os::raw::c_void, + pub xDelUser: ::std::option::Option, + pub aCoord: *mut sqlite3_rtree_dbl, + pub anQueue: *mut ::std::os::raw::c_uint, + pub nCoord: ::std::os::raw::c_int, + pub iLevel: ::std::os::raw::c_int, + pub mxLevel: ::std::os::raw::c_int, + pub iRowid: sqlite3_int64, + pub rParentScore: sqlite3_rtree_dbl, + pub eParentWithin: ::std::os::raw::c_int, + pub eWithin: ::std::os::raw::c_int, + pub rScore: sqlite3_rtree_dbl, + pub apSqlParam: *mut *mut sqlite3_value, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Fts5Context { + _unused: [u8; 0], +} +pub type fts5_extension_function = ::std::option::Option< + unsafe extern "C" fn( + pApi: *const Fts5ExtensionApi, + pFts: *mut Fts5Context, + pCtx: *mut sqlite3_context, + nVal: ::std::os::raw::c_int, + apVal: *mut *mut sqlite3_value, + ), +>; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Fts5PhraseIter { + pub a: *const ::std::os::raw::c_uchar, + pub b: *const ::std::os::raw::c_uchar, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Fts5ExtensionApi { + pub iVersion: ::std::os::raw::c_int, + pub xUserData: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut Fts5Context) -> *mut ::std::os::raw::c_void, + >, + pub xColumnCount: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut Fts5Context) -> ::std::os::raw::c_int, + >, + pub xRowCount: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + pnRow: *mut sqlite3_int64, + ) -> ::std::os::raw::c_int, + >, + pub xColumnTotalSize: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + iCol: ::std::os::raw::c_int, + pnToken: *mut sqlite3_int64, + ) -> ::std::os::raw::c_int, + >, + pub xTokenize: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + pText: *const ::std::os::raw::c_char, + nText: ::std::os::raw::c_int, + pCtx: *mut ::std::os::raw::c_void, + xToken: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + arg4: ::std::os::raw::c_int, + arg5: ::std::os::raw::c_int, + arg6: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + ) -> ::std::os::raw::c_int, + >, + pub xPhraseCount: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut Fts5Context) -> ::std::os::raw::c_int, + >, + pub xPhraseSize: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + iPhrase: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xInstCount: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + pnInst: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xInst: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + iIdx: ::std::os::raw::c_int, + piPhrase: *mut ::std::os::raw::c_int, + piCol: *mut ::std::os::raw::c_int, + piOff: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xRowid: + ::std::option::Option sqlite3_int64>, + pub xColumnText: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + iCol: ::std::os::raw::c_int, + pz: *mut *const ::std::os::raw::c_char, + pn: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xColumnSize: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + iCol: ::std::os::raw::c_int, + pnToken: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xQueryPhrase: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + iPhrase: ::std::os::raw::c_int, + pUserData: *mut ::std::os::raw::c_void, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *const Fts5ExtensionApi, + arg2: *mut Fts5Context, + arg3: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + ) -> ::std::os::raw::c_int, + >, + pub xSetAuxdata: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + pAux: *mut ::std::os::raw::c_void, + xDelete: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, + pub xGetAuxdata: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + bClear: ::std::os::raw::c_int, + ) -> *mut ::std::os::raw::c_void, + >, + pub xPhraseFirst: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + iPhrase: ::std::os::raw::c_int, + arg2: *mut Fts5PhraseIter, + arg3: *mut ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xPhraseNext: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + arg2: *mut Fts5PhraseIter, + piCol: *mut ::std::os::raw::c_int, + piOff: *mut ::std::os::raw::c_int, + ), + >, + pub xPhraseFirstColumn: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + iPhrase: ::std::os::raw::c_int, + arg2: *mut Fts5PhraseIter, + arg3: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xPhraseNextColumn: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + arg2: *mut Fts5PhraseIter, + piCol: *mut ::std::os::raw::c_int, + ), + >, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Fts5Tokenizer { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct fts5_tokenizer { + pub xCreate: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + azArg: *mut *const ::std::os::raw::c_char, + nArg: ::std::os::raw::c_int, + ppOut: *mut *mut Fts5Tokenizer, + ) -> ::std::os::raw::c_int, + >, + pub xDelete: ::std::option::Option, + pub xTokenize: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Tokenizer, + pCtx: *mut ::std::os::raw::c_void, + flags: ::std::os::raw::c_int, + pText: *const ::std::os::raw::c_char, + nText: ::std::os::raw::c_int, + xToken: ::std::option::Option< + unsafe extern "C" fn( + pCtx: *mut ::std::os::raw::c_void, + tflags: ::std::os::raw::c_int, + pToken: *const ::std::os::raw::c_char, + nToken: ::std::os::raw::c_int, + iStart: ::std::os::raw::c_int, + iEnd: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + ) -> ::std::os::raw::c_int, + >, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct fts5_api { + pub iVersion: ::std::os::raw::c_int, + pub xCreateTokenizer: ::std::option::Option< + unsafe extern "C" fn( + pApi: *mut fts5_api, + zName: *const ::std::os::raw::c_char, + pContext: *mut ::std::os::raw::c_void, + pTokenizer: *mut fts5_tokenizer, + xDestroy: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, + pub xFindTokenizer: ::std::option::Option< + unsafe extern "C" fn( + pApi: *mut fts5_api, + zName: *const ::std::os::raw::c_char, + ppContext: *mut *mut ::std::os::raw::c_void, + pTokenizer: *mut fts5_tokenizer, + ) -> ::std::os::raw::c_int, + >, + pub xCreateFunction: ::std::option::Option< + unsafe extern "C" fn( + pApi: *mut fts5_api, + zName: *const ::std::os::raw::c_char, + pContext: *mut ::std::os::raw::c_void, + xFunction: fts5_extension_function, + xDestroy: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3_api_routines { + pub aggregate_context: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + nBytes: ::std::os::raw::c_int, + ) -> *mut ::std::os::raw::c_void, + >, + pub aggregate_count: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_context) -> ::std::os::raw::c_int, + >, + pub bind_blob: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + n: ::std::os::raw::c_int, + arg4: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, + pub bind_double: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: f64, + ) -> ::std::os::raw::c_int, + >, + pub bind_int: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub bind_int64: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: sqlite_int64, + ) -> ::std::os::raw::c_int, + >, + pub bind_null: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub bind_parameter_count: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int, + >, + pub bind_parameter_index: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + zName: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub bind_parameter_name: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, + pub bind_text: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + n: ::std::os::raw::c_int, + arg4: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, + pub bind_text16: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: ::std::os::raw::c_int, + arg5: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, + pub bind_value: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const sqlite3_value, + ) -> ::std::os::raw::c_int, + >, + pub busy_handler: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + pub busy_timeout: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + ms: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub changes: + ::std::option::Option ::std::os::raw::c_int>, + pub close: + ::std::option::Option ::std::os::raw::c_int>, + pub collation_needed: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *mut ::std::os::raw::c_void, + arg3: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut sqlite3, + eTextRep: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + ), + >, + ) -> ::std::os::raw::c_int, + >, + pub collation_needed16: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *mut ::std::os::raw::c_void, + arg3: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut sqlite3, + eTextRep: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + ), + >, + ) -> ::std::os::raw::c_int, + >, + pub column_blob: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void, + >, + pub column_bytes: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub column_bytes16: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub column_count: ::std::option::Option< + unsafe extern "C" fn(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int, + >, + pub column_database_name: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, + pub column_database_name16: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void, + >, + pub column_decltype: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + i: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, + pub column_decltype16: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void, + >, + pub column_double: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_stmt, iCol: ::std::os::raw::c_int) -> f64, + >, + pub column_int: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub column_int64: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_stmt, iCol: ::std::os::raw::c_int) -> sqlite_int64, + >, + pub column_name: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, + pub column_name16: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void, + >, + pub column_origin_name: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, + pub column_origin_name16: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void, + >, + pub column_table_name: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, + pub column_table_name16: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void, + >, + pub column_text: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_uchar, + >, + pub column_text16: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void, + >, + pub column_type: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub column_value: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> *mut sqlite3_value, + >, + pub commit_hook: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void, + >, + pub complete: ::std::option::Option< + unsafe extern "C" fn(sql: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int, + >, + pub complete16: ::std::option::Option< + unsafe extern "C" fn(sql: *const ::std::os::raw::c_void) -> ::std::os::raw::c_int, + >, + pub create_collation: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, + arg5: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: ::std::os::raw::c_int, + arg5: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + ) -> ::std::os::raw::c_int, + >, + pub create_collation16: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, + arg5: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: ::std::os::raw::c_int, + arg5: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + ) -> ::std::os::raw::c_int, + >, + pub create_function: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_void, + xFunc: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xStep: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xFinal: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, + pub create_function16: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_void, + xFunc: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xStep: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xFinal: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, + pub create_module: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const sqlite3_module, + arg4: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + pub data_count: ::std::option::Option< + unsafe extern "C" fn(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int, + >, + pub db_handle: + ::std::option::Option *mut sqlite3>, + pub declare_vtab: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub enable_shared_cache: ::std::option::Option< + unsafe extern "C" fn(arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int, + >, + pub errcode: + ::std::option::Option ::std::os::raw::c_int>, + pub errmsg: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3) -> *const ::std::os::raw::c_char, + >, + pub errmsg16: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3) -> *const ::std::os::raw::c_void, + >, + pub exec: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: sqlite3_callback, + arg4: *mut ::std::os::raw::c_void, + arg5: *mut *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub expired: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int, + >, + pub finalize: ::std::option::Option< + unsafe extern "C" fn(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int, + >, + pub free: ::std::option::Option, + pub free_table: + ::std::option::Option, + pub get_autocommit: + ::std::option::Option ::std::os::raw::c_int>, + pub get_auxdata: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + ) -> *mut ::std::os::raw::c_void, + >, + pub get_table: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *mut *mut *mut ::std::os::raw::c_char, + arg4: *mut ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_int, + arg6: *mut *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub global_recover: ::std::option::Option ::std::os::raw::c_int>, + pub interruptx: ::std::option::Option, + pub last_insert_rowid: + ::std::option::Option sqlite_int64>, + pub libversion: ::std::option::Option *const ::std::os::raw::c_char>, + pub libversion_number: ::std::option::Option ::std::os::raw::c_int>, + pub malloc: ::std::option::Option< + unsafe extern "C" fn(arg1: ::std::os::raw::c_int) -> *mut ::std::os::raw::c_void, + >, + pub mprintf: ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + ... + ) -> *mut ::std::os::raw::c_char, + >, + pub open: ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *mut *mut sqlite3, + ) -> ::std::os::raw::c_int, + >, + pub open16: ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_void, + arg2: *mut *mut sqlite3, + ) -> ::std::os::raw::c_int, + >, + pub prepare: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut *mut sqlite3_stmt, + arg5: *mut *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub prepare16: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: *mut *mut sqlite3_stmt, + arg5: *mut *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + pub profile: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *const ::std::os::raw::c_char, + arg3: sqlite_uint64, + ), + >, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void, + >, + pub progress_handler: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + arg3: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int, + >, + arg4: *mut ::std::os::raw::c_void, + ), + >, + pub realloc: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + ) -> *mut ::std::os::raw::c_void, + >, + pub reset: ::std::option::Option< + unsafe extern "C" fn(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int, + >, + pub result_blob: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option, + ), + >, + pub result_double: + ::std::option::Option, + pub result_error: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + ), + >, + pub result_error16: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + ), + >, + pub result_int: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_context, arg2: ::std::os::raw::c_int), + >, + pub result_int64: + ::std::option::Option, + pub result_null: ::std::option::Option, + pub result_text: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option, + ), + >, + pub result_text16: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option, + ), + >, + pub result_text16be: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option, + ), + >, + pub result_text16le: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option, + ), + >, + pub result_value: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_context, arg2: *mut sqlite3_value), + >, + pub rollback_hook: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void, + >, + pub set_authorizer: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + arg4: *const ::std::os::raw::c_char, + arg5: *const ::std::os::raw::c_char, + arg6: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + pub set_auxdata: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut ::std::os::raw::c_void, + arg4: ::std::option::Option, + ), + >, + pub xsnprintf: ::std::option::Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + arg2: *mut ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + ... + ) -> *mut ::std::os::raw::c_char, + >, + pub step: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int, + >, + pub table_column_metadata: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: *const ::std::os::raw::c_char, + arg5: *mut *const ::std::os::raw::c_char, + arg6: *mut *const ::std::os::raw::c_char, + arg7: *mut ::std::os::raw::c_int, + arg8: *mut ::std::os::raw::c_int, + arg9: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub thread_cleanup: ::std::option::Option, + pub total_changes: + ::std::option::Option ::std::os::raw::c_int>, + pub trace: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + xTrace: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *const ::std::os::raw::c_char, + ), + >, + arg2: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void, + >, + pub transfer_bindings: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: *mut sqlite3_stmt, + ) -> ::std::os::raw::c_int, + >, + pub update_hook: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + arg4: *const ::std::os::raw::c_char, + arg5: sqlite_int64, + ), + >, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void, + >, + pub user_data: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_context) -> *mut ::std::os::raw::c_void, + >, + pub value_blob: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> *const ::std::os::raw::c_void, + >, + pub value_bytes: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int, + >, + pub value_bytes16: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int, + >, + pub value_double: ::std::option::Option f64>, + pub value_int: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int, + >, + pub value_int64: + ::std::option::Option sqlite_int64>, + pub value_numeric_type: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int, + >, + pub value_text: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> *const ::std::os::raw::c_uchar, + >, + pub value_text16: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> *const ::std::os::raw::c_void, + >, + pub value_text16be: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> *const ::std::os::raw::c_void, + >, + pub value_text16le: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> *const ::std::os::raw::c_void, + >, + pub value_type: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int, + >, + pub vmprintf: ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_char, + >, + pub overload_function: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + zFuncName: *const ::std::os::raw::c_char, + nArg: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub prepare_v2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut *mut sqlite3_stmt, + arg5: *mut *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub prepare16_v2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: *mut *mut sqlite3_stmt, + arg5: *mut *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + pub clear_bindings: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int, + >, + pub create_module_v2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const sqlite3_module, + arg4: *mut ::std::os::raw::c_void, + xDestroy: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, + pub bind_zeroblob: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub blob_bytes: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_blob) -> ::std::os::raw::c_int, + >, + pub blob_close: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_blob) -> ::std::os::raw::c_int, + >, + pub blob_open: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: *const ::std::os::raw::c_char, + arg5: sqlite3_int64, + arg6: ::std::os::raw::c_int, + arg7: *mut *mut sqlite3_blob, + ) -> ::std::os::raw::c_int, + >, + pub blob_read: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_blob, + arg2: *mut ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub blob_write: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_blob, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub create_collation_v2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, + arg5: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: ::std::os::raw::c_int, + arg5: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + arg6: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, + pub file_control: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + pub memory_highwater: + ::std::option::Option sqlite3_int64>, + pub memory_used: ::std::option::Option sqlite3_int64>, + pub mutex_alloc: ::std::option::Option< + unsafe extern "C" fn(arg1: ::std::os::raw::c_int) -> *mut sqlite3_mutex, + >, + pub mutex_enter: ::std::option::Option, + pub mutex_free: ::std::option::Option, + pub mutex_leave: ::std::option::Option, + pub mutex_try: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_mutex) -> ::std::os::raw::c_int, + >, + pub open_v2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *mut *mut sqlite3, + arg3: ::std::os::raw::c_int, + arg4: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub release_memory: ::std::option::Option< + unsafe extern "C" fn(arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int, + >, + pub result_error_nomem: ::std::option::Option, + pub result_error_toobig: + ::std::option::Option, + pub sleep: ::std::option::Option< + unsafe extern "C" fn(arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int, + >, + pub soft_heap_limit: ::std::option::Option, + pub vfs_find: ::std::option::Option< + unsafe extern "C" fn(arg1: *const ::std::os::raw::c_char) -> *mut sqlite3_vfs, + >, + pub vfs_register: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub vfs_unregister: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_vfs) -> ::std::os::raw::c_int, + >, + pub xthreadsafe: ::std::option::Option ::std::os::raw::c_int>, + pub result_zeroblob: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_context, arg2: ::std::os::raw::c_int), + >, + pub result_error_code: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_context, arg2: ::std::os::raw::c_int), + >, + pub test_control: ::std::option::Option< + unsafe extern "C" fn(arg1: ::std::os::raw::c_int, ...) -> ::std::os::raw::c_int, + >, + pub randomness: ::std::option::Option< + unsafe extern "C" fn(arg1: ::std::os::raw::c_int, arg2: *mut ::std::os::raw::c_void), + >, + pub context_db_handle: + ::std::option::Option *mut sqlite3>, + pub extended_result_codes: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub limit: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub next_stmt: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3, arg2: *mut sqlite3_stmt) -> *mut sqlite3_stmt, + >, + pub sql: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> *const ::std::os::raw::c_char, + >, + pub status: ::std::option::Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + arg2: *mut ::std::os::raw::c_int, + arg3: *mut ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub backup_finish: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_backup) -> ::std::os::raw::c_int, + >, + pub backup_init: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *mut sqlite3, + arg4: *const ::std::os::raw::c_char, + ) -> *mut sqlite3_backup, + >, + pub backup_pagecount: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_backup) -> ::std::os::raw::c_int, + >, + pub backup_remaining: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_backup) -> ::std::os::raw::c_int, + >, + pub backup_step: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_backup, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub compileoption_get: ::std::option::Option< + unsafe extern "C" fn(arg1: ::std::os::raw::c_int) -> *const ::std::os::raw::c_char, + >, + pub compileoption_used: ::std::option::Option< + unsafe extern "C" fn(arg1: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int, + >, + pub create_function_v2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_void, + xFunc: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xStep: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xFinal: ::std::option::Option, + xDestroy: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, + pub db_config: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + ... + ) -> ::std::os::raw::c_int, + >, + pub db_mutex: + ::std::option::Option *mut sqlite3_mutex>, + pub db_status: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + arg3: *mut ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_int, + arg5: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub extended_errcode: + ::std::option::Option ::std::os::raw::c_int>, + pub log: ::std::option::Option< + unsafe extern "C" fn(arg1: ::std::os::raw::c_int, arg2: *const ::std::os::raw::c_char, ...), + >, + pub soft_heap_limit64: + ::std::option::Option sqlite3_int64>, + pub sourceid: ::std::option::Option *const ::std::os::raw::c_char>, + pub stmt_status: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub strnicmp: ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub unlock_notify: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + ), + >, + arg3: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + pub wal_autocheckpoint: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub wal_checkpoint: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub wal_hook: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut sqlite3, + arg3: *const ::std::os::raw::c_char, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void, + >, + pub blob_reopen: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_blob, arg2: sqlite3_int64) -> ::std::os::raw::c_int, + >, + pub vtab_config: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + op: ::std::os::raw::c_int, + ... + ) -> ::std::os::raw::c_int, + >, + pub vtab_on_conflict: + ::std::option::Option ::std::os::raw::c_int>, + pub close_v2: + ::std::option::Option ::std::os::raw::c_int>, + pub db_filename: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + ) -> *const ::std::os::raw::c_char, + >, + pub db_readonly: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub db_release_memory: + ::std::option::Option ::std::os::raw::c_int>, + pub errstr: ::std::option::Option< + unsafe extern "C" fn(arg1: ::std::os::raw::c_int) -> *const ::std::os::raw::c_char, + >, + pub stmt_busy: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int, + >, + pub stmt_readonly: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int, + >, + pub stricmp: ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub uri_boolean: ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub uri_int64: ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: sqlite3_int64, + ) -> sqlite3_int64, + >, + pub uri_parameter: ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + ) -> *const ::std::os::raw::c_char, + >, + pub xvsnprintf: ::std::option::Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + arg2: *mut ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_char, + >, + pub wal_checkpoint_v2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub auto_extension: ::std::option::Option< + unsafe extern "C" fn( + arg1: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, + pub bind_blob64: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: sqlite3_uint64, + arg5: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, + pub bind_text64: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + arg4: sqlite3_uint64, + arg5: ::std::option::Option, + arg6: ::std::os::raw::c_uchar, + ) -> ::std::os::raw::c_int, + >, + pub cancel_auto_extension: ::std::option::Option< + unsafe extern "C" fn( + arg1: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, + pub load_extension: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: *mut *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub malloc64: ::std::option::Option< + unsafe extern "C" fn(arg1: sqlite3_uint64) -> *mut ::std::os::raw::c_void, + >, + pub msize: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void) -> sqlite3_uint64, + >, + pub realloc64: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: sqlite3_uint64, + ) -> *mut ::std::os::raw::c_void, + >, + pub reset_auto_extension: ::std::option::Option, + pub result_blob64: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: sqlite3_uint64, + arg4: ::std::option::Option, + ), + >, + pub result_text64: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_char, + arg3: sqlite3_uint64, + arg4: ::std::option::Option, + arg5: ::std::os::raw::c_uchar, + ), + >, + pub strglob: ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub value_dup: ::std::option::Option< + unsafe extern "C" fn(arg1: *const sqlite3_value) -> *mut sqlite3_value, + >, + pub value_free: ::std::option::Option, + pub result_zeroblob64: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: sqlite3_uint64, + ) -> ::std::os::raw::c_int, + >, + pub bind_zeroblob64: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: sqlite3_uint64, + ) -> ::std::os::raw::c_int, + >, + pub value_subtype: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> ::std::os::raw::c_uint, + >, + pub result_subtype: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_context, arg2: ::std::os::raw::c_uint), + >, + pub status64: ::std::option::Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + arg2: *mut sqlite3_int64, + arg3: *mut sqlite3_int64, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub strlike: ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_uint, + ) -> ::std::os::raw::c_int, + >, + pub db_cacheflush: + ::std::option::Option ::std::os::raw::c_int>, + pub system_errno: + ::std::option::Option ::std::os::raw::c_int>, + pub trace_v2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_uint, + arg3: ::std::option::Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_uint, + arg2: *mut ::std::os::raw::c_void, + arg3: *mut ::std::os::raw::c_void, + arg4: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + arg4: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + pub expanded_sql: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> *mut ::std::os::raw::c_char, + >, + pub set_last_insert_rowid: + ::std::option::Option, + pub prepare_v3: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_uint, + arg5: *mut *mut sqlite3_stmt, + arg6: *mut *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub prepare16_v3: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_uint, + arg5: *mut *mut sqlite3_stmt, + arg6: *mut *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + pub bind_pointer: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *mut ::std::os::raw::c_void, + arg4: *const ::std::os::raw::c_char, + arg5: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, + pub result_pointer: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *mut ::std::os::raw::c_void, + arg3: *const ::std::os::raw::c_char, + arg4: ::std::option::Option, + ), + >, + pub value_pointer: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_value, + arg2: *const ::std::os::raw::c_char, + ) -> *mut ::std::os::raw::c_void, + >, + pub vtab_nochange: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_context) -> ::std::os::raw::c_int, + >, + pub value_nochange: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int, + >, + pub vtab_collation: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_index_info, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, + pub keyword_count: ::std::option::Option ::std::os::raw::c_int>, + pub keyword_name: ::std::option::Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + arg2: *mut *const ::std::os::raw::c_char, + arg3: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub keyword_check: ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub str_new: + ::std::option::Option *mut sqlite3_str>, + pub str_finish: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_str) -> *mut ::std::os::raw::c_char, + >, + pub str_appendf: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_str, zFormat: *const ::std::os::raw::c_char, ...), + >, + pub str_vappendf: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_str, + zFormat: *const ::std::os::raw::c_char, + arg2: *mut ::std::os::raw::c_void, + ), + >, + pub str_append: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_str, + zIn: *const ::std::os::raw::c_char, + N: ::std::os::raw::c_int, + ), + >, + pub str_appendall: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_str, zIn: *const ::std::os::raw::c_char), + >, + pub str_appendchar: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_str, + N: ::std::os::raw::c_int, + C: ::std::os::raw::c_char, + ), + >, + pub str_reset: ::std::option::Option, + pub str_errcode: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_str) -> ::std::os::raw::c_int, + >, + pub str_length: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_str) -> ::std::os::raw::c_int, + >, + pub str_value: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_str) -> *mut ::std::os::raw::c_char, + >, + pub create_window_function: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_void, + xStep: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xFinal: ::std::option::Option, + xValue: ::std::option::Option, + xInv: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xDestroy: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, + pub normalized_sql: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> *const ::std::os::raw::c_char, + >, + pub stmt_isexplain: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int, + >, + pub value_frombind: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int, + >, + pub drop_modules: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *mut *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub hard_heap_limit64: + ::std::option::Option sqlite3_int64>, + pub uri_key: ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, + pub filename_database: ::std::option::Option< + unsafe extern "C" fn(arg1: *const ::std::os::raw::c_char) -> *const ::std::os::raw::c_char, + >, + pub filename_journal: ::std::option::Option< + unsafe extern "C" fn(arg1: *const ::std::os::raw::c_char) -> *const ::std::os::raw::c_char, + >, + pub filename_wal: ::std::option::Option< + unsafe extern "C" fn(arg1: *const ::std::os::raw::c_char) -> *const ::std::os::raw::c_char, + >, + pub create_filename: ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: ::std::os::raw::c_int, + arg5: *mut *const ::std::os::raw::c_char, + ) -> *const ::std::os::raw::c_char, + >, + pub free_filename: + ::std::option::Option, + pub database_file_object: ::std::option::Option< + unsafe extern "C" fn(arg1: *const ::std::os::raw::c_char) -> *mut sqlite3_file, + >, + pub txn_state: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + pub changes64: ::std::option::Option sqlite3_int64>, + pub total_changes64: + ::std::option::Option sqlite3_int64>, + pub autovacuum_pages: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_uint, + arg4: ::std::os::raw::c_uint, + arg5: ::std::os::raw::c_uint, + ) -> ::std::os::raw::c_uint, + >, + arg3: *mut ::std::os::raw::c_void, + arg4: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, + pub error_offset: + ::std::option::Option ::std::os::raw::c_int>, + pub vtab_rhs_value: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_index_info, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ) -> ::std::os::raw::c_int, + >, + pub vtab_distinct: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_index_info) -> ::std::os::raw::c_int, + >, + pub vtab_in: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_index_info, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub vtab_in_first: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_value, + arg2: *mut *mut sqlite3_value, + ) -> ::std::os::raw::c_int, + >, + pub vtab_in_next: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_value, + arg2: *mut *mut sqlite3_value, + ) -> ::std::os::raw::c_int, + >, + pub deserialize: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *mut ::std::os::raw::c_uchar, + arg4: sqlite3_int64, + arg5: sqlite3_int64, + arg6: ::std::os::raw::c_uint, + ) -> ::std::os::raw::c_int, + >, + pub serialize: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *mut sqlite3_int64, + arg4: ::std::os::raw::c_uint, + ) -> *mut ::std::os::raw::c_uchar, + >, + pub db_name: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, + pub value_encoding: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int, + >, + pub is_interrupted: + ::std::option::Option ::std::os::raw::c_int>, +} +pub type sqlite3_loadext_entry = ::std::option::Option< + unsafe extern "C" fn( + db: *mut sqlite3, + pzErrMsg: *mut *mut ::std::os::raw::c_char, + pThunk: *const sqlite3_api_routines, + ) -> ::std::os::raw::c_int, +>; +static __SQLITE3_AGGREGATE_CONTEXT: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + nBytes: ::std::os::raw::c_int, + ) -> *mut ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_aggregate_context( + arg1: *mut sqlite3_context, + nBytes: ::std::os::raw::c_int, +) -> *mut ::std::os::raw::c_void { + let fun = __SQLITE3_AGGREGATE_CONTEXT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, nBytes) +} + +static __SQLITE3_AGGREGATE_COUNT: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_aggregate_count( + arg1: *mut sqlite3_context, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_AGGREGATE_COUNT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_BIND_BLOB: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + n: ::std::os::raw::c_int, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_bind_blob( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + n: ::std::os::raw::c_int, + arg4: ::std::option::Option, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BIND_BLOB + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, n, arg4) +} + +static __SQLITE3_BIND_DOUBLE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: f64, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_bind_double( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: f64, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BIND_DOUBLE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_BIND_INT: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_bind_int( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BIND_INT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_BIND_INT64: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: sqlite_int64, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_bind_int64( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: sqlite_int64, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BIND_INT64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_BIND_NULL: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_bind_null( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BIND_NULL + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_BIND_PARAMETER_COUNT: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_bind_parameter_count( + arg1: *mut sqlite3_stmt, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BIND_PARAMETER_COUNT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_BIND_PARAMETER_INDEX: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + zName: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_bind_parameter_index( + arg1: *mut sqlite3_stmt, + zName: *const ::std::os::raw::c_char, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BIND_PARAMETER_INDEX + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, zName) +} + +static __SQLITE3_BIND_PARAMETER_NAME: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_bind_parameter_name( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_BIND_PARAMETER_NAME + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_BIND_TEXT: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + n: ::std::os::raw::c_int, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_bind_text( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + n: ::std::os::raw::c_int, + arg4: ::std::option::Option, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BIND_TEXT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, n, arg4) +} + +static __SQLITE3_BIND_TEXT16: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: ::std::os::raw::c_int, + arg5: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_bind_text16( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: ::std::os::raw::c_int, + arg5: ::std::option::Option, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BIND_TEXT16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5) +} + +static __SQLITE3_BIND_VALUE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const sqlite3_value, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_bind_value( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const sqlite3_value, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BIND_VALUE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_BUSY_HANDLER: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_busy_handler( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BUSY_HANDLER + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_BUSY_TIMEOUT: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + ms: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_busy_timeout( + arg1: *mut sqlite3, + ms: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BUSY_TIMEOUT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, ms) +} + +static __SQLITE3_CHANGES: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_changes(arg1: *mut sqlite3) -> ::std::os::raw::c_int { + let fun = __SQLITE3_CHANGES + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_CLOSE: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_close(arg1: *mut sqlite3) -> ::std::os::raw::c_int { + let fun = __SQLITE3_CLOSE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_COLLATION_NEEDED: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *mut ::std::os::raw::c_void, + arg3: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut sqlite3, + eTextRep: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + ), + >, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_collation_needed( + arg1: *mut sqlite3, + arg2: *mut ::std::os::raw::c_void, + arg3: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut sqlite3, + eTextRep: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + ), + >, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_COLLATION_NEEDED + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_COLLATION_NEEDED16: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *mut ::std::os::raw::c_void, + arg3: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut sqlite3, + eTextRep: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + ), + >, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_collation_needed16( + arg1: *mut sqlite3, + arg2: *mut ::std::os::raw::c_void, + arg3: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut sqlite3, + eTextRep: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + ), + >, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_COLLATION_NEEDED16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_COLUMN_BLOB: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_blob( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_void { + let fun = __SQLITE3_COLUMN_BLOB + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, iCol) +} + +static __SQLITE3_COLUMN_BYTES: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_bytes( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_COLUMN_BYTES + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, iCol) +} + +static __SQLITE3_COLUMN_BYTES16: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_bytes16( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_COLUMN_BYTES16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, iCol) +} + +static __SQLITE3_COLUMN_COUNT: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_count(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int { + let fun = __SQLITE3_COLUMN_COUNT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(pStmt) +} + +static __SQLITE3_COLUMN_DATABASE_NAME: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_database_name( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_COLUMN_DATABASE_NAME + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_COLUMN_DATABASE_NAME16: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_database_name16( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_void { + let fun = __SQLITE3_COLUMN_DATABASE_NAME16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_COLUMN_DECLTYPE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + i: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_decltype( + arg1: *mut sqlite3_stmt, + i: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_COLUMN_DECLTYPE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, i) +} + +static __SQLITE3_COLUMN_DECLTYPE16: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_decltype16( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_void { + let fun = __SQLITE3_COLUMN_DECLTYPE16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_COLUMN_DOUBLE: ::atomic::Atomic< + Option< + unsafe extern "C" fn(arg1: *mut sqlite3_stmt, iCol: ::std::os::raw::c_int) -> f64, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_double( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, +) -> f64 { + let fun = __SQLITE3_COLUMN_DOUBLE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, iCol) +} + +static __SQLITE3_COLUMN_INT: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_int( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_COLUMN_INT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, iCol) +} + +static __SQLITE3_COLUMN_INT64: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> sqlite_int64, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_int64( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, +) -> sqlite_int64 { + let fun = __SQLITE3_COLUMN_INT64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, iCol) +} + +static __SQLITE3_COLUMN_NAME: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_name( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_COLUMN_NAME + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_COLUMN_NAME16: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_name16( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_void { + let fun = __SQLITE3_COLUMN_NAME16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_COLUMN_ORIGIN_NAME: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_origin_name( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_COLUMN_ORIGIN_NAME + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_COLUMN_ORIGIN_NAME16: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_origin_name16( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_void { + let fun = __SQLITE3_COLUMN_ORIGIN_NAME16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_COLUMN_TABLE_NAME: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_table_name( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_COLUMN_TABLE_NAME + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_COLUMN_TABLE_NAME16: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_table_name16( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_void { + let fun = __SQLITE3_COLUMN_TABLE_NAME16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_COLUMN_TEXT: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_uchar, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_text( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_uchar { + let fun = __SQLITE3_COLUMN_TEXT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, iCol) +} + +static __SQLITE3_COLUMN_TEXT16: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_text16( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_void { + let fun = __SQLITE3_COLUMN_TEXT16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, iCol) +} + +static __SQLITE3_COLUMN_TYPE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_type( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_COLUMN_TYPE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, iCol) +} + +static __SQLITE3_COLUMN_VALUE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> *mut sqlite3_value, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_column_value( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, +) -> *mut sqlite3_value { + let fun = __SQLITE3_COLUMN_VALUE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, iCol) +} + +static __SQLITE3_COMMIT_HOOK: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_commit_hook( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, +) -> *mut ::std::os::raw::c_void { + let fun = __SQLITE3_COMMIT_HOOK + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_COMPLETE: ::atomic::Atomic< + Option< + unsafe extern "C" fn(sql: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_complete( + sql: *const ::std::os::raw::c_char, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_COMPLETE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(sql) +} + +static __SQLITE3_COMPLETE16: ::atomic::Atomic< + Option< + unsafe extern "C" fn(sql: *const ::std::os::raw::c_void) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_complete16( + sql: *const ::std::os::raw::c_void, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_COMPLETE16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(sql) +} + +static __SQLITE3_CREATE_COLLATION: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, + arg5: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: ::std::os::raw::c_int, + arg5: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_create_collation( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, + arg5: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: ::std::os::raw::c_int, + arg5: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_CREATE_COLLATION + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5) +} + +static __SQLITE3_CREATE_COLLATION16: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, + arg5: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: ::std::os::raw::c_int, + arg5: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_create_collation16( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, + arg5: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: ::std::os::raw::c_int, + arg5: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_CREATE_COLLATION16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5) +} + +static __SQLITE3_CREATE_FUNCTION: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_void, + xFunc: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xStep: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xFinal: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_context), + >, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_create_function( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_void, + xFunc: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xStep: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xFinal: ::std::option::Option, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_CREATE_FUNCTION + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5, xFunc, xStep, xFinal) +} + +static __SQLITE3_CREATE_FUNCTION16: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_void, + xFunc: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xStep: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xFinal: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_context), + >, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_create_function16( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_void, + xFunc: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xStep: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xFinal: ::std::option::Option, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_CREATE_FUNCTION16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5, xFunc, xStep, xFinal) +} + +static __SQLITE3_CREATE_MODULE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const sqlite3_module, + arg4: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_create_module( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const sqlite3_module, + arg4: *mut ::std::os::raw::c_void, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_CREATE_MODULE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_DATA_COUNT: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_data_count(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int { + let fun = __SQLITE3_DATA_COUNT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(pStmt) +} + +static __SQLITE3_DB_HANDLE: ::atomic::Atomic< + Option *mut sqlite3>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_db_handle(arg1: *mut sqlite3_stmt) -> *mut sqlite3 { + let fun = __SQLITE3_DB_HANDLE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_DECLARE_VTAB: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_declare_vtab( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_DECLARE_VTAB + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_ENABLE_SHARED_CACHE: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_enable_shared_cache( + arg1: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_ENABLE_SHARED_CACHE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_ERRCODE: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_errcode(db: *mut sqlite3) -> ::std::os::raw::c_int { + let fun = __SQLITE3_ERRCODE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(db) +} + +static __SQLITE3_ERRMSG: ::atomic::Atomic< + Option *const ::std::os::raw::c_char>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_errmsg(arg1: *mut sqlite3) -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_ERRMSG + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_ERRMSG16: ::atomic::Atomic< + Option *const ::std::os::raw::c_void>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_errmsg16(arg1: *mut sqlite3) -> *const ::std::os::raw::c_void { + let fun = __SQLITE3_ERRMSG16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_EXEC: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: sqlite3_callback, + arg4: *mut ::std::os::raw::c_void, + arg5: *mut *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_exec( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: sqlite3_callback, + arg4: *mut ::std::os::raw::c_void, + arg5: *mut *mut ::std::os::raw::c_char, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_EXEC + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5) +} + +static __SQLITE3_EXPIRED: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_expired(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int { + let fun = __SQLITE3_EXPIRED + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_FINALIZE: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_finalize(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int { + let fun = __SQLITE3_FINALIZE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(pStmt) +} + +static __SQLITE3_FREE: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_free(arg1: *mut ::std::os::raw::c_void) { + let fun = __SQLITE3_FREE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_FREE_TABLE: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_free_table(result: *mut *mut ::std::os::raw::c_char) { + let fun = __SQLITE3_FREE_TABLE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(result) +} + +static __SQLITE3_GET_AUTOCOMMIT: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_get_autocommit(arg1: *mut sqlite3) -> ::std::os::raw::c_int { + let fun = __SQLITE3_GET_AUTOCOMMIT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_GET_AUXDATA: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + ) -> *mut ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_get_auxdata( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, +) -> *mut ::std::os::raw::c_void { + let fun = __SQLITE3_GET_AUXDATA + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_GET_TABLE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *mut *mut *mut ::std::os::raw::c_char, + arg4: *mut ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_int, + arg6: *mut *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_get_table( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *mut *mut *mut ::std::os::raw::c_char, + arg4: *mut ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_int, + arg6: *mut *mut ::std::os::raw::c_char, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_GET_TABLE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5, arg6) +} + +static __SQLITE3_GLOBAL_RECOVER: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_global_recover() -> ::std::os::raw::c_int { + let fun = __SQLITE3_GLOBAL_RECOVER + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)() +} + +static __SQLITE3_INTERRUPT: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_interrupt(arg1: *mut sqlite3) { + let fun = __SQLITE3_INTERRUPT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_LAST_INSERT_ROWID: ::atomic::Atomic< + Option sqlite_int64>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_last_insert_rowid(arg1: *mut sqlite3) -> sqlite_int64 { + let fun = __SQLITE3_LAST_INSERT_ROWID + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_LIBVERSION: ::atomic::Atomic< + Option *const ::std::os::raw::c_char>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_libversion() -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_LIBVERSION + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)() +} + +static __SQLITE3_LIBVERSION_NUMBER: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_libversion_number() -> ::std::os::raw::c_int { + let fun = __SQLITE3_LIBVERSION_NUMBER + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)() +} + +static __SQLITE3_MALLOC: ::atomic::Atomic< + Option< + unsafe extern "C" fn(arg1: ::std::os::raw::c_int) -> *mut ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_malloc( + arg1: ::std::os::raw::c_int, +) -> *mut ::std::os::raw::c_void { + let fun = __SQLITE3_MALLOC + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_OPEN: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *mut *mut sqlite3, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_open( + arg1: *const ::std::os::raw::c_char, + arg2: *mut *mut sqlite3, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_OPEN + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_OPEN16: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_void, + arg2: *mut *mut sqlite3, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_open16( + arg1: *const ::std::os::raw::c_void, + arg2: *mut *mut sqlite3, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_OPEN16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_PREPARE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut *mut sqlite3_stmt, + arg5: *mut *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_prepare( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut *mut sqlite3_stmt, + arg5: *mut *const ::std::os::raw::c_char, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_PREPARE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5) +} + +static __SQLITE3_PREPARE16: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: *mut *mut sqlite3_stmt, + arg5: *mut *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_prepare16( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: *mut *mut sqlite3_stmt, + arg5: *mut *const ::std::os::raw::c_void, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_PREPARE16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5) +} + +static __SQLITE3_PROFILE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *const ::std::os::raw::c_char, + arg3: sqlite_uint64, + ), + >, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_profile( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *const ::std::os::raw::c_char, + arg3: sqlite_uint64, + ), + >, + arg3: *mut ::std::os::raw::c_void, +) -> *mut ::std::os::raw::c_void { + let fun = __SQLITE3_PROFILE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_PROGRESS_HANDLER: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + arg3: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + arg4: *mut ::std::os::raw::c_void, + ), + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_progress_handler( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + arg3: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int, + >, + arg4: *mut ::std::os::raw::c_void, +) { + let fun = __SQLITE3_PROGRESS_HANDLER + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_REALLOC: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + ) -> *mut ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_realloc( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, +) -> *mut ::std::os::raw::c_void { + let fun = __SQLITE3_REALLOC + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_RESET: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_reset(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int { + let fun = __SQLITE3_RESET + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(pStmt) +} + +static __SQLITE3_RESULT_BLOB: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ), + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_blob( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option, +) { + let fun = __SQLITE3_RESULT_BLOB + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_RESULT_DOUBLE: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_double(arg1: *mut sqlite3_context, arg2: f64) { + let fun = __SQLITE3_RESULT_DOUBLE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_RESULT_ERROR: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + ), + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_error( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, +) { + let fun = __SQLITE3_RESULT_ERROR + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_RESULT_ERROR16: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + ), + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_error16( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, +) { + let fun = __SQLITE3_RESULT_ERROR16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_RESULT_INT: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_int( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, +) { + let fun = __SQLITE3_RESULT_INT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_RESULT_INT64: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_int64(arg1: *mut sqlite3_context, arg2: sqlite_int64) { + let fun = __SQLITE3_RESULT_INT64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_RESULT_NULL: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_null(arg1: *mut sqlite3_context) { + let fun = __SQLITE3_RESULT_NULL + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_RESULT_TEXT: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ), + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_text( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option, +) { + let fun = __SQLITE3_RESULT_TEXT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_RESULT_TEXT16: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ), + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_text16( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option, +) { + let fun = __SQLITE3_RESULT_TEXT16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_RESULT_TEXT16BE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ), + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_text16be( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option, +) { + let fun = __SQLITE3_RESULT_TEXT16BE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_RESULT_TEXT16LE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ), + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_text16le( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option, +) { + let fun = __SQLITE3_RESULT_TEXT16LE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_RESULT_VALUE: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_value( + arg1: *mut sqlite3_context, + arg2: *mut sqlite3_value, +) { + let fun = __SQLITE3_RESULT_VALUE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_ROLLBACK_HOOK: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_rollback_hook( + arg1: *mut sqlite3, + arg2: ::std::option::Option, + arg3: *mut ::std::os::raw::c_void, +) -> *mut ::std::os::raw::c_void { + let fun = __SQLITE3_ROLLBACK_HOOK + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_SET_AUTHORIZER: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + arg4: *const ::std::os::raw::c_char, + arg5: *const ::std::os::raw::c_char, + arg6: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_set_authorizer( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + arg4: *const ::std::os::raw::c_char, + arg5: *const ::std::os::raw::c_char, + arg6: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_SET_AUTHORIZER + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_SET_AUXDATA: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut ::std::os::raw::c_void, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ), + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_set_auxdata( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut ::std::os::raw::c_void, + arg4: ::std::option::Option, +) { + let fun = __SQLITE3_SET_AUXDATA + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_STEP: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_step(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int { + let fun = __SQLITE3_STEP + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_TABLE_COLUMN_METADATA: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: *const ::std::os::raw::c_char, + arg5: *mut *const ::std::os::raw::c_char, + arg6: *mut *const ::std::os::raw::c_char, + arg7: *mut ::std::os::raw::c_int, + arg8: *mut ::std::os::raw::c_int, + arg9: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_table_column_metadata( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: *const ::std::os::raw::c_char, + arg5: *mut *const ::std::os::raw::c_char, + arg6: *mut *const ::std::os::raw::c_char, + arg7: *mut ::std::os::raw::c_int, + arg8: *mut ::std::os::raw::c_int, + arg9: *mut ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_TABLE_COLUMN_METADATA + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) +} + +static __SQLITE3_THREAD_CLEANUP: ::atomic::Atomic> = ::atomic::Atomic::new( + None, +); +pub unsafe fn sqlite3_thread_cleanup() { + let fun = __SQLITE3_THREAD_CLEANUP + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)() +} + +static __SQLITE3_TOTAL_CHANGES: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_total_changes(arg1: *mut sqlite3) -> ::std::os::raw::c_int { + let fun = __SQLITE3_TOTAL_CHANGES + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_TRACE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + xTrace: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *const ::std::os::raw::c_char, + ), + >, + arg2: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_trace( + arg1: *mut sqlite3, + xTrace: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *const ::std::os::raw::c_char, + ), + >, + arg2: *mut ::std::os::raw::c_void, +) -> *mut ::std::os::raw::c_void { + let fun = __SQLITE3_TRACE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, xTrace, arg2) +} + +static __SQLITE3_TRANSFER_BINDINGS: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: *mut sqlite3_stmt, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_transfer_bindings( + arg1: *mut sqlite3_stmt, + arg2: *mut sqlite3_stmt, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_TRANSFER_BINDINGS + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_UPDATE_HOOK: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + arg4: *const ::std::os::raw::c_char, + arg5: sqlite_int64, + ), + >, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_update_hook( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + arg4: *const ::std::os::raw::c_char, + arg5: sqlite_int64, + ), + >, + arg3: *mut ::std::os::raw::c_void, +) -> *mut ::std::os::raw::c_void { + let fun = __SQLITE3_UPDATE_HOOK + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_USER_DATA: ::atomic::Atomic< + Option< + unsafe extern "C" fn(arg1: *mut sqlite3_context) -> *mut ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_user_data( + arg1: *mut sqlite3_context, +) -> *mut ::std::os::raw::c_void { + let fun = __SQLITE3_USER_DATA + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VALUE_BLOB: ::atomic::Atomic< + Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> *const ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_blob( + arg1: *mut sqlite3_value, +) -> *const ::std::os::raw::c_void { + let fun = __SQLITE3_VALUE_BLOB + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VALUE_BYTES: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_bytes(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int { + let fun = __SQLITE3_VALUE_BYTES + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VALUE_BYTES16: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_bytes16(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int { + let fun = __SQLITE3_VALUE_BYTES16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VALUE_DOUBLE: ::atomic::Atomic< + Option f64>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_double(arg1: *mut sqlite3_value) -> f64 { + let fun = __SQLITE3_VALUE_DOUBLE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VALUE_INT: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_int(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int { + let fun = __SQLITE3_VALUE_INT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VALUE_INT64: ::atomic::Atomic< + Option sqlite_int64>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_int64(arg1: *mut sqlite3_value) -> sqlite_int64 { + let fun = __SQLITE3_VALUE_INT64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VALUE_NUMERIC_TYPE: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_numeric_type( + arg1: *mut sqlite3_value, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_VALUE_NUMERIC_TYPE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VALUE_TEXT: ::atomic::Atomic< + Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> *const ::std::os::raw::c_uchar, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_text( + arg1: *mut sqlite3_value, +) -> *const ::std::os::raw::c_uchar { + let fun = __SQLITE3_VALUE_TEXT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VALUE_TEXT16: ::atomic::Atomic< + Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> *const ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_text16( + arg1: *mut sqlite3_value, +) -> *const ::std::os::raw::c_void { + let fun = __SQLITE3_VALUE_TEXT16 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VALUE_TEXT16BE: ::atomic::Atomic< + Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> *const ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_text16be( + arg1: *mut sqlite3_value, +) -> *const ::std::os::raw::c_void { + let fun = __SQLITE3_VALUE_TEXT16BE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VALUE_TEXT16LE: ::atomic::Atomic< + Option< + unsafe extern "C" fn(arg1: *mut sqlite3_value) -> *const ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_text16le( + arg1: *mut sqlite3_value, +) -> *const ::std::os::raw::c_void { + let fun = __SQLITE3_VALUE_TEXT16LE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VALUE_TYPE: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_type(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int { + let fun = __SQLITE3_VALUE_TYPE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_OVERLOAD_FUNCTION: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + zFuncName: *const ::std::os::raw::c_char, + nArg: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_overload_function( + arg1: *mut sqlite3, + zFuncName: *const ::std::os::raw::c_char, + nArg: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_OVERLOAD_FUNCTION + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, zFuncName, nArg) +} + +static __SQLITE3_PREPARE_V2: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut *mut sqlite3_stmt, + arg5: *mut *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_prepare_v2( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut *mut sqlite3_stmt, + arg5: *mut *const ::std::os::raw::c_char, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_PREPARE_V2 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5) +} + +static __SQLITE3_PREPARE16_V2: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: *mut *mut sqlite3_stmt, + arg5: *mut *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_prepare16_v2( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: *mut *mut sqlite3_stmt, + arg5: *mut *const ::std::os::raw::c_void, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_PREPARE16_V2 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5) +} + +static __SQLITE3_CLEAR_BINDINGS: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_clear_bindings(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int { + let fun = __SQLITE3_CLEAR_BINDINGS + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_CREATE_MODULE_V2: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const sqlite3_module, + arg4: *mut ::std::os::raw::c_void, + xDestroy: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_create_module_v2( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const sqlite3_module, + arg4: *mut ::std::os::raw::c_void, + xDestroy: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_CREATE_MODULE_V2 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, xDestroy) +} + +static __SQLITE3_BIND_ZEROBLOB: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_bind_zeroblob( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BIND_ZEROBLOB + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_BLOB_BYTES: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_blob_bytes(arg1: *mut sqlite3_blob) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BLOB_BYTES + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_BLOB_CLOSE: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_blob_close(arg1: *mut sqlite3_blob) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BLOB_CLOSE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_BLOB_OPEN: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: *const ::std::os::raw::c_char, + arg5: sqlite3_int64, + arg6: ::std::os::raw::c_int, + arg7: *mut *mut sqlite3_blob, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_blob_open( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: *const ::std::os::raw::c_char, + arg5: sqlite3_int64, + arg6: ::std::os::raw::c_int, + arg7: *mut *mut sqlite3_blob, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BLOB_OPEN + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5, arg6, arg7) +} + +static __SQLITE3_BLOB_READ: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_blob, + arg2: *mut ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_blob_read( + arg1: *mut sqlite3_blob, + arg2: *mut ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BLOB_READ + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_BLOB_WRITE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_blob, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_blob_write( + arg1: *mut sqlite3_blob, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BLOB_WRITE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_CREATE_COLLATION_V2: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, + arg5: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: ::std::os::raw::c_int, + arg5: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + arg6: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_create_collation_v2( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, + arg5: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: ::std::os::raw::c_int, + arg5: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + arg6: ::std::option::Option, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_CREATE_COLLATION_V2 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5, arg6) +} + +static __SQLITE3_FILE_CONTROL: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_file_control( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_FILE_CONTROL + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_MEMORY_HIGHWATER: ::atomic::Atomic< + Option sqlite3_int64>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_memory_highwater(arg1: ::std::os::raw::c_int) -> sqlite3_int64 { + let fun = __SQLITE3_MEMORY_HIGHWATER + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_MEMORY_USED: ::atomic::Atomic< + Option sqlite3_int64>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_memory_used() -> sqlite3_int64 { + let fun = __SQLITE3_MEMORY_USED + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)() +} + +static __SQLITE3_MUTEX_ALLOC: ::atomic::Atomic< + Option *mut sqlite3_mutex>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_mutex_alloc(arg1: ::std::os::raw::c_int) -> *mut sqlite3_mutex { + let fun = __SQLITE3_MUTEX_ALLOC + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_MUTEX_ENTER: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_mutex_enter(arg1: *mut sqlite3_mutex) { + let fun = __SQLITE3_MUTEX_ENTER + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_MUTEX_FREE: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_mutex_free(arg1: *mut sqlite3_mutex) { + let fun = __SQLITE3_MUTEX_FREE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_MUTEX_LEAVE: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_mutex_leave(arg1: *mut sqlite3_mutex) { + let fun = __SQLITE3_MUTEX_LEAVE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_MUTEX_TRY: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_mutex_try(arg1: *mut sqlite3_mutex) -> ::std::os::raw::c_int { + let fun = __SQLITE3_MUTEX_TRY + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_OPEN_V2: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *mut *mut sqlite3, + arg3: ::std::os::raw::c_int, + arg4: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_open_v2( + arg1: *const ::std::os::raw::c_char, + arg2: *mut *mut sqlite3, + arg3: ::std::os::raw::c_int, + arg4: *const ::std::os::raw::c_char, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_OPEN_V2 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_RELEASE_MEMORY: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_release_memory( + arg1: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_RELEASE_MEMORY + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_RESULT_ERROR_NOMEM: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_error_nomem(arg1: *mut sqlite3_context) { + let fun = __SQLITE3_RESULT_ERROR_NOMEM + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_RESULT_ERROR_TOOBIG: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_error_toobig(arg1: *mut sqlite3_context) { + let fun = __SQLITE3_RESULT_ERROR_TOOBIG + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_SLEEP: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_sleep(arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int { + let fun = __SQLITE3_SLEEP + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_SOFT_HEAP_LIMIT: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_soft_heap_limit(arg1: ::std::os::raw::c_int) { + let fun = __SQLITE3_SOFT_HEAP_LIMIT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VFS_FIND: ::atomic::Atomic< + Option *mut sqlite3_vfs>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_vfs_find(arg1: *const ::std::os::raw::c_char) -> *mut sqlite3_vfs { + let fun = __SQLITE3_VFS_FIND + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VFS_REGISTER: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_vfs_register( + arg1: *mut sqlite3_vfs, + arg2: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_VFS_REGISTER + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_VFS_UNREGISTER: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_vfs_unregister(arg1: *mut sqlite3_vfs) -> ::std::os::raw::c_int { + let fun = __SQLITE3_VFS_UNREGISTER + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_THREADSAFE: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_threadsafe() -> ::std::os::raw::c_int { + let fun = __SQLITE3_THREADSAFE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)() +} + +static __SQLITE3_RESULT_ZEROBLOB: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_zeroblob( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, +) { + let fun = __SQLITE3_RESULT_ZEROBLOB + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_RESULT_ERROR_CODE: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_error_code( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, +) { + let fun = __SQLITE3_RESULT_ERROR_CODE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_RANDOMNESS: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + arg2: *mut ::std::os::raw::c_void, + ), + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_randomness( + arg1: ::std::os::raw::c_int, + arg2: *mut ::std::os::raw::c_void, +) { + let fun = __SQLITE3_RANDOMNESS + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_CONTEXT_DB_HANDLE: ::atomic::Atomic< + Option *mut sqlite3>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_context_db_handle(arg1: *mut sqlite3_context) -> *mut sqlite3 { + let fun = __SQLITE3_CONTEXT_DB_HANDLE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_EXTENDED_RESULT_CODES: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_extended_result_codes( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_EXTENDED_RESULT_CODES + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_LIMIT: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_limit( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_LIMIT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_NEXT_STMT: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *mut sqlite3_stmt, + ) -> *mut sqlite3_stmt, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_next_stmt( + arg1: *mut sqlite3, + arg2: *mut sqlite3_stmt, +) -> *mut sqlite3_stmt { + let fun = __SQLITE3_NEXT_STMT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_SQL: ::atomic::Atomic< + Option< + unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> *const ::std::os::raw::c_char, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_sql(arg1: *mut sqlite3_stmt) -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_SQL + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_STATUS: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + arg2: *mut ::std::os::raw::c_int, + arg3: *mut ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_status( + arg1: ::std::os::raw::c_int, + arg2: *mut ::std::os::raw::c_int, + arg3: *mut ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_STATUS + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_BACKUP_FINISH: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_backup_finish(arg1: *mut sqlite3_backup) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BACKUP_FINISH + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_BACKUP_INIT: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *mut sqlite3, + arg4: *const ::std::os::raw::c_char, + ) -> *mut sqlite3_backup, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_backup_init( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *mut sqlite3, + arg4: *const ::std::os::raw::c_char, +) -> *mut sqlite3_backup { + let fun = __SQLITE3_BACKUP_INIT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_BACKUP_PAGECOUNT: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_backup_pagecount( + arg1: *mut sqlite3_backup, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BACKUP_PAGECOUNT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_BACKUP_REMAINING: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_backup_remaining( + arg1: *mut sqlite3_backup, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BACKUP_REMAINING + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_BACKUP_STEP: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_backup, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_backup_step( + arg1: *mut sqlite3_backup, + arg2: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BACKUP_STEP + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_COMPILEOPTION_GET: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_compileoption_get( + arg1: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_COMPILEOPTION_GET + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_COMPILEOPTION_USED: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_compileoption_used( + arg1: *const ::std::os::raw::c_char, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_COMPILEOPTION_USED + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_CREATE_FUNCTION_V2: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_void, + xFunc: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xStep: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xFinal: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_context), + >, + xDestroy: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_create_function_v2( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_void, + xFunc: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xStep: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xFinal: ::std::option::Option, + xDestroy: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_CREATE_FUNCTION_V2 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5, xFunc, xStep, xFinal, xDestroy) +} + +static __SQLITE3_DB_CONFIG: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + ... + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_db_config( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_DB_CONFIG + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_DB_MUTEX: ::atomic::Atomic< + Option *mut sqlite3_mutex>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_db_mutex(arg1: *mut sqlite3) -> *mut sqlite3_mutex { + let fun = __SQLITE3_DB_MUTEX + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_DB_STATUS: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + arg3: *mut ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_int, + arg5: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_db_status( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + arg3: *mut ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_int, + arg5: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_DB_STATUS + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5) +} + +static __SQLITE3_EXTENDED_ERRCODE: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_extended_errcode(arg1: *mut sqlite3) -> ::std::os::raw::c_int { + let fun = __SQLITE3_EXTENDED_ERRCODE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_LOG: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + arg2: *const ::std::os::raw::c_char, + ... + ), + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_log( + arg1: ::std::os::raw::c_int, + arg2: *const ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, +) { + let fun = __SQLITE3_LOG + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_SOFT_HEAP_LIMIT64: ::atomic::Atomic< + Option sqlite3_int64>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_soft_heap_limit64(arg1: sqlite3_int64) -> sqlite3_int64 { + let fun = __SQLITE3_SOFT_HEAP_LIMIT64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_SOURCEID: ::atomic::Atomic< + Option *const ::std::os::raw::c_char>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_sourceid() -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_SOURCEID + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)() +} + +static __SQLITE3_STMT_STATUS: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_stmt_status( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_STMT_STATUS + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_STRNICMP: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_strnicmp( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_STRNICMP + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_UNLOCK_NOTIFY: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + ), + >, + arg3: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_unlock_notify( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + ), + >, + arg3: *mut ::std::os::raw::c_void, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_UNLOCK_NOTIFY + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_WAL_AUTOCHECKPOINT: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_wal_autocheckpoint( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_WAL_AUTOCHECKPOINT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_WAL_CHECKPOINT: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_wal_checkpoint( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_WAL_CHECKPOINT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_WAL_HOOK: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut sqlite3, + arg3: *const ::std::os::raw::c_char, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_wal_hook( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut sqlite3, + arg3: *const ::std::os::raw::c_char, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, +) -> *mut ::std::os::raw::c_void { + let fun = __SQLITE3_WAL_HOOK + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_BLOB_REOPEN: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_blob, + arg2: sqlite3_int64, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_blob_reopen( + arg1: *mut sqlite3_blob, + arg2: sqlite3_int64, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BLOB_REOPEN + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_VTAB_CONFIG: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + op: ::std::os::raw::c_int, + ... + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_vtab_config( + arg1: *mut sqlite3, + op: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_VTAB_CONFIG + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, op) +} + +static __SQLITE3_VTAB_ON_CONFLICT: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_vtab_on_conflict(arg1: *mut sqlite3) -> ::std::os::raw::c_int { + let fun = __SQLITE3_VTAB_ON_CONFLICT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_CLOSE_V2: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_close_v2(arg1: *mut sqlite3) -> ::std::os::raw::c_int { + let fun = __SQLITE3_CLOSE_V2 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_DB_FILENAME: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + ) -> *const ::std::os::raw::c_char, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_db_filename( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, +) -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_DB_FILENAME + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_DB_READONLY: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_db_readonly( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_DB_READONLY + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_DB_RELEASE_MEMORY: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_db_release_memory(arg1: *mut sqlite3) -> ::std::os::raw::c_int { + let fun = __SQLITE3_DB_RELEASE_MEMORY + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_ERRSTR: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_errstr( + arg1: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_ERRSTR + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_STMT_BUSY: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_stmt_busy(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int { + let fun = __SQLITE3_STMT_BUSY + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_STMT_READONLY: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_stmt_readonly(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int { + let fun = __SQLITE3_STMT_READONLY + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_STRICMP: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_stricmp( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_STRICMP + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_URI_BOOLEAN: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_uri_boolean( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_URI_BOOLEAN + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_URI_INT64: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: sqlite3_int64, + ) -> sqlite3_int64, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_uri_int64( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: sqlite3_int64, +) -> sqlite3_int64 { + let fun = __SQLITE3_URI_INT64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_URI_PARAMETER: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + ) -> *const ::std::os::raw::c_char, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_uri_parameter( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, +) -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_URI_PARAMETER + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_WAL_CHECKPOINT_V2: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_wal_checkpoint_v2( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_WAL_CHECKPOINT_V2 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5) +} + +static __SQLITE3_AUTO_EXTENSION: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_auto_extension( + arg1: ::std::option::Option, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_AUTO_EXTENSION + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_BIND_BLOB64: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: sqlite3_uint64, + arg5: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_bind_blob64( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: sqlite3_uint64, + arg5: ::std::option::Option, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BIND_BLOB64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5) +} + +static __SQLITE3_BIND_TEXT64: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + arg4: sqlite3_uint64, + arg5: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + arg6: ::std::os::raw::c_uchar, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_bind_text64( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + arg4: sqlite3_uint64, + arg5: ::std::option::Option, + arg6: ::std::os::raw::c_uchar, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BIND_TEXT64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5, arg6) +} + +static __SQLITE3_CANCEL_AUTO_EXTENSION: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_cancel_auto_extension( + arg1: ::std::option::Option, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_CANCEL_AUTO_EXTENSION + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_LOAD_EXTENSION: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: *mut *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_load_extension( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: *mut *mut ::std::os::raw::c_char, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_LOAD_EXTENSION + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_MALLOC64: ::atomic::Atomic< + Option *mut ::std::os::raw::c_void>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_malloc64(arg1: sqlite3_uint64) -> *mut ::std::os::raw::c_void { + let fun = __SQLITE3_MALLOC64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_MSIZE: ::atomic::Atomic< + Option sqlite3_uint64>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_msize(arg1: *mut ::std::os::raw::c_void) -> sqlite3_uint64 { + let fun = __SQLITE3_MSIZE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_REALLOC64: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: sqlite3_uint64, + ) -> *mut ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_realloc64( + arg1: *mut ::std::os::raw::c_void, + arg2: sqlite3_uint64, +) -> *mut ::std::os::raw::c_void { + let fun = __SQLITE3_REALLOC64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_RESET_AUTO_EXTENSION: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_reset_auto_extension() { + let fun = __SQLITE3_RESET_AUTO_EXTENSION + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)() +} + +static __SQLITE3_RESULT_BLOB64: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: sqlite3_uint64, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ), + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_blob64( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: sqlite3_uint64, + arg4: ::std::option::Option, +) { + let fun = __SQLITE3_RESULT_BLOB64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_RESULT_TEXT64: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_char, + arg3: sqlite3_uint64, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + arg5: ::std::os::raw::c_uchar, + ), + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_text64( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_char, + arg3: sqlite3_uint64, + arg4: ::std::option::Option, + arg5: ::std::os::raw::c_uchar, +) { + let fun = __SQLITE3_RESULT_TEXT64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5) +} + +static __SQLITE3_STRGLOB: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_strglob( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_STRGLOB + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_VALUE_DUP: ::atomic::Atomic< + Option *mut sqlite3_value>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_dup(arg1: *const sqlite3_value) -> *mut sqlite3_value { + let fun = __SQLITE3_VALUE_DUP + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VALUE_FREE: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_free(arg1: *mut sqlite3_value) { + let fun = __SQLITE3_VALUE_FREE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_RESULT_ZEROBLOB64: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: sqlite3_uint64, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_zeroblob64( + arg1: *mut sqlite3_context, + arg2: sqlite3_uint64, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_RESULT_ZEROBLOB64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_BIND_ZEROBLOB64: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: sqlite3_uint64, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_bind_zeroblob64( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: sqlite3_uint64, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BIND_ZEROBLOB64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_VALUE_SUBTYPE: ::atomic::Atomic< + Option ::std::os::raw::c_uint>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_subtype(arg1: *mut sqlite3_value) -> ::std::os::raw::c_uint { + let fun = __SQLITE3_VALUE_SUBTYPE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_RESULT_SUBTYPE: ::atomic::Atomic< + Option< + unsafe extern "C" fn(arg1: *mut sqlite3_context, arg2: ::std::os::raw::c_uint), + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_subtype( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_uint, +) { + let fun = __SQLITE3_RESULT_SUBTYPE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_STATUS64: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + arg2: *mut sqlite3_int64, + arg3: *mut sqlite3_int64, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_status64( + arg1: ::std::os::raw::c_int, + arg2: *mut sqlite3_int64, + arg3: *mut sqlite3_int64, + arg4: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_STATUS64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_STRLIKE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_uint, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_strlike( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_uint, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_STRLIKE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_DB_CACHEFLUSH: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_db_cacheflush(arg1: *mut sqlite3) -> ::std::os::raw::c_int { + let fun = __SQLITE3_DB_CACHEFLUSH + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_SYSTEM_ERRNO: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_system_errno(arg1: *mut sqlite3) -> ::std::os::raw::c_int { + let fun = __SQLITE3_SYSTEM_ERRNO + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_TRACE_V2: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_uint, + arg3: ::std::option::Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_uint, + arg2: *mut ::std::os::raw::c_void, + arg3: *mut ::std::os::raw::c_void, + arg4: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + arg4: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_trace_v2( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_uint, + arg3: ::std::option::Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_uint, + arg2: *mut ::std::os::raw::c_void, + arg3: *mut ::std::os::raw::c_void, + arg4: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + arg4: *mut ::std::os::raw::c_void, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_TRACE_V2 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_EXPANDED_SQL: ::atomic::Atomic< + Option *mut ::std::os::raw::c_char>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_expanded_sql( + arg1: *mut sqlite3_stmt, +) -> *mut ::std::os::raw::c_char { + let fun = __SQLITE3_EXPANDED_SQL + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_SET_LAST_INSERT_ROWID: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_set_last_insert_rowid(arg1: *mut sqlite3, arg2: sqlite3_int64) { + let fun = __SQLITE3_SET_LAST_INSERT_ROWID + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_PREPARE_V3: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_uint, + arg5: *mut *mut sqlite3_stmt, + arg6: *mut *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_prepare_v3( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_uint, + arg5: *mut *mut sqlite3_stmt, + arg6: *mut *const ::std::os::raw::c_char, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_PREPARE_V3 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5, arg6) +} + +static __SQLITE3_PREPARE16_V3: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_uint, + arg5: *mut *mut sqlite3_stmt, + arg6: *mut *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_prepare16_v3( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_uint, + arg5: *mut *mut sqlite3_stmt, + arg6: *mut *const ::std::os::raw::c_void, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_PREPARE16_V3 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5, arg6) +} + +static __SQLITE3_BIND_POINTER: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *mut ::std::os::raw::c_void, + arg4: *const ::std::os::raw::c_char, + arg5: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_bind_pointer( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *mut ::std::os::raw::c_void, + arg4: *const ::std::os::raw::c_char, + arg5: ::std::option::Option, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_BIND_POINTER + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5) +} + +static __SQLITE3_RESULT_POINTER: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *mut ::std::os::raw::c_void, + arg3: *const ::std::os::raw::c_char, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ), + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_result_pointer( + arg1: *mut sqlite3_context, + arg2: *mut ::std::os::raw::c_void, + arg3: *const ::std::os::raw::c_char, + arg4: ::std::option::Option, +) { + let fun = __SQLITE3_RESULT_POINTER + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_VALUE_POINTER: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_value, + arg2: *const ::std::os::raw::c_char, + ) -> *mut ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_pointer( + arg1: *mut sqlite3_value, + arg2: *const ::std::os::raw::c_char, +) -> *mut ::std::os::raw::c_void { + let fun = __SQLITE3_VALUE_POINTER + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_VTAB_NOCHANGE: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_vtab_nochange( + arg1: *mut sqlite3_context, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_VTAB_NOCHANGE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VALUE_NOCHANGE: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_nochange(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int { + let fun = __SQLITE3_VALUE_NOCHANGE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VTAB_COLLATION: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_index_info, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_vtab_collation( + arg1: *mut sqlite3_index_info, + arg2: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_VTAB_COLLATION + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_KEYWORD_COUNT: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_keyword_count() -> ::std::os::raw::c_int { + let fun = __SQLITE3_KEYWORD_COUNT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)() +} + +static __SQLITE3_KEYWORD_NAME: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + arg2: *mut *const ::std::os::raw::c_char, + arg3: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_keyword_name( + arg1: ::std::os::raw::c_int, + arg2: *mut *const ::std::os::raw::c_char, + arg3: *mut ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_KEYWORD_NAME + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_KEYWORD_CHECK: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_keyword_check( + arg1: *const ::std::os::raw::c_char, + arg2: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_KEYWORD_CHECK + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_STR_NEW: ::atomic::Atomic< + Option *mut sqlite3_str>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_str_new(arg1: *mut sqlite3) -> *mut sqlite3_str { + let fun = __SQLITE3_STR_NEW + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_STR_FINISH: ::atomic::Atomic< + Option *mut ::std::os::raw::c_char>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_str_finish(arg1: *mut sqlite3_str) -> *mut ::std::os::raw::c_char { + let fun = __SQLITE3_STR_FINISH + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_STR_APPEND: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_str, + zIn: *const ::std::os::raw::c_char, + N: ::std::os::raw::c_int, + ), + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_str_append( + arg1: *mut sqlite3_str, + zIn: *const ::std::os::raw::c_char, + N: ::std::os::raw::c_int, +) { + let fun = __SQLITE3_STR_APPEND + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, zIn, N) +} + +static __SQLITE3_STR_APPENDALL: ::atomic::Atomic< + Option< + unsafe extern "C" fn(arg1: *mut sqlite3_str, zIn: *const ::std::os::raw::c_char), + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_str_appendall( + arg1: *mut sqlite3_str, + zIn: *const ::std::os::raw::c_char, +) { + let fun = __SQLITE3_STR_APPENDALL + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, zIn) +} + +static __SQLITE3_STR_APPENDCHAR: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_str, + N: ::std::os::raw::c_int, + C: ::std::os::raw::c_char, + ), + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_str_appendchar( + arg1: *mut sqlite3_str, + N: ::std::os::raw::c_int, + C: ::std::os::raw::c_char, +) { + let fun = __SQLITE3_STR_APPENDCHAR + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, N, C) +} + +static __SQLITE3_STR_RESET: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_str_reset(arg1: *mut sqlite3_str) { + let fun = __SQLITE3_STR_RESET + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_STR_ERRCODE: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_str_errcode(arg1: *mut sqlite3_str) -> ::std::os::raw::c_int { + let fun = __SQLITE3_STR_ERRCODE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_STR_LENGTH: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_str_length(arg1: *mut sqlite3_str) -> ::std::os::raw::c_int { + let fun = __SQLITE3_STR_LENGTH + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_STR_VALUE: ::atomic::Atomic< + Option *mut ::std::os::raw::c_char>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_str_value(arg1: *mut sqlite3_str) -> *mut ::std::os::raw::c_char { + let fun = __SQLITE3_STR_VALUE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_CREATE_WINDOW_FUNCTION: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_void, + xStep: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xFinal: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_context), + >, + xValue: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut sqlite3_context), + >, + xInv: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xDestroy: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_create_window_function( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_void, + xStep: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xFinal: ::std::option::Option, + xValue: ::std::option::Option, + xInv: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xDestroy: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_CREATE_WINDOW_FUNCTION + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5, xStep, xFinal, xValue, xInv, xDestroy) +} + +static __SQLITE3_NORMALIZED_SQL: ::atomic::Atomic< + Option< + unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> *const ::std::os::raw::c_char, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_normalized_sql( + arg1: *mut sqlite3_stmt, +) -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_NORMALIZED_SQL + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_STMT_ISEXPLAIN: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_stmt_isexplain(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int { + let fun = __SQLITE3_STMT_ISEXPLAIN + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VALUE_FROMBIND: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_frombind(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int { + let fun = __SQLITE3_VALUE_FROMBIND + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_DROP_MODULES: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *mut *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_drop_modules( + arg1: *mut sqlite3, + arg2: *mut *const ::std::os::raw::c_char, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_DROP_MODULES + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_HARD_HEAP_LIMIT64: ::atomic::Atomic< + Option sqlite3_int64>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_hard_heap_limit64(arg1: sqlite3_int64) -> sqlite3_int64 { + let fun = __SQLITE3_HARD_HEAP_LIMIT64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_URI_KEY: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_uri_key( + arg1: *const ::std::os::raw::c_char, + arg2: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_URI_KEY + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_FILENAME_DATABASE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + ) -> *const ::std::os::raw::c_char, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_filename_database( + arg1: *const ::std::os::raw::c_char, +) -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_FILENAME_DATABASE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_FILENAME_JOURNAL: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + ) -> *const ::std::os::raw::c_char, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_filename_journal( + arg1: *const ::std::os::raw::c_char, +) -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_FILENAME_JOURNAL + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_FILENAME_WAL: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + ) -> *const ::std::os::raw::c_char, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_filename_wal( + arg1: *const ::std::os::raw::c_char, +) -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_FILENAME_WAL + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_CREATE_FILENAME: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: ::std::os::raw::c_int, + arg5: *mut *const ::std::os::raw::c_char, + ) -> *const ::std::os::raw::c_char, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_create_filename( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: ::std::os::raw::c_int, + arg5: *mut *const ::std::os::raw::c_char, +) -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_CREATE_FILENAME + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5) +} + +static __SQLITE3_FREE_FILENAME: ::atomic::Atomic< + Option, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_free_filename(arg1: *const ::std::os::raw::c_char) { + let fun = __SQLITE3_FREE_FILENAME + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_DATABASE_FILE_OBJECT: ::atomic::Atomic< + Option< + unsafe extern "C" fn(arg1: *const ::std::os::raw::c_char) -> *mut sqlite3_file, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_database_file_object( + arg1: *const ::std::os::raw::c_char, +) -> *mut sqlite3_file { + let fun = __SQLITE3_DATABASE_FILE_OBJECT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_TXN_STATE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_txn_state( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_TXN_STATE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_CHANGES64: ::atomic::Atomic< + Option sqlite3_int64>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_changes64(arg1: *mut sqlite3) -> sqlite3_int64 { + let fun = __SQLITE3_CHANGES64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_TOTAL_CHANGES64: ::atomic::Atomic< + Option sqlite3_int64>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_total_changes64(arg1: *mut sqlite3) -> sqlite3_int64 { + let fun = __SQLITE3_TOTAL_CHANGES64 + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_AUTOVACUUM_PAGES: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_uint, + arg4: ::std::os::raw::c_uint, + arg5: ::std::os::raw::c_uint, + ) -> ::std::os::raw::c_uint, + >, + arg3: *mut ::std::os::raw::c_void, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_autovacuum_pages( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_uint, + arg4: ::std::os::raw::c_uint, + arg5: ::std::os::raw::c_uint, + ) -> ::std::os::raw::c_uint, + >, + arg3: *mut ::std::os::raw::c_void, + arg4: ::std::option::Option, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_AUTOVACUUM_PAGES + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_ERROR_OFFSET: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_error_offset(arg1: *mut sqlite3) -> ::std::os::raw::c_int { + let fun = __SQLITE3_ERROR_OFFSET + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VTAB_RHS_VALUE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_index_info, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_vtab_rhs_value( + arg1: *mut sqlite3_index_info, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_VTAB_RHS_VALUE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_VTAB_DISTINCT: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_vtab_distinct( + arg1: *mut sqlite3_index_info, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_VTAB_DISTINCT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_VTAB_IN: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_index_info, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_vtab_in( + arg1: *mut sqlite3_index_info, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_VTAB_IN + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3) +} + +static __SQLITE3_VTAB_IN_FIRST: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_value, + arg2: *mut *mut sqlite3_value, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_vtab_in_first( + arg1: *mut sqlite3_value, + arg2: *mut *mut sqlite3_value, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_VTAB_IN_FIRST + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_VTAB_IN_NEXT: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_value, + arg2: *mut *mut sqlite3_value, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_vtab_in_next( + arg1: *mut sqlite3_value, + arg2: *mut *mut sqlite3_value, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_VTAB_IN_NEXT + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_DESERIALIZE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *mut ::std::os::raw::c_uchar, + arg4: sqlite3_int64, + arg5: sqlite3_int64, + arg6: ::std::os::raw::c_uint, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_deserialize( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *mut ::std::os::raw::c_uchar, + arg4: sqlite3_int64, + arg5: sqlite3_int64, + arg6: ::std::os::raw::c_uint, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_DESERIALIZE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4, arg5, arg6) +} + +static __SQLITE3_SERIALIZE: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *mut sqlite3_int64, + arg4: ::std::os::raw::c_uint, + ) -> *mut ::std::os::raw::c_uchar, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_serialize( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *mut sqlite3_int64, + arg4: ::std::os::raw::c_uint, +) -> *mut ::std::os::raw::c_uchar { + let fun = __SQLITE3_SERIALIZE + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_DB_NAME: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_db_name( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, +) -> *const ::std::os::raw::c_char { + let fun = __SQLITE3_DB_NAME + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_VALUE_ENCODING: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_value_encoding(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int { + let fun = __SQLITE3_VALUE_ENCODING + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +static __SQLITE3_IS_INTERRUPTED: ::atomic::Atomic< + Option ::std::os::raw::c_int>, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_is_interrupted(arg1: *mut sqlite3) -> ::std::os::raw::c_int { + let fun = __SQLITE3_IS_INTERRUPTED + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1) +} + +/// Loadable extension initialization error +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[non_exhaustive] +pub enum InitError { + /// Invalid sqlite3_api_routines pointer + NullApiPointer, + /// Version mismatch between the extension and the SQLite3 library + VersionMismatch { compile_time: i32, runtime: i32 }, + /// Invalid function pointer in one of sqlite3_api_routines fields + NullFunctionPointer, +} +impl ::std::fmt::Display for InitError { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + match *self { + InitError::NullApiPointer => { + write!(f, "Invalid sqlite3_api_routines pointer") + } + InitError::VersionMismatch { compile_time, runtime } => { + write!(f, "SQLite version mismatch: {runtime} < {compile_time}") + } + InitError::NullFunctionPointer => { + write!(f, "Some sqlite3_api_routines fields are null") + } + } + } +} +/// Like SQLITE_EXTENSION_INIT2 macro +pub unsafe fn rusqlite_extension_init2( + p_api: *mut sqlite3_api_routines, +) -> ::std::result::Result<(), InitError> { + if p_api.is_null() { + return Err(InitError::NullApiPointer); + } + if let Some(fun) = (*p_api).libversion_number { + let version = fun(); + if SQLITE_VERSION_NUMBER > version { + return Err(InitError::VersionMismatch { + compile_time: SQLITE_VERSION_NUMBER, + runtime: version, + }); + } + } else { + return Err(InitError::NullFunctionPointer); + } + __SQLITE3_AGGREGATE_CONTEXT + .store((*p_api).aggregate_context, ::atomic::Ordering::Release); + __SQLITE3_AGGREGATE_COUNT + .store((*p_api).aggregate_count, ::atomic::Ordering::Release); + __SQLITE3_BIND_BLOB.store((*p_api).bind_blob, ::atomic::Ordering::Release); + __SQLITE3_BIND_DOUBLE.store((*p_api).bind_double, ::atomic::Ordering::Release); + __SQLITE3_BIND_INT.store((*p_api).bind_int, ::atomic::Ordering::Release); + __SQLITE3_BIND_INT64.store((*p_api).bind_int64, ::atomic::Ordering::Release); + __SQLITE3_BIND_NULL.store((*p_api).bind_null, ::atomic::Ordering::Release); + __SQLITE3_BIND_PARAMETER_COUNT + .store((*p_api).bind_parameter_count, ::atomic::Ordering::Release); + __SQLITE3_BIND_PARAMETER_INDEX + .store((*p_api).bind_parameter_index, ::atomic::Ordering::Release); + __SQLITE3_BIND_PARAMETER_NAME + .store((*p_api).bind_parameter_name, ::atomic::Ordering::Release); + __SQLITE3_BIND_TEXT.store((*p_api).bind_text, ::atomic::Ordering::Release); + __SQLITE3_BIND_TEXT16.store((*p_api).bind_text16, ::atomic::Ordering::Release); + __SQLITE3_BIND_VALUE.store((*p_api).bind_value, ::atomic::Ordering::Release); + __SQLITE3_BUSY_HANDLER.store((*p_api).busy_handler, ::atomic::Ordering::Release); + __SQLITE3_BUSY_TIMEOUT.store((*p_api).busy_timeout, ::atomic::Ordering::Release); + __SQLITE3_CHANGES.store((*p_api).changes, ::atomic::Ordering::Release); + __SQLITE3_CLOSE.store((*p_api).close, ::atomic::Ordering::Release); + __SQLITE3_COLLATION_NEEDED + .store((*p_api).collation_needed, ::atomic::Ordering::Release); + __SQLITE3_COLLATION_NEEDED16 + .store((*p_api).collation_needed16, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_BLOB.store((*p_api).column_blob, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_BYTES.store((*p_api).column_bytes, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_BYTES16.store((*p_api).column_bytes16, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_COUNT.store((*p_api).column_count, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_DATABASE_NAME + .store((*p_api).column_database_name, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_DATABASE_NAME16 + .store((*p_api).column_database_name16, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_DECLTYPE + .store((*p_api).column_decltype, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_DECLTYPE16 + .store((*p_api).column_decltype16, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_DOUBLE.store((*p_api).column_double, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_INT.store((*p_api).column_int, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_INT64.store((*p_api).column_int64, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_NAME.store((*p_api).column_name, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_NAME16.store((*p_api).column_name16, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_ORIGIN_NAME + .store((*p_api).column_origin_name, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_ORIGIN_NAME16 + .store((*p_api).column_origin_name16, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_TABLE_NAME + .store((*p_api).column_table_name, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_TABLE_NAME16 + .store((*p_api).column_table_name16, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_TEXT.store((*p_api).column_text, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_TEXT16.store((*p_api).column_text16, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_TYPE.store((*p_api).column_type, ::atomic::Ordering::Release); + __SQLITE3_COLUMN_VALUE.store((*p_api).column_value, ::atomic::Ordering::Release); + __SQLITE3_COMMIT_HOOK.store((*p_api).commit_hook, ::atomic::Ordering::Release); + __SQLITE3_COMPLETE.store((*p_api).complete, ::atomic::Ordering::Release); + __SQLITE3_COMPLETE16.store((*p_api).complete16, ::atomic::Ordering::Release); + __SQLITE3_CREATE_COLLATION + .store((*p_api).create_collation, ::atomic::Ordering::Release); + __SQLITE3_CREATE_COLLATION16 + .store((*p_api).create_collation16, ::atomic::Ordering::Release); + __SQLITE3_CREATE_FUNCTION + .store((*p_api).create_function, ::atomic::Ordering::Release); + __SQLITE3_CREATE_FUNCTION16 + .store((*p_api).create_function16, ::atomic::Ordering::Release); + __SQLITE3_CREATE_MODULE.store((*p_api).create_module, ::atomic::Ordering::Release); + __SQLITE3_DATA_COUNT.store((*p_api).data_count, ::atomic::Ordering::Release); + __SQLITE3_DB_HANDLE.store((*p_api).db_handle, ::atomic::Ordering::Release); + __SQLITE3_DECLARE_VTAB.store((*p_api).declare_vtab, ::atomic::Ordering::Release); + __SQLITE3_ENABLE_SHARED_CACHE + .store((*p_api).enable_shared_cache, ::atomic::Ordering::Release); + __SQLITE3_ERRCODE.store((*p_api).errcode, ::atomic::Ordering::Release); + __SQLITE3_ERRMSG.store((*p_api).errmsg, ::atomic::Ordering::Release); + __SQLITE3_ERRMSG16.store((*p_api).errmsg16, ::atomic::Ordering::Release); + __SQLITE3_EXEC.store((*p_api).exec, ::atomic::Ordering::Release); + __SQLITE3_EXPIRED.store((*p_api).expired, ::atomic::Ordering::Release); + __SQLITE3_FINALIZE.store((*p_api).finalize, ::atomic::Ordering::Release); + __SQLITE3_FREE.store((*p_api).free, ::atomic::Ordering::Release); + __SQLITE3_FREE_TABLE.store((*p_api).free_table, ::atomic::Ordering::Release); + __SQLITE3_GET_AUTOCOMMIT.store((*p_api).get_autocommit, ::atomic::Ordering::Release); + __SQLITE3_GET_AUXDATA.store((*p_api).get_auxdata, ::atomic::Ordering::Release); + __SQLITE3_GET_TABLE.store((*p_api).get_table, ::atomic::Ordering::Release); + __SQLITE3_GLOBAL_RECOVER.store((*p_api).global_recover, ::atomic::Ordering::Release); + __SQLITE3_INTERRUPT.store((*p_api).interruptx, ::atomic::Ordering::Release); + __SQLITE3_LAST_INSERT_ROWID + .store((*p_api).last_insert_rowid, ::atomic::Ordering::Release); + __SQLITE3_LIBVERSION.store((*p_api).libversion, ::atomic::Ordering::Release); + __SQLITE3_LIBVERSION_NUMBER + .store((*p_api).libversion_number, ::atomic::Ordering::Release); + __SQLITE3_MALLOC.store((*p_api).malloc, ::atomic::Ordering::Release); + __SQLITE3_OPEN.store((*p_api).open, ::atomic::Ordering::Release); + __SQLITE3_OPEN16.store((*p_api).open16, ::atomic::Ordering::Release); + __SQLITE3_PREPARE.store((*p_api).prepare, ::atomic::Ordering::Release); + __SQLITE3_PREPARE16.store((*p_api).prepare16, ::atomic::Ordering::Release); + __SQLITE3_PROFILE.store((*p_api).profile, ::atomic::Ordering::Release); + __SQLITE3_PROGRESS_HANDLER + .store((*p_api).progress_handler, ::atomic::Ordering::Release); + __SQLITE3_REALLOC.store((*p_api).realloc, ::atomic::Ordering::Release); + __SQLITE3_RESET.store((*p_api).reset, ::atomic::Ordering::Release); + __SQLITE3_RESULT_BLOB.store((*p_api).result_blob, ::atomic::Ordering::Release); + __SQLITE3_RESULT_DOUBLE.store((*p_api).result_double, ::atomic::Ordering::Release); + __SQLITE3_RESULT_ERROR.store((*p_api).result_error, ::atomic::Ordering::Release); + __SQLITE3_RESULT_ERROR16.store((*p_api).result_error16, ::atomic::Ordering::Release); + __SQLITE3_RESULT_INT.store((*p_api).result_int, ::atomic::Ordering::Release); + __SQLITE3_RESULT_INT64.store((*p_api).result_int64, ::atomic::Ordering::Release); + __SQLITE3_RESULT_NULL.store((*p_api).result_null, ::atomic::Ordering::Release); + __SQLITE3_RESULT_TEXT.store((*p_api).result_text, ::atomic::Ordering::Release); + __SQLITE3_RESULT_TEXT16.store((*p_api).result_text16, ::atomic::Ordering::Release); + __SQLITE3_RESULT_TEXT16BE + .store((*p_api).result_text16be, ::atomic::Ordering::Release); + __SQLITE3_RESULT_TEXT16LE + .store((*p_api).result_text16le, ::atomic::Ordering::Release); + __SQLITE3_RESULT_VALUE.store((*p_api).result_value, ::atomic::Ordering::Release); + __SQLITE3_ROLLBACK_HOOK.store((*p_api).rollback_hook, ::atomic::Ordering::Release); + __SQLITE3_SET_AUTHORIZER.store((*p_api).set_authorizer, ::atomic::Ordering::Release); + __SQLITE3_SET_AUXDATA.store((*p_api).set_auxdata, ::atomic::Ordering::Release); + __SQLITE3_STEP.store((*p_api).step, ::atomic::Ordering::Release); + __SQLITE3_TABLE_COLUMN_METADATA + .store((*p_api).table_column_metadata, ::atomic::Ordering::Release); + __SQLITE3_THREAD_CLEANUP.store((*p_api).thread_cleanup, ::atomic::Ordering::Release); + __SQLITE3_TOTAL_CHANGES.store((*p_api).total_changes, ::atomic::Ordering::Release); + __SQLITE3_TRACE.store((*p_api).trace, ::atomic::Ordering::Release); + __SQLITE3_TRANSFER_BINDINGS + .store((*p_api).transfer_bindings, ::atomic::Ordering::Release); + __SQLITE3_UPDATE_HOOK.store((*p_api).update_hook, ::atomic::Ordering::Release); + __SQLITE3_USER_DATA.store((*p_api).user_data, ::atomic::Ordering::Release); + __SQLITE3_VALUE_BLOB.store((*p_api).value_blob, ::atomic::Ordering::Release); + __SQLITE3_VALUE_BYTES.store((*p_api).value_bytes, ::atomic::Ordering::Release); + __SQLITE3_VALUE_BYTES16.store((*p_api).value_bytes16, ::atomic::Ordering::Release); + __SQLITE3_VALUE_DOUBLE.store((*p_api).value_double, ::atomic::Ordering::Release); + __SQLITE3_VALUE_INT.store((*p_api).value_int, ::atomic::Ordering::Release); + __SQLITE3_VALUE_INT64.store((*p_api).value_int64, ::atomic::Ordering::Release); + __SQLITE3_VALUE_NUMERIC_TYPE + .store((*p_api).value_numeric_type, ::atomic::Ordering::Release); + __SQLITE3_VALUE_TEXT.store((*p_api).value_text, ::atomic::Ordering::Release); + __SQLITE3_VALUE_TEXT16.store((*p_api).value_text16, ::atomic::Ordering::Release); + __SQLITE3_VALUE_TEXT16BE.store((*p_api).value_text16be, ::atomic::Ordering::Release); + __SQLITE3_VALUE_TEXT16LE.store((*p_api).value_text16le, ::atomic::Ordering::Release); + __SQLITE3_VALUE_TYPE.store((*p_api).value_type, ::atomic::Ordering::Release); + __SQLITE3_OVERLOAD_FUNCTION + .store((*p_api).overload_function, ::atomic::Ordering::Release); + __SQLITE3_PREPARE_V2.store((*p_api).prepare_v2, ::atomic::Ordering::Release); + __SQLITE3_PREPARE16_V2.store((*p_api).prepare16_v2, ::atomic::Ordering::Release); + __SQLITE3_CLEAR_BINDINGS.store((*p_api).clear_bindings, ::atomic::Ordering::Release); + __SQLITE3_CREATE_MODULE_V2 + .store((*p_api).create_module_v2, ::atomic::Ordering::Release); + __SQLITE3_BIND_ZEROBLOB.store((*p_api).bind_zeroblob, ::atomic::Ordering::Release); + __SQLITE3_BLOB_BYTES.store((*p_api).blob_bytes, ::atomic::Ordering::Release); + __SQLITE3_BLOB_CLOSE.store((*p_api).blob_close, ::atomic::Ordering::Release); + __SQLITE3_BLOB_OPEN.store((*p_api).blob_open, ::atomic::Ordering::Release); + __SQLITE3_BLOB_READ.store((*p_api).blob_read, ::atomic::Ordering::Release); + __SQLITE3_BLOB_WRITE.store((*p_api).blob_write, ::atomic::Ordering::Release); + __SQLITE3_CREATE_COLLATION_V2 + .store((*p_api).create_collation_v2, ::atomic::Ordering::Release); + __SQLITE3_FILE_CONTROL.store((*p_api).file_control, ::atomic::Ordering::Release); + __SQLITE3_MEMORY_HIGHWATER + .store((*p_api).memory_highwater, ::atomic::Ordering::Release); + __SQLITE3_MEMORY_USED.store((*p_api).memory_used, ::atomic::Ordering::Release); + __SQLITE3_MUTEX_ALLOC.store((*p_api).mutex_alloc, ::atomic::Ordering::Release); + __SQLITE3_MUTEX_ENTER.store((*p_api).mutex_enter, ::atomic::Ordering::Release); + __SQLITE3_MUTEX_FREE.store((*p_api).mutex_free, ::atomic::Ordering::Release); + __SQLITE3_MUTEX_LEAVE.store((*p_api).mutex_leave, ::atomic::Ordering::Release); + __SQLITE3_MUTEX_TRY.store((*p_api).mutex_try, ::atomic::Ordering::Release); + __SQLITE3_OPEN_V2.store((*p_api).open_v2, ::atomic::Ordering::Release); + __SQLITE3_RELEASE_MEMORY.store((*p_api).release_memory, ::atomic::Ordering::Release); + __SQLITE3_RESULT_ERROR_NOMEM + .store((*p_api).result_error_nomem, ::atomic::Ordering::Release); + __SQLITE3_RESULT_ERROR_TOOBIG + .store((*p_api).result_error_toobig, ::atomic::Ordering::Release); + __SQLITE3_SLEEP.store((*p_api).sleep, ::atomic::Ordering::Release); + __SQLITE3_SOFT_HEAP_LIMIT + .store((*p_api).soft_heap_limit, ::atomic::Ordering::Release); + __SQLITE3_VFS_FIND.store((*p_api).vfs_find, ::atomic::Ordering::Release); + __SQLITE3_VFS_REGISTER.store((*p_api).vfs_register, ::atomic::Ordering::Release); + __SQLITE3_VFS_UNREGISTER.store((*p_api).vfs_unregister, ::atomic::Ordering::Release); + __SQLITE3_THREADSAFE.store((*p_api).xthreadsafe, ::atomic::Ordering::Release); + __SQLITE3_RESULT_ZEROBLOB + .store((*p_api).result_zeroblob, ::atomic::Ordering::Release); + __SQLITE3_RESULT_ERROR_CODE + .store((*p_api).result_error_code, ::atomic::Ordering::Release); + __SQLITE3_RANDOMNESS.store((*p_api).randomness, ::atomic::Ordering::Release); + __SQLITE3_CONTEXT_DB_HANDLE + .store((*p_api).context_db_handle, ::atomic::Ordering::Release); + __SQLITE3_EXTENDED_RESULT_CODES + .store((*p_api).extended_result_codes, ::atomic::Ordering::Release); + __SQLITE3_LIMIT.store((*p_api).limit, ::atomic::Ordering::Release); + __SQLITE3_NEXT_STMT.store((*p_api).next_stmt, ::atomic::Ordering::Release); + __SQLITE3_SQL.store((*p_api).sql, ::atomic::Ordering::Release); + __SQLITE3_STATUS.store((*p_api).status, ::atomic::Ordering::Release); + __SQLITE3_BACKUP_FINISH.store((*p_api).backup_finish, ::atomic::Ordering::Release); + __SQLITE3_BACKUP_INIT.store((*p_api).backup_init, ::atomic::Ordering::Release); + __SQLITE3_BACKUP_PAGECOUNT + .store((*p_api).backup_pagecount, ::atomic::Ordering::Release); + __SQLITE3_BACKUP_REMAINING + .store((*p_api).backup_remaining, ::atomic::Ordering::Release); + __SQLITE3_BACKUP_STEP.store((*p_api).backup_step, ::atomic::Ordering::Release); + __SQLITE3_COMPILEOPTION_GET + .store((*p_api).compileoption_get, ::atomic::Ordering::Release); + __SQLITE3_COMPILEOPTION_USED + .store((*p_api).compileoption_used, ::atomic::Ordering::Release); + __SQLITE3_CREATE_FUNCTION_V2 + .store((*p_api).create_function_v2, ::atomic::Ordering::Release); + __SQLITE3_DB_CONFIG.store((*p_api).db_config, ::atomic::Ordering::Release); + __SQLITE3_DB_MUTEX.store((*p_api).db_mutex, ::atomic::Ordering::Release); + __SQLITE3_DB_STATUS.store((*p_api).db_status, ::atomic::Ordering::Release); + __SQLITE3_EXTENDED_ERRCODE + .store((*p_api).extended_errcode, ::atomic::Ordering::Release); + __SQLITE3_LOG.store((*p_api).log, ::atomic::Ordering::Release); + __SQLITE3_SOFT_HEAP_LIMIT64 + .store((*p_api).soft_heap_limit64, ::atomic::Ordering::Release); + __SQLITE3_SOURCEID.store((*p_api).sourceid, ::atomic::Ordering::Release); + __SQLITE3_STMT_STATUS.store((*p_api).stmt_status, ::atomic::Ordering::Release); + __SQLITE3_STRNICMP.store((*p_api).strnicmp, ::atomic::Ordering::Release); + __SQLITE3_UNLOCK_NOTIFY.store((*p_api).unlock_notify, ::atomic::Ordering::Release); + __SQLITE3_WAL_AUTOCHECKPOINT + .store((*p_api).wal_autocheckpoint, ::atomic::Ordering::Release); + __SQLITE3_WAL_CHECKPOINT.store((*p_api).wal_checkpoint, ::atomic::Ordering::Release); + __SQLITE3_WAL_HOOK.store((*p_api).wal_hook, ::atomic::Ordering::Release); + __SQLITE3_BLOB_REOPEN.store((*p_api).blob_reopen, ::atomic::Ordering::Release); + __SQLITE3_VTAB_CONFIG.store((*p_api).vtab_config, ::atomic::Ordering::Release); + __SQLITE3_VTAB_ON_CONFLICT + .store((*p_api).vtab_on_conflict, ::atomic::Ordering::Release); + __SQLITE3_CLOSE_V2.store((*p_api).close_v2, ::atomic::Ordering::Release); + __SQLITE3_DB_FILENAME.store((*p_api).db_filename, ::atomic::Ordering::Release); + __SQLITE3_DB_READONLY.store((*p_api).db_readonly, ::atomic::Ordering::Release); + __SQLITE3_DB_RELEASE_MEMORY + .store((*p_api).db_release_memory, ::atomic::Ordering::Release); + __SQLITE3_ERRSTR.store((*p_api).errstr, ::atomic::Ordering::Release); + __SQLITE3_STMT_BUSY.store((*p_api).stmt_busy, ::atomic::Ordering::Release); + __SQLITE3_STMT_READONLY.store((*p_api).stmt_readonly, ::atomic::Ordering::Release); + __SQLITE3_STRICMP.store((*p_api).stricmp, ::atomic::Ordering::Release); + __SQLITE3_URI_BOOLEAN.store((*p_api).uri_boolean, ::atomic::Ordering::Release); + __SQLITE3_URI_INT64.store((*p_api).uri_int64, ::atomic::Ordering::Release); + __SQLITE3_URI_PARAMETER.store((*p_api).uri_parameter, ::atomic::Ordering::Release); + __SQLITE3_WAL_CHECKPOINT_V2 + .store((*p_api).wal_checkpoint_v2, ::atomic::Ordering::Release); + __SQLITE3_AUTO_EXTENSION.store((*p_api).auto_extension, ::atomic::Ordering::Release); + __SQLITE3_BIND_BLOB64.store((*p_api).bind_blob64, ::atomic::Ordering::Release); + __SQLITE3_BIND_TEXT64.store((*p_api).bind_text64, ::atomic::Ordering::Release); + __SQLITE3_CANCEL_AUTO_EXTENSION + .store((*p_api).cancel_auto_extension, ::atomic::Ordering::Release); + __SQLITE3_LOAD_EXTENSION.store((*p_api).load_extension, ::atomic::Ordering::Release); + __SQLITE3_MALLOC64.store((*p_api).malloc64, ::atomic::Ordering::Release); + __SQLITE3_MSIZE.store((*p_api).msize, ::atomic::Ordering::Release); + __SQLITE3_REALLOC64.store((*p_api).realloc64, ::atomic::Ordering::Release); + __SQLITE3_RESET_AUTO_EXTENSION + .store((*p_api).reset_auto_extension, ::atomic::Ordering::Release); + __SQLITE3_RESULT_BLOB64.store((*p_api).result_blob64, ::atomic::Ordering::Release); + __SQLITE3_RESULT_TEXT64.store((*p_api).result_text64, ::atomic::Ordering::Release); + __SQLITE3_STRGLOB.store((*p_api).strglob, ::atomic::Ordering::Release); + __SQLITE3_VALUE_DUP.store((*p_api).value_dup, ::atomic::Ordering::Release); + __SQLITE3_VALUE_FREE.store((*p_api).value_free, ::atomic::Ordering::Release); + __SQLITE3_RESULT_ZEROBLOB64 + .store((*p_api).result_zeroblob64, ::atomic::Ordering::Release); + __SQLITE3_BIND_ZEROBLOB64 + .store((*p_api).bind_zeroblob64, ::atomic::Ordering::Release); + __SQLITE3_VALUE_SUBTYPE.store((*p_api).value_subtype, ::atomic::Ordering::Release); + __SQLITE3_RESULT_SUBTYPE.store((*p_api).result_subtype, ::atomic::Ordering::Release); + __SQLITE3_STATUS64.store((*p_api).status64, ::atomic::Ordering::Release); + __SQLITE3_STRLIKE.store((*p_api).strlike, ::atomic::Ordering::Release); + __SQLITE3_DB_CACHEFLUSH.store((*p_api).db_cacheflush, ::atomic::Ordering::Release); + __SQLITE3_SYSTEM_ERRNO.store((*p_api).system_errno, ::atomic::Ordering::Release); + __SQLITE3_TRACE_V2.store((*p_api).trace_v2, ::atomic::Ordering::Release); + __SQLITE3_EXPANDED_SQL.store((*p_api).expanded_sql, ::atomic::Ordering::Release); + __SQLITE3_SET_LAST_INSERT_ROWID + .store((*p_api).set_last_insert_rowid, ::atomic::Ordering::Release); + __SQLITE3_PREPARE_V3.store((*p_api).prepare_v3, ::atomic::Ordering::Release); + __SQLITE3_PREPARE16_V3.store((*p_api).prepare16_v3, ::atomic::Ordering::Release); + __SQLITE3_BIND_POINTER.store((*p_api).bind_pointer, ::atomic::Ordering::Release); + __SQLITE3_RESULT_POINTER.store((*p_api).result_pointer, ::atomic::Ordering::Release); + __SQLITE3_VALUE_POINTER.store((*p_api).value_pointer, ::atomic::Ordering::Release); + __SQLITE3_VTAB_NOCHANGE.store((*p_api).vtab_nochange, ::atomic::Ordering::Release); + __SQLITE3_VALUE_NOCHANGE.store((*p_api).value_nochange, ::atomic::Ordering::Release); + __SQLITE3_VTAB_COLLATION.store((*p_api).vtab_collation, ::atomic::Ordering::Release); + __SQLITE3_KEYWORD_COUNT.store((*p_api).keyword_count, ::atomic::Ordering::Release); + __SQLITE3_KEYWORD_NAME.store((*p_api).keyword_name, ::atomic::Ordering::Release); + __SQLITE3_KEYWORD_CHECK.store((*p_api).keyword_check, ::atomic::Ordering::Release); + __SQLITE3_STR_NEW.store((*p_api).str_new, ::atomic::Ordering::Release); + __SQLITE3_STR_FINISH.store((*p_api).str_finish, ::atomic::Ordering::Release); + __SQLITE3_STR_APPEND.store((*p_api).str_append, ::atomic::Ordering::Release); + __SQLITE3_STR_APPENDALL.store((*p_api).str_appendall, ::atomic::Ordering::Release); + __SQLITE3_STR_APPENDCHAR.store((*p_api).str_appendchar, ::atomic::Ordering::Release); + __SQLITE3_STR_RESET.store((*p_api).str_reset, ::atomic::Ordering::Release); + __SQLITE3_STR_ERRCODE.store((*p_api).str_errcode, ::atomic::Ordering::Release); + __SQLITE3_STR_LENGTH.store((*p_api).str_length, ::atomic::Ordering::Release); + __SQLITE3_STR_VALUE.store((*p_api).str_value, ::atomic::Ordering::Release); + __SQLITE3_CREATE_WINDOW_FUNCTION + .store((*p_api).create_window_function, ::atomic::Ordering::Release); + __SQLITE3_NORMALIZED_SQL.store((*p_api).normalized_sql, ::atomic::Ordering::Release); + __SQLITE3_STMT_ISEXPLAIN.store((*p_api).stmt_isexplain, ::atomic::Ordering::Release); + __SQLITE3_VALUE_FROMBIND.store((*p_api).value_frombind, ::atomic::Ordering::Release); + __SQLITE3_DROP_MODULES.store((*p_api).drop_modules, ::atomic::Ordering::Release); + __SQLITE3_HARD_HEAP_LIMIT64 + .store((*p_api).hard_heap_limit64, ::atomic::Ordering::Release); + __SQLITE3_URI_KEY.store((*p_api).uri_key, ::atomic::Ordering::Release); + __SQLITE3_FILENAME_DATABASE + .store((*p_api).filename_database, ::atomic::Ordering::Release); + __SQLITE3_FILENAME_JOURNAL + .store((*p_api).filename_journal, ::atomic::Ordering::Release); + __SQLITE3_FILENAME_WAL.store((*p_api).filename_wal, ::atomic::Ordering::Release); + __SQLITE3_CREATE_FILENAME + .store((*p_api).create_filename, ::atomic::Ordering::Release); + __SQLITE3_FREE_FILENAME.store((*p_api).free_filename, ::atomic::Ordering::Release); + __SQLITE3_DATABASE_FILE_OBJECT + .store((*p_api).database_file_object, ::atomic::Ordering::Release); + __SQLITE3_TXN_STATE.store((*p_api).txn_state, ::atomic::Ordering::Release); + __SQLITE3_CHANGES64.store((*p_api).changes64, ::atomic::Ordering::Release); + __SQLITE3_TOTAL_CHANGES64 + .store((*p_api).total_changes64, ::atomic::Ordering::Release); + __SQLITE3_AUTOVACUUM_PAGES + .store((*p_api).autovacuum_pages, ::atomic::Ordering::Release); + __SQLITE3_ERROR_OFFSET.store((*p_api).error_offset, ::atomic::Ordering::Release); + __SQLITE3_VTAB_RHS_VALUE.store((*p_api).vtab_rhs_value, ::atomic::Ordering::Release); + __SQLITE3_VTAB_DISTINCT.store((*p_api).vtab_distinct, ::atomic::Ordering::Release); + __SQLITE3_VTAB_IN.store((*p_api).vtab_in, ::atomic::Ordering::Release); + __SQLITE3_VTAB_IN_FIRST.store((*p_api).vtab_in_first, ::atomic::Ordering::Release); + __SQLITE3_VTAB_IN_NEXT.store((*p_api).vtab_in_next, ::atomic::Ordering::Release); + __SQLITE3_DESERIALIZE.store((*p_api).deserialize, ::atomic::Ordering::Release); + __SQLITE3_SERIALIZE.store((*p_api).serialize, ::atomic::Ordering::Release); + __SQLITE3_DB_NAME.store((*p_api).db_name, ::atomic::Ordering::Release); + __SQLITE3_VALUE_ENCODING.store((*p_api).value_encoding, ::atomic::Ordering::Release); + __SQLITE3_IS_INTERRUPTED.store((*p_api).is_interrupted, ::atomic::Ordering::Release); + Ok(()) +} + diff --git a/libsqlite3-sys/upgrade.sh b/libsqlite3-sys/upgrade.sh index 17e505a..6567808 100755 --- a/libsqlite3-sys/upgrade.sh +++ b/libsqlite3-sys/upgrade.sh @@ -3,10 +3,10 @@ SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) echo "$SCRIPT_DIR" cd "$SCRIPT_DIR" || { echo "fatal error" >&2; exit 1; } -cargo clean -mkdir -p "$SCRIPT_DIR/../target" "$SCRIPT_DIR/sqlite3" +cargo clean -p libsqlite3-sys +TARGET_DIR="$SCRIPT_DIR/../target" export SQLITE3_LIB_DIR="$SCRIPT_DIR/sqlite3" -export SQLITE3_INCLUDE_DIR="$SQLITE3_LIB_DIR" +mkdir -p "$TARGET_DIR" "$SQLITE3_LIB_DIR" # Download and extract amalgamation SQLITE=sqlite-amalgamation-3420000 @@ -16,13 +16,24 @@ unzip -p "$SQLITE.zip" "$SQLITE/sqlite3.h" > "$SQLITE3_LIB_DIR/sqlite3.h" unzip -p "$SQLITE.zip" "$SQLITE/sqlite3ext.h" > "$SQLITE3_LIB_DIR/sqlite3ext.h" rm -f "$SQLITE.zip" -# Regenerate bindgen file for sqlite3 +export SQLITE3_INCLUDE_DIR="$SQLITE3_LIB_DIR" +# Regenerate bindgen file for sqlite3.h rm -f "$SQLITE3_LIB_DIR/bindgen_bundled_version.rs" cargo update # Just to make sure there is only one bindgen.rs file in target dir -find "$SCRIPT_DIR/../target" -type f -name bindgen.rs -exec rm {} \; +find "$TARGET_DIR" -type f -name bindgen.rs -exec rm {} \; env LIBSQLITE3_SYS_BUNDLING=1 cargo build --features "buildtime_bindgen session" --no-default-features -find "$SCRIPT_DIR/../target" -type f -name bindgen.rs -exec mv {} "$SQLITE3_LIB_DIR/bindgen_bundled_version.rs" \; +find "$TARGET_DIR" -type f -name bindgen.rs -exec mv {} "$SQLITE3_LIB_DIR/bindgen_bundled_version.rs" \; + +# Regenerate bindgen file for sqlite3ext.h +# some sqlite3_api_routines fields are function pointers with va_list arg but currently stable Rust doesn't support this type. +# FIXME how to generate portable bindings without : +sed -i '' 's/va_list/void*/' "$SQLITE3_LIB_DIR/sqlite3ext.h" +rm -f "$SQLITE3_LIB_DIR/bindgen_bundled_version_ext.rs" +find "$TARGET_DIR" -type f -name bindgen.rs -exec rm {} \; +env LIBSQLITE3_SYS_BUNDLING=1 cargo build --features "buildtime_bindgen loadable_extension" --no-default-features +find "$TARGET_DIR" -type f -name bindgen.rs -exec mv {} "$SQLITE3_LIB_DIR/bindgen_bundled_version_ext.rs" \; +git checkout "$SQLITE3_LIB_DIR/sqlite3ext.h" # Sanity checks cd "$SCRIPT_DIR/.." || { echo "fatal error" >&2; exit 1; } diff --git a/libsqlite3-sys/upgrade_sqlcipher.sh b/libsqlite3-sys/upgrade_sqlcipher.sh index 7332289..fc0b850 100755 --- a/libsqlite3-sys/upgrade_sqlcipher.sh +++ b/libsqlite3-sys/upgrade_sqlcipher.sh @@ -3,7 +3,7 @@ SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) echo "$SCRIPT_DIR" cd "$SCRIPT_DIR" || { echo "fatal error" >&2; exit 1; } -cargo clean +cargo clean -p libsqlite3-sys mkdir -p "$SCRIPT_DIR/../target" "$SCRIPT_DIR/sqlcipher" export SQLCIPHER_LIB_DIR="$SCRIPT_DIR/sqlcipher" export SQLCIPHER_INCLUDE_DIR="$SQLCIPHER_LIB_DIR" diff --git a/libsqlite3-sys/wrapper_ext.h b/libsqlite3-sys/wrapper_ext.h new file mode 100644 index 0000000..ab1b1f9 --- /dev/null +++ b/libsqlite3-sys/wrapper_ext.h @@ -0,0 +1,2 @@ +#include "sqlite3ext.h" + diff --git a/src/inner_connection.rs b/src/inner_connection.rs index a7487a8..6a5c7ba 100644 --- a/src/inner_connection.rs +++ b/src/inner_connection.rs @@ -4,7 +4,7 @@ use std::os::raw::{c_char, c_int}; use std::path::Path; use std::ptr; use std::str; -use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::atomic::AtomicBool; use std::sync::{Arc, Mutex}; use super::ffi; @@ -390,7 +390,7 @@ impl Drop for InnerConnection { } } -#[cfg(not(any(target_arch = "wasm32")))] +#[cfg(not(any(target_arch = "wasm32", feature = "loadable_extension")))] static SQLITE_INIT: std::sync::Once = std::sync::Once::new(); pub static BYPASS_SQLITE_INIT: AtomicBool = AtomicBool::new(false); @@ -440,7 +440,9 @@ fn ensure_safe_sqlite_threading_mode() -> Result<()> { Ok(()) } } else { + #[cfg(not(feature = "loadable_extension"))] SQLITE_INIT.call_once(|| { + use std::sync::atomic::Ordering; if BYPASS_SQLITE_INIT.load(Ordering::Relaxed) { return; } diff --git a/src/trace.rs b/src/trace.rs index ce4c80b..7317a0c 100644 --- a/src/trace.rs +++ b/src/trace.rs @@ -8,8 +8,7 @@ use std::ptr; use std::time::Duration; use super::ffi; -use crate::error::error_from_sqlite_code; -use crate::{Connection, Result}; +use crate::Connection; /// Set up the process-wide SQLite error logging callback. /// @@ -25,7 +24,8 @@ use crate::{Connection, Result}; /// * It must be threadsafe if SQLite is used in a multithreaded way. /// /// cf [The Error And Warning Log](http://sqlite.org/errlog.html). -pub unsafe fn config_log(callback: Option) -> Result<()> { +#[cfg(not(feature = "loadable_extension"))] +pub unsafe fn config_log(callback: Option) -> crate::Result<()> { extern "C" fn log_callback(p_arg: *mut c_void, err: c_int, msg: *const c_char) { let c_slice = unsafe { CStr::from_ptr(msg).to_bytes() }; let callback: fn(c_int, &str) = unsafe { mem::transmute(p_arg) }; @@ -48,7 +48,7 @@ pub unsafe fn config_log(callback: Option) -> Result<()> { if rc == ffi::SQLITE_OK { Ok(()) } else { - Err(error_from_sqlite_code(rc, None)) + Err(crate::error::error_from_sqlite_code(rc, None)) } } diff --git a/tests/deny_single_threaded_sqlite_config.rs b/tests/deny_single_threaded_sqlite_config.rs index 7118dab..aeb7eec 100644 --- a/tests/deny_single_threaded_sqlite_config.rs +++ b/tests/deny_single_threaded_sqlite_config.rs @@ -1,11 +1,11 @@ //! Ensure we reject connections when SQLite is in single-threaded mode, as it //! would violate safety if multiple Rust threads tried to use connections. -use rusqlite::ffi; -use rusqlite::Connection; - +#[cfg(not(feature = "loadable_extension"))] #[test] fn test_error_when_singlethread_mode() { + use rusqlite::ffi; + use rusqlite::Connection; // put SQLite into single-threaded mode unsafe { // Note: macOS system SQLite seems to return an error if you attempt to From 92c536b622807651baad0769e3535f8babc4cb29 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sun, 9 Jul 2023 14:17:19 +0200 Subject: [PATCH 11/63] Remove parse_macros (fails with wrapper_ext.h) --- libsqlite3-sys/Cargo.toml | 4 +-- libsqlite3-sys/build.rs | 60 +++++++++++++-------------------------- 2 files changed, 21 insertions(+), 43 deletions(-) diff --git a/libsqlite3-sys/Cargo.toml b/libsqlite3-sys/Cargo.toml index 1b5fd59..9b718d8 100644 --- a/libsqlite3-sys/Cargo.toml +++ b/libsqlite3-sys/Cargo.toml @@ -23,7 +23,7 @@ min_sqlite_version_3_14_0 = ["pkg-config", "vcpkg"] # Bundle only the bindings file. Note that this does nothing if # `buildtime_bindgen` is enabled. bundled_bindings = [] -loadable_extension = ["atomic", "prettyplease", "quote", "regex", "syn"] +loadable_extension = ["atomic", "prettyplease", "quote", "syn"] # sqlite3_unlock_notify >= 3.6.12 unlock_notify = [] # 3.13.0 @@ -55,6 +55,4 @@ prettyplease = {version = "0.2", optional = true } # like bindgen quote = { version = "1", optional = true, default-features = false } # like bindgen -regex = { version = "1.5", optional = true, default-features = false, features = ["std", "unicode"] } -# like bindgen syn = { version = "2.0", optional = true, features = ["full", "extra-traits", "visit-mut"] } diff --git a/libsqlite3-sys/build.rs b/libsqlite3-sys/build.rs index 93a1a8d..5564fcf 100644 --- a/libsqlite3-sys/build.rs +++ b/libsqlite3-sys/build.rs @@ -659,31 +659,30 @@ mod bindings { .generate() .unwrap_or_else(|_| panic!("could not run bindgen on header {}", header)); - if cfg!(feature = "loadable_extension") { + #[cfg(feature = "loadable_extension")] + { let mut output = Vec::new(); bindings .write(Box::new(&mut output)) .expect("could not write output of bindgen"); let mut output = String::from_utf8(output).expect("bindgen output was not UTF-8?!"); - super::loadable_extension::generate_functions(&header, &mut output); + super::loadable_extension::generate_functions(&mut output); std::fs::write(out_path, output.as_bytes()) - } else { - bindings.write_to_file(out_path) + .unwrap_or_else(|_| panic!("Could not write to {:?}", out_path)); } - .unwrap_or_else(|_| panic!("Could not write to {:?}", out_path)); + #[cfg(not(feature = "loadable_extension"))] + bindings + .write_to_file(out_path) + .unwrap_or_else(|_| panic!("Could not write to {:?}", out_path)); } } #[cfg(all(feature = "buildtime_bindgen", feature = "loadable_extension"))] mod loadable_extension { - use std::collections::HashMap; - /// try to generate similar rust code for all `#define sqlite3_xyz /// sqlite3_api->abc` macros` in sqlite3ext.h - pub fn generate_functions(header: &str, output: &mut String) { - // (1) parse macros in sqlite3ext.h - let mappings = parse_macros(header); - // (2) parse sqlite3_api_routines fields from bindgen output + pub fn generate_functions(output: &mut String) { + // (1) parse sqlite3_api_routines fields from bindgen output let ast: syn::File = syn::parse_str(output).expect("could not parse bindgen output"); let sqlite3_api_routines: syn::ItemStruct = ast .items @@ -703,7 +702,7 @@ mod loadable_extension { let sqlite3_api_routines_ident = sqlite3_api_routines.ident; let p_api = quote::format_ident!("p_api"); let mut stores = Vec::new(); - // (3) `#define sqlite3_xyz sqlite3_api->abc` => `pub unsafe fn + // (2) `#define sqlite3_xyz sqlite3_api->abc` => `pub unsafe fn // sqlite3_xyz(args) -> ty {...}` for each `abc` field: for field in sqlite3_api_routines.fields { let ident = field.ident.expect("unamed field"); @@ -712,12 +711,16 @@ mod loadable_extension { if name == "vmprintf" || name == "xvsnprintf" || name == "str_vappendf" { continue; // skip va_list } - let sqlite3_name = mappings - .get(&name) - .unwrap_or_else(|| panic!("no mapping for {name}")); + let sqlite3_name = match name.as_ref() { + "xthreadsafe" => "sqlite3_threadsafe".to_owned(), + "interruptx" => "sqlite3_interrupt".to_owned(), + _ => { + format!("sqlite3_{name}") + } + }; let ptr_name = syn::Ident::new(format!("__{}", sqlite3_name.to_uppercase()).as_ref(), span); - let sqlite3_fn_name = syn::Ident::new(sqlite3_name, span); + let sqlite3_fn_name = syn::Ident::new(&sqlite3_name, span); let method = extract_method(&field.ty).unwrap_or_else(|| panic!("unexpected type for {name}")); let arg_names: syn::punctuated::Punctuated<&syn::Ident, syn::token::Comma> = method @@ -768,7 +771,7 @@ mod loadable_extension { ); }); } - // (4) generate rust code similar to SQLITE_EXTENSION_INIT2 macro + // (3) generate rust code similar to SQLITE_EXTENSION_INIT2 macro let tokens = quote::quote! { /// Loadable extension initialization error #[derive(Clone, Copy, Debug, PartialEq, Eq)] @@ -813,29 +816,6 @@ mod loadable_extension { output.push('\n'); } - // Load all `#define sqlite3_xyz sqlite3_api->abc` in sqlite3ext.h - // as a map `{abc => sqlite3_xyz}` - // See https://github.com/rust-lang/rust-bindgen/issues/2544 - fn parse_macros(header: &str) -> HashMap { - use regex::Regex; - use std::fs::File; - use std::io::{BufRead, BufReader}; - let re = Regex::new(r"^#define\s+(sqlite3_\w+)\s+sqlite3_api->(\w+)").unwrap(); - let f = File::open(header).expect("could not read sqlite3ext.h"); - let f = BufReader::new(f); - let mut mappings = HashMap::new(); - for line in f.lines() { - let line = line.expect("could not read line"); - if let Some(caps) = re.captures(&line) { - mappings.insert( - caps.get(2).unwrap().as_str().to_owned(), - caps.get(1).unwrap().as_str().to_owned(), - ); - } - } - mappings - } - fn extract_method(ty: &syn::Type) -> Option<&syn::TypeBareFn> { match ty { syn::Type::Path(tp) => tp.path.segments.last(), From 81585a75cb2cd02f80d07147f568f18babe50680 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sun, 9 Jul 2023 15:53:03 +0200 Subject: [PATCH 12/63] Add Connection::extension_init2 --- .../bindgen-bindings/bindgen_3.14.0_ext.rs | 34 +++---------------- libsqlite3-sys/build.rs | 28 +++------------ .../sqlite3/bindgen_bundled_version_ext.rs | 34 +++---------------- libsqlite3-sys/src/error.rs | 34 +++++++++++++++++++ src/error.rs | 18 ++++++++++ src/lib.rs | 11 ++++++ 6 files changed, 75 insertions(+), 84 deletions(-) diff --git a/libsqlite3-sys/bindgen-bindings/bindgen_3.14.0_ext.rs b/libsqlite3-sys/bindgen-bindings/bindgen_3.14.0_ext.rs index cc6a1a2..f6c4cb6 100644 --- a/libsqlite3-sys/bindgen-bindings/bindgen_3.14.0_ext.rs +++ b/libsqlite3-sys/bindgen-bindings/bindgen_3.14.0_ext.rs @@ -6263,49 +6263,23 @@ pub unsafe fn sqlite3_expanded_sql( (fun)(arg1) } -/// Loadable extension initialization error -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -#[non_exhaustive] -pub enum InitError { - /// Invalid sqlite3_api_routines pointer - NullApiPointer, - /// Version mismatch between the extension and the SQLite3 library - VersionMismatch { compile_time: i32, runtime: i32 }, - /// Invalid function pointer in one of sqlite3_api_routines fields - NullFunctionPointer, -} -impl ::std::fmt::Display for InitError { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - match *self { - InitError::NullApiPointer => { - write!(f, "Invalid sqlite3_api_routines pointer") - } - InitError::VersionMismatch { compile_time, runtime } => { - write!(f, "SQLite version mismatch: {runtime} < {compile_time}") - } - InitError::NullFunctionPointer => { - write!(f, "Some sqlite3_api_routines fields are null") - } - } - } -} /// Like SQLITE_EXTENSION_INIT2 macro pub unsafe fn rusqlite_extension_init2( p_api: *mut sqlite3_api_routines, -) -> ::std::result::Result<(), InitError> { +) -> ::std::result::Result<(), crate::InitError> { if p_api.is_null() { - return Err(InitError::NullApiPointer); + return Err(crate::InitError::NullApiPointer); } if let Some(fun) = (*p_api).libversion_number { let version = fun(); if SQLITE_VERSION_NUMBER > version { - return Err(InitError::VersionMismatch { + return Err(crate::InitError::VersionMismatch { compile_time: SQLITE_VERSION_NUMBER, runtime: version, }); } } else { - return Err(InitError::NullFunctionPointer); + return Err(crate::InitError::NullFunctionPointer); } __SQLITE3_AGGREGATE_CONTEXT .store((*p_api).aggregate_context, ::atomic::Ordering::Release); diff --git a/libsqlite3-sys/build.rs b/libsqlite3-sys/build.rs index 5564fcf..49efffb 100644 --- a/libsqlite3-sys/build.rs +++ b/libsqlite3-sys/build.rs @@ -773,38 +773,18 @@ mod loadable_extension { } // (3) generate rust code similar to SQLITE_EXTENSION_INIT2 macro let tokens = quote::quote! { - /// Loadable extension initialization error - #[derive(Clone, Copy, Debug, PartialEq, Eq)] - #[non_exhaustive] - pub enum InitError { - /// Invalid sqlite3_api_routines pointer - NullApiPointer, - /// Version mismatch between the extension and the SQLite3 library - VersionMismatch{compile_time: i32, runtime: i32}, - /// Invalid function pointer in one of sqlite3_api_routines fields - NullFunctionPointer, - } - impl ::std::fmt::Display for InitError { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - match *self { - InitError::NullApiPointer => write!(f, "Invalid sqlite3_api_routines pointer"), - InitError::VersionMismatch{compile_time, runtime} => write!(f, "SQLite version mismatch: {runtime} < {compile_time}"), - InitError::NullFunctionPointer => write!(f, "Some sqlite3_api_routines fields are null"), - } - } - } /// Like SQLITE_EXTENSION_INIT2 macro - pub unsafe fn rusqlite_extension_init2(#p_api: *mut #sqlite3_api_routines_ident) -> ::std::result::Result<(),InitError> { + pub unsafe fn rusqlite_extension_init2(#p_api: *mut #sqlite3_api_routines_ident) -> ::std::result::Result<(),crate::InitError> { if #p_api.is_null() { - return Err(InitError::NullApiPointer); + return Err(crate::InitError::NullApiPointer); } if let Some(fun) = (*#p_api).libversion_number { let version = fun(); if SQLITE_VERSION_NUMBER > version { - return Err(InitError::VersionMismatch{compile_time: SQLITE_VERSION_NUMBER, runtime: version}); + return Err(crate::InitError::VersionMismatch{compile_time: SQLITE_VERSION_NUMBER, runtime: version}); } } else { - return Err(InitError::NullFunctionPointer); + return Err(crate::InitError::NullFunctionPointer); } #(#stores)* Ok(()) diff --git a/libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs b/libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs index c0a371d..a97023e 100644 --- a/libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs +++ b/libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs @@ -7459,49 +7459,23 @@ pub unsafe fn sqlite3_is_interrupted(arg1: *mut sqlite3) -> ::std::os::raw::c_in (fun)(arg1) } -/// Loadable extension initialization error -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -#[non_exhaustive] -pub enum InitError { - /// Invalid sqlite3_api_routines pointer - NullApiPointer, - /// Version mismatch between the extension and the SQLite3 library - VersionMismatch { compile_time: i32, runtime: i32 }, - /// Invalid function pointer in one of sqlite3_api_routines fields - NullFunctionPointer, -} -impl ::std::fmt::Display for InitError { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - match *self { - InitError::NullApiPointer => { - write!(f, "Invalid sqlite3_api_routines pointer") - } - InitError::VersionMismatch { compile_time, runtime } => { - write!(f, "SQLite version mismatch: {runtime} < {compile_time}") - } - InitError::NullFunctionPointer => { - write!(f, "Some sqlite3_api_routines fields are null") - } - } - } -} /// Like SQLITE_EXTENSION_INIT2 macro pub unsafe fn rusqlite_extension_init2( p_api: *mut sqlite3_api_routines, -) -> ::std::result::Result<(), InitError> { +) -> ::std::result::Result<(), crate::InitError> { if p_api.is_null() { - return Err(InitError::NullApiPointer); + return Err(crate::InitError::NullApiPointer); } if let Some(fun) = (*p_api).libversion_number { let version = fun(); if SQLITE_VERSION_NUMBER > version { - return Err(InitError::VersionMismatch { + return Err(crate::InitError::VersionMismatch { compile_time: SQLITE_VERSION_NUMBER, runtime: version, }); } } else { - return Err(InitError::NullFunctionPointer); + return Err(crate::InitError::NullFunctionPointer); } __SQLITE3_AGGREGATE_CONTEXT .store((*p_api).aggregate_context, ::atomic::Ordering::Release); diff --git a/libsqlite3-sys/src/error.rs b/libsqlite3-sys/src/error.rs index 6de7184..4e91547 100644 --- a/libsqlite3-sys/src/error.rs +++ b/libsqlite3-sys/src/error.rs @@ -269,3 +269,37 @@ pub fn code_to_str(code: c_int) -> &'static str { _ => "Unknown error code", } } + +/// Loadable extension initialization error +#[cfg(feature = "loadable_extension")] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[non_exhaustive] +pub enum InitError { + /// Invalid sqlite3_api_routines pointer + NullApiPointer, + /// Version mismatch between the extension and the SQLite3 library + VersionMismatch { compile_time: i32, runtime: i32 }, + /// Invalid function pointer in one of sqlite3_api_routines fields + NullFunctionPointer, +} +#[cfg(feature = "loadable_extension")] +impl ::std::fmt::Display for InitError { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + match *self { + InitError::NullApiPointer => { + write!(f, "Invalid sqlite3_api_routines pointer") + } + InitError::VersionMismatch { + compile_time, + runtime, + } => { + write!(f, "SQLite version mismatch: {runtime} < {compile_time}") + } + InitError::NullFunctionPointer => { + write!(f, "Some sqlite3_api_routines fields are null") + } + } + } +} +#[cfg(feature = "loadable_extension")] +impl error::Error for InitError {} diff --git a/src/error.rs b/src/error.rs index 79df3e7..bbd3f9b 100644 --- a/src/error.rs +++ b/src/error.rs @@ -141,6 +141,10 @@ pub enum Error { /// byte offset of the start of invalid token offset: c_int, }, + /// Loadable extension initialization error + #[cfg(feature = "loadable_extension")] + #[cfg_attr(docsrs, doc(cfg(feature = "loadable_extension")))] + InitError(ffi::InitError), } impl PartialEq for Error { @@ -200,6 +204,8 @@ impl PartialEq for Error { offset: o2, }, ) => e1 == e2 && m1 == m2 && s1 == s2 && o1 == o2, + #[cfg(feature = "loadable_extension")] + (Error::InitError(e1), Error::InitError(e2)) => e1 == e2, (..) => false, } } @@ -241,6 +247,14 @@ impl From for Error { } } +#[cfg(feature = "loadable_extension")] +impl From for Error { + #[cold] + fn from(err: ffi::InitError) -> Error { + Error::InitError(err) + } +} + impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { @@ -311,6 +325,8 @@ impl fmt::Display for Error { ref sql, .. } => write!(f, "{msg} in {sql} at offset {offset}"), + #[cfg(feature = "loadable_extension")] + Error::InitError(ref err) => err.fmt(f), } } } @@ -360,6 +376,8 @@ impl error::Error for Error { Error::BlobSizeError => None, #[cfg(feature = "modern_sqlite")] Error::SqlInputError { ref error, .. } => Some(error), + #[cfg(feature = "loadable_extension")] + Error::InitError(ref err) => Some(err), } } } diff --git a/src/lib.rs b/src/lib.rs index e77a57f..2fd1bdd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -898,6 +898,17 @@ impl Connection { }) } + /// Like SQLITE_EXTENSION_INIT2 macro + #[cfg(feature = "loadable_extension")] + #[cfg_attr(docsrs, doc(cfg(feature = "loadable_extension")))] + pub unsafe fn extension_init2( + db: *mut ffi::sqlite3, + p_api: *mut ffi::sqlite3_api_routines, + ) -> Result { + ffi::rusqlite_extension_init2(p_api)?; + Connection::from_handle(db) + } + /// Create a `Connection` from a raw owned handle. /// /// The returned connection will attempt to close the inner connection From 8051b048db16463927c6b6e21efa0837bda07c08 Mon Sep 17 00:00:00 2001 From: gwenn Date: Fri, 14 Jul 2023 10:18:29 +0200 Subject: [PATCH 13/63] Add a minimal loadable extension example --- .github/workflows/main.yml | 3 +++ Cargo.toml | 5 ++++ examples/loadable_extension.rs | 48 ++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 examples/loadable_extension.rs diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2cd3b8c..abed5ff 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -65,6 +65,9 @@ jobs: - run: cargo test --features 'bundled-full session buildtime_bindgen' --all-targets --workspace --verbose - run: cargo test --features 'bundled-full session buildtime_bindgen' --doc --workspace --verbose + - name: loadable extension + run: cargo build --example loadable_extension --features "loadable_extension modern_sqlite functions vtab trace" + # TODO: move into own action for better caching - name: Static build # Do we expect this to work / should we test with gnu toolchain? diff --git a/Cargo.toml b/Cargo.toml index 38f5937..ae4df7a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -157,6 +157,11 @@ harness = false name = "exec" harness = false +[[example]] +name = "loadable_extension" +crate-type = ["cdylib"] +required-features = ["loadable_extension", "modern_sqlite", "functions", "vtab", "trace"] + [package.metadata.docs.rs] features = ["modern-full"] all-features = false diff --git a/examples/loadable_extension.rs b/examples/loadable_extension.rs new file mode 100644 index 0000000..809d42f --- /dev/null +++ b/examples/loadable_extension.rs @@ -0,0 +1,48 @@ +//! Adaptation of https://sqlite.org/loadext.html#programming_loadable_extensions +use std::os::raw::{c_char, c_int}; + +use rusqlite::ffi; +use rusqlite::functions::FunctionFlags; +use rusqlite::types::{ToSqlOutput, Value}; +use rusqlite::{to_sqlite_error, Connection, Result}; + +/// # build +/// ```sh +/// cargo build --example loadable_extension --features "loadable_extension modern_sqlite functions vtab trace" +/// ``` +/// # test +/// ```sh +/// sqlite> .log on +/// sqlite> .load target/debug/examples/libloadable_extension.so +/// (28) Rusqlite extension initialized +/// sqlite> SELECT rusqlite_test_function(); +/// Rusqlite extension loaded correctly! +/// ``` +#[allow(clippy::not_unsafe_ptr_arg_deref)] +#[no_mangle] +pub extern "C" fn sqlite3_extension_init( + db: *mut ffi::sqlite3, + pz_err_msg: *mut *mut c_char, + p_api: *mut ffi::sqlite3_api_routines, +) -> c_int { + if let Err(err) = extension_init(db, p_api) { + return unsafe { to_sqlite_error(&err, pz_err_msg) }; + } + ffi::SQLITE_OK +} + +fn extension_init(db: *mut ffi::sqlite3, p_api: *mut ffi::sqlite3_api_routines) -> Result<()> { + let db = unsafe { Connection::extension_init2(db, p_api)? }; + db.create_scalar_function( + "rusqlite_test_function", + 0, + FunctionFlags::SQLITE_DETERMINISTIC, + |_ctx| { + Ok(ToSqlOutput::Owned(Value::Text( + "Rusqlite extension loaded correctly!".to_string(), + ))) + }, + )?; + rusqlite::trace::log(ffi::SQLITE_WARNING, "Rusqlite extension initialized"); + Ok(()) +} From d7f2d55bfbffdfbd260dd8dac448b0b0eb551dc8 Mon Sep 17 00:00:00 2001 From: gwenn Date: Fri, 14 Jul 2023 11:07:59 +0200 Subject: [PATCH 14/63] Add example loading extension --- .github/workflows/main.yml | 1 + Cargo.toml | 4 ++++ examples/load_extension.rs | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 examples/load_extension.rs diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index abed5ff..4b75b87 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -67,6 +67,7 @@ jobs: - name: loadable extension run: cargo build --example loadable_extension --features "loadable_extension modern_sqlite functions vtab trace" + run: cargo run --example load_extension --features "load_extension bundled functions vtab trace" # TODO: move into own action for better caching - name: Static build diff --git a/Cargo.toml b/Cargo.toml index ae4df7a..eb2a1b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -162,6 +162,10 @@ name = "loadable_extension" crate-type = ["cdylib"] required-features = ["loadable_extension", "modern_sqlite", "functions", "vtab", "trace"] +[[example]] +name = "load_extension" +required-features = ["load_extension", "bundled", "functions", "vtab", "trace"] + [package.metadata.docs.rs] features = ["modern-full"] all-features = false diff --git a/examples/load_extension.rs b/examples/load_extension.rs new file mode 100644 index 0000000..e23a991 --- /dev/null +++ b/examples/load_extension.rs @@ -0,0 +1,19 @@ +//! Ensure loadable_extension.rs works. + +use rusqlite::{Connection, Result}; + +fn main() -> Result<()> { + let db = Connection::open_in_memory()?; + + unsafe { + db.load_extension_enable()?; + db.load_extension("target/debug/examples/libloadable_extension", None)?; + db.load_extension_disable()?; + } + + let str = db.query_row("SELECT rusqlite_test_function()", [], |row| { + row.get::<_, String>(0) + })?; + assert_eq!(&str, "Rusqlite extension loaded correctly!"); + Ok(()) +} From c8858bbb6892229148e3206148fd9684ed99e735 Mon Sep 17 00:00:00 2001 From: gwenn Date: Fri, 14 Jul 2023 11:19:58 +0200 Subject: [PATCH 15/63] Try to fix invalid workflow file --- .github/workflows/main.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4b75b87..d311fde 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -66,8 +66,9 @@ jobs: - run: cargo test --features 'bundled-full session buildtime_bindgen' --doc --workspace --verbose - name: loadable extension - run: cargo build --example loadable_extension --features "loadable_extension modern_sqlite functions vtab trace" - run: cargo run --example load_extension --features "load_extension bundled functions vtab trace" + run: | + cargo build --example loadable_extension --features "loadable_extension modern_sqlite functions vtab trace" + cargo run --example load_extension --features "load_extension bundled functions vtab trace" # TODO: move into own action for better caching - name: Static build From f9d69410efa08b34a6aa28c35d07d16a9b0aab4a Mon Sep 17 00:00:00 2001 From: gwenn Date: Fri, 14 Jul 2023 15:56:43 +0200 Subject: [PATCH 16/63] Fix panic at 'SQLite API not initialized or SQLite feature omitted' `to_sqlite_error` needs `sqlite3_malloc` ``` sqlite> .log on sqlite> .load target/debug/examples/libloadable_extension.so Error: error during initialization: SQLite version mismatch: 3014000 < 3042000 ``` --- examples/loadable_extension.rs | 4 +++- .../bindgen-bindings/bindgen_3.14.0_ext.rs | 5 +---- libsqlite3-sys/build.rs | 12 ++++++++---- .../sqlite3/bindgen_bundled_version_ext.rs | 5 +---- libsqlite3-sys/src/error.rs | 5 ----- 5 files changed, 13 insertions(+), 18 deletions(-) diff --git a/examples/loadable_extension.rs b/examples/loadable_extension.rs index 809d42f..e913240 100644 --- a/examples/loadable_extension.rs +++ b/examples/loadable_extension.rs @@ -25,7 +25,9 @@ pub extern "C" fn sqlite3_extension_init( pz_err_msg: *mut *mut c_char, p_api: *mut ffi::sqlite3_api_routines, ) -> c_int { - if let Err(err) = extension_init(db, p_api) { + if p_api.is_null() { + return ffi::SQLITE_ERROR; + } else if let Err(err) = extension_init(db, p_api) { return unsafe { to_sqlite_error(&err, pz_err_msg) }; } ffi::SQLITE_OK diff --git a/libsqlite3-sys/bindgen-bindings/bindgen_3.14.0_ext.rs b/libsqlite3-sys/bindgen-bindings/bindgen_3.14.0_ext.rs index f6c4cb6..a8e1afc 100644 --- a/libsqlite3-sys/bindgen-bindings/bindgen_3.14.0_ext.rs +++ b/libsqlite3-sys/bindgen-bindings/bindgen_3.14.0_ext.rs @@ -6267,9 +6267,7 @@ pub unsafe fn sqlite3_expanded_sql( pub unsafe fn rusqlite_extension_init2( p_api: *mut sqlite3_api_routines, ) -> ::std::result::Result<(), crate::InitError> { - if p_api.is_null() { - return Err(crate::InitError::NullApiPointer); - } + __SQLITE3_MALLOC.store((*p_api).malloc, ::atomic::Ordering::Release); if let Some(fun) = (*p_api).libversion_number { let version = fun(); if SQLITE_VERSION_NUMBER > version { @@ -6371,7 +6369,6 @@ pub unsafe fn rusqlite_extension_init2( __SQLITE3_LIBVERSION.store((*p_api).libversion, ::atomic::Ordering::Release); __SQLITE3_LIBVERSION_NUMBER .store((*p_api).libversion_number, ::atomic::Ordering::Release); - __SQLITE3_MALLOC.store((*p_api).malloc, ::atomic::Ordering::Release); __SQLITE3_OPEN.store((*p_api).open, ::atomic::Ordering::Release); __SQLITE3_OPEN16.store((*p_api).open16, ::atomic::Ordering::Release); __SQLITE3_PREPARE.store((*p_api).prepare, ::atomic::Ordering::Release); diff --git a/libsqlite3-sys/build.rs b/libsqlite3-sys/build.rs index 49efffb..dd42653 100644 --- a/libsqlite3-sys/build.rs +++ b/libsqlite3-sys/build.rs @@ -702,6 +702,7 @@ mod loadable_extension { let sqlite3_api_routines_ident = sqlite3_api_routines.ident; let p_api = quote::format_ident!("p_api"); let mut stores = Vec::new(); + let mut malloc = Vec::new(); // (2) `#define sqlite3_xyz sqlite3_api->abc` => `pub unsafe fn // sqlite3_xyz(args) -> ty {...}` for each `abc` field: for field in sqlite3_api_routines.fields { @@ -764,7 +765,12 @@ mod loadable_extension { &syn::parse2(tokens).expect("could not parse quote output"), )); output.push('\n'); - stores.push(quote::quote! { + if name == "malloc" { + &mut malloc + } else { + &mut stores + } + .push(quote::quote! { #ptr_name.store( (*#p_api).#ident, ::atomic::Ordering::Release, @@ -775,9 +781,7 @@ mod loadable_extension { let tokens = quote::quote! { /// Like SQLITE_EXTENSION_INIT2 macro pub unsafe fn rusqlite_extension_init2(#p_api: *mut #sqlite3_api_routines_ident) -> ::std::result::Result<(),crate::InitError> { - if #p_api.is_null() { - return Err(crate::InitError::NullApiPointer); - } + #(#malloc)* // sqlite3_malloc needed by to_sqlite_error if let Some(fun) = (*#p_api).libversion_number { let version = fun(); if SQLITE_VERSION_NUMBER > version { diff --git a/libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs b/libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs index a97023e..b4f9c5d 100644 --- a/libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs +++ b/libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs @@ -7463,9 +7463,7 @@ pub unsafe fn sqlite3_is_interrupted(arg1: *mut sqlite3) -> ::std::os::raw::c_in pub unsafe fn rusqlite_extension_init2( p_api: *mut sqlite3_api_routines, ) -> ::std::result::Result<(), crate::InitError> { - if p_api.is_null() { - return Err(crate::InitError::NullApiPointer); - } + __SQLITE3_MALLOC.store((*p_api).malloc, ::atomic::Ordering::Release); if let Some(fun) = (*p_api).libversion_number { let version = fun(); if SQLITE_VERSION_NUMBER > version { @@ -7567,7 +7565,6 @@ pub unsafe fn rusqlite_extension_init2( __SQLITE3_LIBVERSION.store((*p_api).libversion, ::atomic::Ordering::Release); __SQLITE3_LIBVERSION_NUMBER .store((*p_api).libversion_number, ::atomic::Ordering::Release); - __SQLITE3_MALLOC.store((*p_api).malloc, ::atomic::Ordering::Release); __SQLITE3_OPEN.store((*p_api).open, ::atomic::Ordering::Release); __SQLITE3_OPEN16.store((*p_api).open16, ::atomic::Ordering::Release); __SQLITE3_PREPARE.store((*p_api).prepare, ::atomic::Ordering::Release); diff --git a/libsqlite3-sys/src/error.rs b/libsqlite3-sys/src/error.rs index 4e91547..f93d20a 100644 --- a/libsqlite3-sys/src/error.rs +++ b/libsqlite3-sys/src/error.rs @@ -275,8 +275,6 @@ pub fn code_to_str(code: c_int) -> &'static str { #[derive(Clone, Copy, Debug, PartialEq, Eq)] #[non_exhaustive] pub enum InitError { - /// Invalid sqlite3_api_routines pointer - NullApiPointer, /// Version mismatch between the extension and the SQLite3 library VersionMismatch { compile_time: i32, runtime: i32 }, /// Invalid function pointer in one of sqlite3_api_routines fields @@ -286,9 +284,6 @@ pub enum InitError { impl ::std::fmt::Display for InitError { fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { match *self { - InitError::NullApiPointer => { - write!(f, "Invalid sqlite3_api_routines pointer") - } InitError::VersionMismatch { compile_time, runtime, From 3742efe24c845147d46935daaa7b11399de615b3 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 15 Jul 2023 10:24:51 +0200 Subject: [PATCH 17/63] Omit deprecated functions --- .../bindgen-bindings/bindgen_3.14.0_ext.rs | 90 ------------------- libsqlite3-sys/build.rs | 7 ++ .../sqlite3/bindgen_bundled_version_ext.rs | 67 -------------- 3 files changed, 7 insertions(+), 157 deletions(-) diff --git a/libsqlite3-sys/bindgen-bindings/bindgen_3.14.0_ext.rs b/libsqlite3-sys/bindgen-bindings/bindgen_3.14.0_ext.rs index a8e1afc..5cc4702 100644 --- a/libsqlite3-sys/bindgen-bindings/bindgen_3.14.0_ext.rs +++ b/libsqlite3-sys/bindgen-bindings/bindgen_3.14.0_ext.rs @@ -2509,18 +2509,6 @@ pub unsafe fn sqlite3_aggregate_context( (fun)(arg1, nBytes) } -static __SQLITE3_AGGREGATE_COUNT: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); -pub unsafe fn sqlite3_aggregate_count( - arg1: *mut sqlite3_context, -) -> ::std::os::raw::c_int { - let fun = __SQLITE3_AGGREGATE_COUNT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); - (fun)(arg1) -} - static __SQLITE3_BIND_BLOB: ::atomic::Atomic< Option< unsafe extern "C" fn( @@ -3620,16 +3608,6 @@ pub unsafe fn sqlite3_exec( (fun)(arg1, arg2, arg3, arg4, arg5) } -static __SQLITE3_EXPIRED: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); -pub unsafe fn sqlite3_expired(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int { - let fun = __SQLITE3_EXPIRED - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); - (fun)(arg1) -} - static __SQLITE3_FINALIZE: ::atomic::Atomic< Option ::std::os::raw::c_int>, > = ::atomic::Atomic::new(None); @@ -3714,16 +3692,6 @@ pub unsafe fn sqlite3_get_table( (fun)(arg1, arg2, arg3, arg4, arg5, arg6) } -static __SQLITE3_GLOBAL_RECOVER: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); -pub unsafe fn sqlite3_global_recover() -> ::std::os::raw::c_int { - let fun = __SQLITE3_GLOBAL_RECOVER - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); - (fun)() -} - static __SQLITE3_INTERRUPT: ::atomic::Atomic< Option, > = ::atomic::Atomic::new(None); @@ -4292,16 +4260,6 @@ pub unsafe fn sqlite3_table_column_metadata( (fun)(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) } -static __SQLITE3_THREAD_CLEANUP: ::atomic::Atomic> = ::atomic::Atomic::new( - None, -); -pub unsafe fn sqlite3_thread_cleanup() { - let fun = __SQLITE3_THREAD_CLEANUP - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); - (fun)() -} - static __SQLITE3_TOTAL_CHANGES: ::atomic::Atomic< Option ::std::os::raw::c_int>, > = ::atomic::Atomic::new(None); @@ -4342,24 +4300,6 @@ pub unsafe fn sqlite3_trace( (fun)(arg1, xTrace, arg2) } -static __SQLITE3_TRANSFER_BINDINGS: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: *mut sqlite3_stmt, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); -pub unsafe fn sqlite3_transfer_bindings( - arg1: *mut sqlite3_stmt, - arg2: *mut sqlite3_stmt, -) -> ::std::os::raw::c_int { - let fun = __SQLITE3_TRANSFER_BINDINGS - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); - (fun)(arg1, arg2) -} - static __SQLITE3_UPDATE_HOOK: ::atomic::Atomic< Option< unsafe extern "C" fn( @@ -5800,28 +5740,6 @@ pub unsafe fn sqlite3_uri_parameter( (fun)(arg1, arg2) } -static __SQLITE3_URI_VSNPRINTF: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: ::std::os::raw::c_int, - arg2: *mut ::std::os::raw::c_char, - arg3: *const ::std::os::raw::c_char, - arg4: *mut ::std::os::raw::c_void, - ) -> *mut ::std::os::raw::c_char, - >, -> = ::atomic::Atomic::new(None); -pub unsafe fn sqlite3_uri_vsnprintf( - arg1: ::std::os::raw::c_int, - arg2: *mut ::std::os::raw::c_char, - arg3: *const ::std::os::raw::c_char, - arg4: *mut ::std::os::raw::c_void, -) -> *mut ::std::os::raw::c_char { - let fun = __SQLITE3_URI_VSNPRINTF - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); - (fun)(arg1, arg2, arg3, arg4) -} - static __SQLITE3_WAL_CHECKPOINT_V2: ::atomic::Atomic< Option< unsafe extern "C" fn( @@ -6281,8 +6199,6 @@ pub unsafe fn rusqlite_extension_init2( } __SQLITE3_AGGREGATE_CONTEXT .store((*p_api).aggregate_context, ::atomic::Ordering::Release); - __SQLITE3_AGGREGATE_COUNT - .store((*p_api).aggregate_count, ::atomic::Ordering::Release); __SQLITE3_BIND_BLOB.store((*p_api).bind_blob, ::atomic::Ordering::Release); __SQLITE3_BIND_DOUBLE.store((*p_api).bind_double, ::atomic::Ordering::Release); __SQLITE3_BIND_INT.store((*p_api).bind_int, ::atomic::Ordering::Release); @@ -6355,14 +6271,12 @@ pub unsafe fn rusqlite_extension_init2( __SQLITE3_ERRMSG.store((*p_api).errmsg, ::atomic::Ordering::Release); __SQLITE3_ERRMSG16.store((*p_api).errmsg16, ::atomic::Ordering::Release); __SQLITE3_EXEC.store((*p_api).exec, ::atomic::Ordering::Release); - __SQLITE3_EXPIRED.store((*p_api).expired, ::atomic::Ordering::Release); __SQLITE3_FINALIZE.store((*p_api).finalize, ::atomic::Ordering::Release); __SQLITE3_FREE.store((*p_api).free, ::atomic::Ordering::Release); __SQLITE3_FREE_TABLE.store((*p_api).free_table, ::atomic::Ordering::Release); __SQLITE3_GET_AUTOCOMMIT.store((*p_api).get_autocommit, ::atomic::Ordering::Release); __SQLITE3_GET_AUXDATA.store((*p_api).get_auxdata, ::atomic::Ordering::Release); __SQLITE3_GET_TABLE.store((*p_api).get_table, ::atomic::Ordering::Release); - __SQLITE3_GLOBAL_RECOVER.store((*p_api).global_recover, ::atomic::Ordering::Release); __SQLITE3_INTERRUPT.store((*p_api).interruptx, ::atomic::Ordering::Release); __SQLITE3_LAST_INSERT_ROWID .store((*p_api).last_insert_rowid, ::atomic::Ordering::Release); @@ -6398,11 +6312,8 @@ pub unsafe fn rusqlite_extension_init2( __SQLITE3_STEP.store((*p_api).step, ::atomic::Ordering::Release); __SQLITE3_TABLE_COLUMN_METADATA .store((*p_api).table_column_metadata, ::atomic::Ordering::Release); - __SQLITE3_THREAD_CLEANUP.store((*p_api).thread_cleanup, ::atomic::Ordering::Release); __SQLITE3_TOTAL_CHANGES.store((*p_api).total_changes, ::atomic::Ordering::Release); __SQLITE3_TRACE.store((*p_api).trace, ::atomic::Ordering::Release); - __SQLITE3_TRANSFER_BINDINGS - .store((*p_api).transfer_bindings, ::atomic::Ordering::Release); __SQLITE3_UPDATE_HOOK.store((*p_api).update_hook, ::atomic::Ordering::Release); __SQLITE3_USER_DATA.store((*p_api).user_data, ::atomic::Ordering::Release); __SQLITE3_VALUE_BLOB.store((*p_api).value_blob, ::atomic::Ordering::Release); @@ -6513,7 +6424,6 @@ pub unsafe fn rusqlite_extension_init2( __SQLITE3_URI_BOOLEAN.store((*p_api).uri_boolean, ::atomic::Ordering::Release); __SQLITE3_URI_INT64.store((*p_api).uri_int64, ::atomic::Ordering::Release); __SQLITE3_URI_PARAMETER.store((*p_api).uri_parameter, ::atomic::Ordering::Release); - __SQLITE3_URI_VSNPRINTF.store((*p_api).vsnprintf, ::atomic::Ordering::Release); __SQLITE3_WAL_CHECKPOINT_V2 .store((*p_api).wal_checkpoint_v2, ::atomic::Ordering::Release); __SQLITE3_AUTO_EXTENSION.store((*p_api).auto_extension, ::atomic::Ordering::Release); diff --git a/libsqlite3-sys/build.rs b/libsqlite3-sys/build.rs index dd42653..6541e7d 100644 --- a/libsqlite3-sys/build.rs +++ b/libsqlite3-sys/build.rs @@ -711,6 +711,13 @@ mod loadable_extension { let name = ident.to_string(); if name == "vmprintf" || name == "xvsnprintf" || name == "str_vappendf" { continue; // skip va_list + } else if name == "aggregate_count" + || name == "expired" + || name == "global_recover" + || name == "thread_cleanup" + || name == "transfer_bindings" + { + continue; // omit deprecated } let sqlite3_name = match name.as_ref() { "xthreadsafe" => "sqlite3_threadsafe".to_owned(), diff --git a/libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs b/libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs index b4f9c5d..0028a4b 100644 --- a/libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs +++ b/libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs @@ -2890,18 +2890,6 @@ pub unsafe fn sqlite3_aggregate_context( (fun)(arg1, nBytes) } -static __SQLITE3_AGGREGATE_COUNT: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); -pub unsafe fn sqlite3_aggregate_count( - arg1: *mut sqlite3_context, -) -> ::std::os::raw::c_int { - let fun = __SQLITE3_AGGREGATE_COUNT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); - (fun)(arg1) -} - static __SQLITE3_BIND_BLOB: ::atomic::Atomic< Option< unsafe extern "C" fn( @@ -4001,16 +3989,6 @@ pub unsafe fn sqlite3_exec( (fun)(arg1, arg2, arg3, arg4, arg5) } -static __SQLITE3_EXPIRED: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); -pub unsafe fn sqlite3_expired(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int { - let fun = __SQLITE3_EXPIRED - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); - (fun)(arg1) -} - static __SQLITE3_FINALIZE: ::atomic::Atomic< Option ::std::os::raw::c_int>, > = ::atomic::Atomic::new(None); @@ -4095,16 +4073,6 @@ pub unsafe fn sqlite3_get_table( (fun)(arg1, arg2, arg3, arg4, arg5, arg6) } -static __SQLITE3_GLOBAL_RECOVER: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); -pub unsafe fn sqlite3_global_recover() -> ::std::os::raw::c_int { - let fun = __SQLITE3_GLOBAL_RECOVER - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); - (fun)() -} - static __SQLITE3_INTERRUPT: ::atomic::Atomic< Option, > = ::atomic::Atomic::new(None); @@ -4673,16 +4641,6 @@ pub unsafe fn sqlite3_table_column_metadata( (fun)(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) } -static __SQLITE3_THREAD_CLEANUP: ::atomic::Atomic> = ::atomic::Atomic::new( - None, -); -pub unsafe fn sqlite3_thread_cleanup() { - let fun = __SQLITE3_THREAD_CLEANUP - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); - (fun)() -} - static __SQLITE3_TOTAL_CHANGES: ::atomic::Atomic< Option ::std::os::raw::c_int>, > = ::atomic::Atomic::new(None); @@ -4723,24 +4681,6 @@ pub unsafe fn sqlite3_trace( (fun)(arg1, xTrace, arg2) } -static __SQLITE3_TRANSFER_BINDINGS: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: *mut sqlite3_stmt, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); -pub unsafe fn sqlite3_transfer_bindings( - arg1: *mut sqlite3_stmt, - arg2: *mut sqlite3_stmt, -) -> ::std::os::raw::c_int { - let fun = __SQLITE3_TRANSFER_BINDINGS - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); - (fun)(arg1, arg2) -} - static __SQLITE3_UPDATE_HOOK: ::atomic::Atomic< Option< unsafe extern "C" fn( @@ -7477,8 +7417,6 @@ pub unsafe fn rusqlite_extension_init2( } __SQLITE3_AGGREGATE_CONTEXT .store((*p_api).aggregate_context, ::atomic::Ordering::Release); - __SQLITE3_AGGREGATE_COUNT - .store((*p_api).aggregate_count, ::atomic::Ordering::Release); __SQLITE3_BIND_BLOB.store((*p_api).bind_blob, ::atomic::Ordering::Release); __SQLITE3_BIND_DOUBLE.store((*p_api).bind_double, ::atomic::Ordering::Release); __SQLITE3_BIND_INT.store((*p_api).bind_int, ::atomic::Ordering::Release); @@ -7551,14 +7489,12 @@ pub unsafe fn rusqlite_extension_init2( __SQLITE3_ERRMSG.store((*p_api).errmsg, ::atomic::Ordering::Release); __SQLITE3_ERRMSG16.store((*p_api).errmsg16, ::atomic::Ordering::Release); __SQLITE3_EXEC.store((*p_api).exec, ::atomic::Ordering::Release); - __SQLITE3_EXPIRED.store((*p_api).expired, ::atomic::Ordering::Release); __SQLITE3_FINALIZE.store((*p_api).finalize, ::atomic::Ordering::Release); __SQLITE3_FREE.store((*p_api).free, ::atomic::Ordering::Release); __SQLITE3_FREE_TABLE.store((*p_api).free_table, ::atomic::Ordering::Release); __SQLITE3_GET_AUTOCOMMIT.store((*p_api).get_autocommit, ::atomic::Ordering::Release); __SQLITE3_GET_AUXDATA.store((*p_api).get_auxdata, ::atomic::Ordering::Release); __SQLITE3_GET_TABLE.store((*p_api).get_table, ::atomic::Ordering::Release); - __SQLITE3_GLOBAL_RECOVER.store((*p_api).global_recover, ::atomic::Ordering::Release); __SQLITE3_INTERRUPT.store((*p_api).interruptx, ::atomic::Ordering::Release); __SQLITE3_LAST_INSERT_ROWID .store((*p_api).last_insert_rowid, ::atomic::Ordering::Release); @@ -7594,11 +7530,8 @@ pub unsafe fn rusqlite_extension_init2( __SQLITE3_STEP.store((*p_api).step, ::atomic::Ordering::Release); __SQLITE3_TABLE_COLUMN_METADATA .store((*p_api).table_column_metadata, ::atomic::Ordering::Release); - __SQLITE3_THREAD_CLEANUP.store((*p_api).thread_cleanup, ::atomic::Ordering::Release); __SQLITE3_TOTAL_CHANGES.store((*p_api).total_changes, ::atomic::Ordering::Release); __SQLITE3_TRACE.store((*p_api).trace, ::atomic::Ordering::Release); - __SQLITE3_TRANSFER_BINDINGS - .store((*p_api).transfer_bindings, ::atomic::Ordering::Release); __SQLITE3_UPDATE_HOOK.store((*p_api).update_hook, ::atomic::Ordering::Release); __SQLITE3_USER_DATA.store((*p_api).user_data, ::atomic::Ordering::Release); __SQLITE3_VALUE_BLOB.store((*p_api).value_blob, ::atomic::Ordering::Release); From 856c94063d45d59a81cf5ba856adfa314a19d751 Mon Sep 17 00:00:00 2001 From: gwenn Date: Tue, 18 Jul 2023 17:45:28 +0200 Subject: [PATCH 18/63] Try to fix windows build --- examples/load_extension.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/load_extension.rs b/examples/load_extension.rs index e23a991..9e52bb2 100644 --- a/examples/load_extension.rs +++ b/examples/load_extension.rs @@ -7,7 +7,10 @@ fn main() -> Result<()> { unsafe { db.load_extension_enable()?; + #[cfg(not(windows))] db.load_extension("target/debug/examples/libloadable_extension", None)?; + #[cfg(windows)] + db.load_extension("target/debug/examples/loadable_extension", None)?; db.load_extension_disable()?; } From b86d9321b5538c0977bcc7f0fd12393f346b4e7f Mon Sep 17 00:00:00 2001 From: gwenn Date: Sun, 20 Aug 2023 10:35:26 +0200 Subject: [PATCH 19/63] Support Rust expression like `{x.y}` in SQL strings --- rusqlite-macros/Cargo.toml | 2 +- rusqlite-macros/src/lib.rs | 6 +++++- rusqlite-macros/tests/test.rs | 25 ++++++++++++++++++++++++- src/lib.rs | 8 ++++---- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/rusqlite-macros/Cargo.toml b/rusqlite-macros/Cargo.toml index 3d40775..c50ebcf 100644 --- a/rusqlite-macros/Cargo.toml +++ b/rusqlite-macros/Cargo.toml @@ -12,5 +12,5 @@ categories = ["database"] proc-macro = true [dependencies] -sqlite3-parser = { version = "0.9", default-features = false, features = ["YYNOERRORRECOVERY"] } +sqlite3-parser = { version = "0.10.0", default-features = false, features = ["YYNOERRORRECOVERY", "rust_variable"] } fallible-iterator = "0.3" diff --git a/rusqlite-macros/src/lib.rs b/rusqlite-macros/src/lib.rs index 8dda22c..583f839 100644 --- a/rusqlite-macros/src/lib.rs +++ b/rusqlite-macros/src/lib.rs @@ -58,11 +58,15 @@ fn try_bind(input: TokenStream) -> Result { let mut res = TokenStream::new(); for (i, name) in info.names.iter().enumerate() { res.extend(Some(stmt.clone())); + let offset = match name.as_bytes()[0] { + b'$' | b'@' | b'#' | b':' => 1, + _ => 0, // captured identifier: {...} + }; res.extend(respan( parse_ts(&format!( ".raw_bind_parameter({}, &{})?;", i + 1, - &name[1..] + &name[offset..] )), call_site, )); diff --git a/rusqlite-macros/tests/test.rs b/rusqlite-macros/tests/test.rs index 785ca9b..1499718 100644 --- a/rusqlite-macros/tests/test.rs +++ b/rusqlite-macros/tests/test.rs @@ -16,7 +16,30 @@ fn test_literal() -> Result { let first_name = "El"; let last_name = "Barto"; let mut stmt = Stmt; - __bind!(stmt "SELECT $first_name, $last_name"); + __bind!(stmt "SELECT $first_name, {last_name}"); + Ok(()) +} + +#[test] +fn test_tuple() -> Result { + let names = ("El", "Barto"); + let mut stmt = Stmt; + __bind!(stmt "SELECT {names.0}, {names.1}"); + Ok(()) +} + +#[test] +fn test_struct() -> Result { + struct Person<'s> { + first_name: &'s str, + last_name: &'s str, + } + let p = Person { + first_name: "El", + last_name: "Barto", + }; + let mut stmt = Stmt; + __bind!(stmt "SELECT {p.first_name}, {p.last_name}"); Ok(()) } diff --git a/src/lib.rs b/src/lib.rs index 4106838..a9a3af4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -220,9 +220,9 @@ macro_rules! named_params { /// Captured identifiers in SQL /// -/// * only SQLite `$x` / `@x` / `:x` syntax works (Rust `&x` syntax does not -/// work). +/// * SQLite `$x` / `@x` / `:x` syntax works (Rust `&x` syntax does not work). /// * `$x.y` expression does not work. +/// * `{x}` and `{x.y}` work /// /// # Example /// @@ -249,9 +249,9 @@ macro_rules! prepare_and_bind { /// Captured identifiers in SQL /// -/// * only SQLite `$x` / `@x` / `:x` syntax works (Rust `&x` syntax does not -/// work). +/// * SQLite `$x` / `@x` / `:x` syntax works (Rust `&x` syntax does not work). /// * `$x.y` expression does not work. +/// * `{x}` and `{x.y}` work #[cfg(feature = "rusqlite-macros")] #[cfg_attr(docsrs, doc(cfg(feature = "rusqlite-macros")))] #[macro_export] From bbb570aabd20bae03b3d510acdcfece0e5e7cd6f Mon Sep 17 00:00:00 2001 From: gwenn Date: Mon, 21 Aug 2023 19:40:37 +0200 Subject: [PATCH 20/63] Revert "Support Rust expression like `{x.y}` in SQL strings" This reverts commit b86d9321b5538c0977bcc7f0fd12393f346b4e7f. --- rusqlite-macros/Cargo.toml | 2 +- rusqlite-macros/src/lib.rs | 6 +----- rusqlite-macros/tests/test.rs | 25 +------------------------ src/lib.rs | 8 ++++---- 4 files changed, 7 insertions(+), 34 deletions(-) diff --git a/rusqlite-macros/Cargo.toml b/rusqlite-macros/Cargo.toml index c50ebcf..2fad35b 100644 --- a/rusqlite-macros/Cargo.toml +++ b/rusqlite-macros/Cargo.toml @@ -12,5 +12,5 @@ categories = ["database"] proc-macro = true [dependencies] -sqlite3-parser = { version = "0.10.0", default-features = false, features = ["YYNOERRORRECOVERY", "rust_variable"] } +sqlite3-parser = { version = "0.11", default-features = false, features = ["YYNOERRORRECOVERY"] } fallible-iterator = "0.3" diff --git a/rusqlite-macros/src/lib.rs b/rusqlite-macros/src/lib.rs index 583f839..8dda22c 100644 --- a/rusqlite-macros/src/lib.rs +++ b/rusqlite-macros/src/lib.rs @@ -58,15 +58,11 @@ fn try_bind(input: TokenStream) -> Result { let mut res = TokenStream::new(); for (i, name) in info.names.iter().enumerate() { res.extend(Some(stmt.clone())); - let offset = match name.as_bytes()[0] { - b'$' | b'@' | b'#' | b':' => 1, - _ => 0, // captured identifier: {...} - }; res.extend(respan( parse_ts(&format!( ".raw_bind_parameter({}, &{})?;", i + 1, - &name[offset..] + &name[1..] )), call_site, )); diff --git a/rusqlite-macros/tests/test.rs b/rusqlite-macros/tests/test.rs index 1499718..785ca9b 100644 --- a/rusqlite-macros/tests/test.rs +++ b/rusqlite-macros/tests/test.rs @@ -16,30 +16,7 @@ fn test_literal() -> Result { let first_name = "El"; let last_name = "Barto"; let mut stmt = Stmt; - __bind!(stmt "SELECT $first_name, {last_name}"); - Ok(()) -} - -#[test] -fn test_tuple() -> Result { - let names = ("El", "Barto"); - let mut stmt = Stmt; - __bind!(stmt "SELECT {names.0}, {names.1}"); - Ok(()) -} - -#[test] -fn test_struct() -> Result { - struct Person<'s> { - first_name: &'s str, - last_name: &'s str, - } - let p = Person { - first_name: "El", - last_name: "Barto", - }; - let mut stmt = Stmt; - __bind!(stmt "SELECT {p.first_name}, {p.last_name}"); + __bind!(stmt "SELECT $first_name, $last_name"); Ok(()) } diff --git a/src/lib.rs b/src/lib.rs index a9a3af4..4106838 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -220,9 +220,9 @@ macro_rules! named_params { /// Captured identifiers in SQL /// -/// * SQLite `$x` / `@x` / `:x` syntax works (Rust `&x` syntax does not work). +/// * only SQLite `$x` / `@x` / `:x` syntax works (Rust `&x` syntax does not +/// work). /// * `$x.y` expression does not work. -/// * `{x}` and `{x.y}` work /// /// # Example /// @@ -249,9 +249,9 @@ macro_rules! prepare_and_bind { /// Captured identifiers in SQL /// -/// * SQLite `$x` / `@x` / `:x` syntax works (Rust `&x` syntax does not work). +/// * only SQLite `$x` / `@x` / `:x` syntax works (Rust `&x` syntax does not +/// work). /// * `$x.y` expression does not work. -/// * `{x}` and `{x.y}` work #[cfg(feature = "rusqlite-macros")] #[cfg_attr(docsrs, doc(cfg(feature = "rusqlite-macros")))] #[macro_export] From 5e79f84b370fd69aa2093aad08606c235db3e32b Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 26 Aug 2023 10:54:26 +0000 Subject: [PATCH 21/63] Upgrade SQLite bundled version to 3.43.0 --- .../sqlite3/bindgen_bundled_version.rs | 796 +- libsqlite3-sys/sqlite3/sqlite3.c | 7714 ++++++++++++----- libsqlite3-sys/sqlite3/sqlite3.h | 106 +- libsqlite3-sys/sqlite3/sqlite3ext.h | 4 + libsqlite3-sys/upgrade.sh | 2 +- 5 files changed, 5928 insertions(+), 2694 deletions(-) diff --git a/libsqlite3-sys/sqlite3/bindgen_bundled_version.rs b/libsqlite3-sys/sqlite3/bindgen_bundled_version.rs index 6c9e290..032403b 100644 --- a/libsqlite3-sys/sqlite3/bindgen_bundled_version.rs +++ b/libsqlite3-sys/sqlite3/bindgen_bundled_version.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.66.0 */ +/* automatically generated by rust-bindgen 0.66.1 */ extern "C" { pub fn sqlite3_auto_extension( @@ -23,72 +23,10 @@ extern "C" { ) -> ::std::os::raw::c_int; } -pub const SQLITE_VERSION: &[u8; 7] = b"3.42.0\0"; -pub const SQLITE_VERSION_NUMBER: i32 = 3042000; +pub const SQLITE_VERSION: &[u8; 7] = b"3.43.0\0"; +pub const SQLITE_VERSION_NUMBER: i32 = 3043000; pub const SQLITE_SOURCE_ID: &[u8; 85] = - b"2023-05-16 12:36:15 831d0fb2836b71c9bc51067c49fee4b8f18047814f2ff22d817d25195cf350b0\0"; -extern "C" { - pub static sqlite3_version: [::std::os::raw::c_char; 0usize]; -} -extern "C" { - pub fn sqlite3_libversion() -> *const ::std::os::raw::c_char; -} -extern "C" { - pub fn sqlite3_sourceid() -> *const ::std::os::raw::c_char; -} -extern "C" { - pub fn sqlite3_libversion_number() -> ::std::os::raw::c_int; -} -extern "C" { - pub fn sqlite3_compileoption_used( - zOptName: *const ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn sqlite3_compileoption_get(N: ::std::os::raw::c_int) -> *const ::std::os::raw::c_char; -} -extern "C" { - pub fn sqlite3_threadsafe() -> ::std::os::raw::c_int; -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct sqlite3 { - _unused: [u8; 0], -} -pub type sqlite_int64 = ::std::os::raw::c_longlong; -pub type sqlite_uint64 = ::std::os::raw::c_ulonglong; -pub type sqlite3_int64 = sqlite_int64; -pub type sqlite3_uint64 = sqlite_uint64; -extern "C" { - pub fn sqlite3_close(arg1: *mut sqlite3) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn sqlite3_close_v2(arg1: *mut sqlite3) -> ::std::os::raw::c_int; -} -pub type sqlite3_callback = ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - arg2: ::std::os::raw::c_int, - arg3: *mut *mut ::std::os::raw::c_char, - arg4: *mut *mut ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, ->; -extern "C" { - pub fn sqlite3_exec( - arg1: *mut sqlite3, - sql: *const ::std::os::raw::c_char, - callback: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - arg2: ::std::os::raw::c_int, - arg3: *mut *mut ::std::os::raw::c_char, - arg4: *mut *mut ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, - >, - arg2: *mut ::std::os::raw::c_void, - errmsg: *mut *mut ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int; -} + b"2023-08-24 12:36:59 0f80b798b3f4b81a7bb4233c58294edd0f1156f36b6ecf5ab8e83631d468778c\0"; pub const SQLITE_OK: i32 = 0; pub const SQLITE_ERROR: i32 = 1; pub const SQLITE_INTERNAL: i32 = 2; @@ -156,6 +94,7 @@ pub const SQLITE_IOERR_COMMIT_ATOMIC: i32 = 7690; pub const SQLITE_IOERR_ROLLBACK_ATOMIC: i32 = 7946; pub const SQLITE_IOERR_DATA: i32 = 8202; pub const SQLITE_IOERR_CORRUPTFS: i32 = 8458; +pub const SQLITE_IOERR_IN_PAGE: i32 = 8714; pub const SQLITE_LOCKED_SHAREDCACHE: i32 = 262; pub const SQLITE_LOCKED_VTAB: i32 = 518; pub const SQLITE_BUSY_RECOVERY: i32 = 261; @@ -242,6 +181,394 @@ pub const SQLITE_LOCK_EXCLUSIVE: i32 = 4; pub const SQLITE_SYNC_NORMAL: i32 = 2; pub const SQLITE_SYNC_FULL: i32 = 3; pub const SQLITE_SYNC_DATAONLY: i32 = 16; +pub const SQLITE_FCNTL_LOCKSTATE: i32 = 1; +pub const SQLITE_FCNTL_GET_LOCKPROXYFILE: i32 = 2; +pub const SQLITE_FCNTL_SET_LOCKPROXYFILE: i32 = 3; +pub const SQLITE_FCNTL_LAST_ERRNO: i32 = 4; +pub const SQLITE_FCNTL_SIZE_HINT: i32 = 5; +pub const SQLITE_FCNTL_CHUNK_SIZE: i32 = 6; +pub const SQLITE_FCNTL_FILE_POINTER: i32 = 7; +pub const SQLITE_FCNTL_SYNC_OMITTED: i32 = 8; +pub const SQLITE_FCNTL_WIN32_AV_RETRY: i32 = 9; +pub const SQLITE_FCNTL_PERSIST_WAL: i32 = 10; +pub const SQLITE_FCNTL_OVERWRITE: i32 = 11; +pub const SQLITE_FCNTL_VFSNAME: i32 = 12; +pub const SQLITE_FCNTL_POWERSAFE_OVERWRITE: i32 = 13; +pub const SQLITE_FCNTL_PRAGMA: i32 = 14; +pub const SQLITE_FCNTL_BUSYHANDLER: i32 = 15; +pub const SQLITE_FCNTL_TEMPFILENAME: i32 = 16; +pub const SQLITE_FCNTL_MMAP_SIZE: i32 = 18; +pub const SQLITE_FCNTL_TRACE: i32 = 19; +pub const SQLITE_FCNTL_HAS_MOVED: i32 = 20; +pub const SQLITE_FCNTL_SYNC: i32 = 21; +pub const SQLITE_FCNTL_COMMIT_PHASETWO: i32 = 22; +pub const SQLITE_FCNTL_WIN32_SET_HANDLE: i32 = 23; +pub const SQLITE_FCNTL_WAL_BLOCK: i32 = 24; +pub const SQLITE_FCNTL_ZIPVFS: i32 = 25; +pub const SQLITE_FCNTL_RBU: i32 = 26; +pub const SQLITE_FCNTL_VFS_POINTER: i32 = 27; +pub const SQLITE_FCNTL_JOURNAL_POINTER: i32 = 28; +pub const SQLITE_FCNTL_WIN32_GET_HANDLE: i32 = 29; +pub const SQLITE_FCNTL_PDB: i32 = 30; +pub const SQLITE_FCNTL_BEGIN_ATOMIC_WRITE: i32 = 31; +pub const SQLITE_FCNTL_COMMIT_ATOMIC_WRITE: i32 = 32; +pub const SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE: i32 = 33; +pub const SQLITE_FCNTL_LOCK_TIMEOUT: i32 = 34; +pub const SQLITE_FCNTL_DATA_VERSION: i32 = 35; +pub const SQLITE_FCNTL_SIZE_LIMIT: i32 = 36; +pub const SQLITE_FCNTL_CKPT_DONE: i32 = 37; +pub const SQLITE_FCNTL_RESERVE_BYTES: i32 = 38; +pub const SQLITE_FCNTL_CKPT_START: i32 = 39; +pub const SQLITE_FCNTL_EXTERNAL_READER: i32 = 40; +pub const SQLITE_FCNTL_CKSM_FILE: i32 = 41; +pub const SQLITE_FCNTL_RESET_CACHE: i32 = 42; +pub const SQLITE_GET_LOCKPROXYFILE: i32 = 2; +pub const SQLITE_SET_LOCKPROXYFILE: i32 = 3; +pub const SQLITE_LAST_ERRNO: i32 = 4; +pub const SQLITE_ACCESS_EXISTS: i32 = 0; +pub const SQLITE_ACCESS_READWRITE: i32 = 1; +pub const SQLITE_ACCESS_READ: i32 = 2; +pub const SQLITE_SHM_UNLOCK: i32 = 1; +pub const SQLITE_SHM_LOCK: i32 = 2; +pub const SQLITE_SHM_SHARED: i32 = 4; +pub const SQLITE_SHM_EXCLUSIVE: i32 = 8; +pub const SQLITE_SHM_NLOCK: i32 = 8; +pub const SQLITE_CONFIG_SINGLETHREAD: i32 = 1; +pub const SQLITE_CONFIG_MULTITHREAD: i32 = 2; +pub const SQLITE_CONFIG_SERIALIZED: i32 = 3; +pub const SQLITE_CONFIG_MALLOC: i32 = 4; +pub const SQLITE_CONFIG_GETMALLOC: i32 = 5; +pub const SQLITE_CONFIG_SCRATCH: i32 = 6; +pub const SQLITE_CONFIG_PAGECACHE: i32 = 7; +pub const SQLITE_CONFIG_HEAP: i32 = 8; +pub const SQLITE_CONFIG_MEMSTATUS: i32 = 9; +pub const SQLITE_CONFIG_MUTEX: i32 = 10; +pub const SQLITE_CONFIG_GETMUTEX: i32 = 11; +pub const SQLITE_CONFIG_LOOKASIDE: i32 = 13; +pub const SQLITE_CONFIG_PCACHE: i32 = 14; +pub const SQLITE_CONFIG_GETPCACHE: i32 = 15; +pub const SQLITE_CONFIG_LOG: i32 = 16; +pub const SQLITE_CONFIG_URI: i32 = 17; +pub const SQLITE_CONFIG_PCACHE2: i32 = 18; +pub const SQLITE_CONFIG_GETPCACHE2: i32 = 19; +pub const SQLITE_CONFIG_COVERING_INDEX_SCAN: i32 = 20; +pub const SQLITE_CONFIG_SQLLOG: i32 = 21; +pub const SQLITE_CONFIG_MMAP_SIZE: i32 = 22; +pub const SQLITE_CONFIG_WIN32_HEAPSIZE: i32 = 23; +pub const SQLITE_CONFIG_PCACHE_HDRSZ: i32 = 24; +pub const SQLITE_CONFIG_PMASZ: i32 = 25; +pub const SQLITE_CONFIG_STMTJRNL_SPILL: i32 = 26; +pub const SQLITE_CONFIG_SMALL_MALLOC: i32 = 27; +pub const SQLITE_CONFIG_SORTERREF_SIZE: i32 = 28; +pub const SQLITE_CONFIG_MEMDB_MAXSIZE: i32 = 29; +pub const SQLITE_DBCONFIG_MAINDBNAME: i32 = 1000; +pub const SQLITE_DBCONFIG_LOOKASIDE: i32 = 1001; +pub const SQLITE_DBCONFIG_ENABLE_FKEY: i32 = 1002; +pub const SQLITE_DBCONFIG_ENABLE_TRIGGER: i32 = 1003; +pub const SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER: i32 = 1004; +pub const SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION: i32 = 1005; +pub const SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE: i32 = 1006; +pub const SQLITE_DBCONFIG_ENABLE_QPSG: i32 = 1007; +pub const SQLITE_DBCONFIG_TRIGGER_EQP: i32 = 1008; +pub const SQLITE_DBCONFIG_RESET_DATABASE: i32 = 1009; +pub const SQLITE_DBCONFIG_DEFENSIVE: i32 = 1010; +pub const SQLITE_DBCONFIG_WRITABLE_SCHEMA: i32 = 1011; +pub const SQLITE_DBCONFIG_LEGACY_ALTER_TABLE: i32 = 1012; +pub const SQLITE_DBCONFIG_DQS_DML: i32 = 1013; +pub const SQLITE_DBCONFIG_DQS_DDL: i32 = 1014; +pub const SQLITE_DBCONFIG_ENABLE_VIEW: i32 = 1015; +pub const SQLITE_DBCONFIG_LEGACY_FILE_FORMAT: i32 = 1016; +pub const SQLITE_DBCONFIG_TRUSTED_SCHEMA: i32 = 1017; +pub const SQLITE_DBCONFIG_STMT_SCANSTATUS: i32 = 1018; +pub const SQLITE_DBCONFIG_REVERSE_SCANORDER: i32 = 1019; +pub const SQLITE_DBCONFIG_MAX: i32 = 1019; +pub const SQLITE_DENY: i32 = 1; +pub const SQLITE_IGNORE: i32 = 2; +pub const SQLITE_CREATE_INDEX: i32 = 1; +pub const SQLITE_CREATE_TABLE: i32 = 2; +pub const SQLITE_CREATE_TEMP_INDEX: i32 = 3; +pub const SQLITE_CREATE_TEMP_TABLE: i32 = 4; +pub const SQLITE_CREATE_TEMP_TRIGGER: i32 = 5; +pub const SQLITE_CREATE_TEMP_VIEW: i32 = 6; +pub const SQLITE_CREATE_TRIGGER: i32 = 7; +pub const SQLITE_CREATE_VIEW: i32 = 8; +pub const SQLITE_DELETE: i32 = 9; +pub const SQLITE_DROP_INDEX: i32 = 10; +pub const SQLITE_DROP_TABLE: i32 = 11; +pub const SQLITE_DROP_TEMP_INDEX: i32 = 12; +pub const SQLITE_DROP_TEMP_TABLE: i32 = 13; +pub const SQLITE_DROP_TEMP_TRIGGER: i32 = 14; +pub const SQLITE_DROP_TEMP_VIEW: i32 = 15; +pub const SQLITE_DROP_TRIGGER: i32 = 16; +pub const SQLITE_DROP_VIEW: i32 = 17; +pub const SQLITE_INSERT: i32 = 18; +pub const SQLITE_PRAGMA: i32 = 19; +pub const SQLITE_READ: i32 = 20; +pub const SQLITE_SELECT: i32 = 21; +pub const SQLITE_TRANSACTION: i32 = 22; +pub const SQLITE_UPDATE: i32 = 23; +pub const SQLITE_ATTACH: i32 = 24; +pub const SQLITE_DETACH: i32 = 25; +pub const SQLITE_ALTER_TABLE: i32 = 26; +pub const SQLITE_REINDEX: i32 = 27; +pub const SQLITE_ANALYZE: i32 = 28; +pub const SQLITE_CREATE_VTABLE: i32 = 29; +pub const SQLITE_DROP_VTABLE: i32 = 30; +pub const SQLITE_FUNCTION: i32 = 31; +pub const SQLITE_SAVEPOINT: i32 = 32; +pub const SQLITE_COPY: i32 = 0; +pub const SQLITE_RECURSIVE: i32 = 33; +pub const SQLITE_TRACE_STMT: i32 = 1; +pub const SQLITE_TRACE_PROFILE: i32 = 2; +pub const SQLITE_TRACE_ROW: i32 = 4; +pub const SQLITE_TRACE_CLOSE: i32 = 8; +pub const SQLITE_LIMIT_LENGTH: i32 = 0; +pub const SQLITE_LIMIT_SQL_LENGTH: i32 = 1; +pub const SQLITE_LIMIT_COLUMN: i32 = 2; +pub const SQLITE_LIMIT_EXPR_DEPTH: i32 = 3; +pub const SQLITE_LIMIT_COMPOUND_SELECT: i32 = 4; +pub const SQLITE_LIMIT_VDBE_OP: i32 = 5; +pub const SQLITE_LIMIT_FUNCTION_ARG: i32 = 6; +pub const SQLITE_LIMIT_ATTACHED: i32 = 7; +pub const SQLITE_LIMIT_LIKE_PATTERN_LENGTH: i32 = 8; +pub const SQLITE_LIMIT_VARIABLE_NUMBER: i32 = 9; +pub const SQLITE_LIMIT_TRIGGER_DEPTH: i32 = 10; +pub const SQLITE_LIMIT_WORKER_THREADS: i32 = 11; +pub const SQLITE_PREPARE_PERSISTENT: ::std::os::raw::c_uint = 1; +pub const SQLITE_PREPARE_NORMALIZE: ::std::os::raw::c_uint = 2; +pub const SQLITE_PREPARE_NO_VTAB: ::std::os::raw::c_uint = 4; +pub const SQLITE_INTEGER: i32 = 1; +pub const SQLITE_FLOAT: i32 = 2; +pub const SQLITE_BLOB: i32 = 4; +pub const SQLITE_NULL: i32 = 5; +pub const SQLITE_TEXT: i32 = 3; +pub const SQLITE3_TEXT: i32 = 3; +pub const SQLITE_UTF8: i32 = 1; +pub const SQLITE_UTF16LE: i32 = 2; +pub const SQLITE_UTF16BE: i32 = 3; +pub const SQLITE_UTF16: i32 = 4; +pub const SQLITE_ANY: i32 = 5; +pub const SQLITE_UTF16_ALIGNED: i32 = 8; +pub const SQLITE_DETERMINISTIC: i32 = 2048; +pub const SQLITE_DIRECTONLY: i32 = 524288; +pub const SQLITE_SUBTYPE: i32 = 1048576; +pub const SQLITE_INNOCUOUS: i32 = 2097152; +pub const SQLITE_WIN32_DATA_DIRECTORY_TYPE: i32 = 1; +pub const SQLITE_WIN32_TEMP_DIRECTORY_TYPE: i32 = 2; +pub const SQLITE_TXN_NONE: i32 = 0; +pub const SQLITE_TXN_READ: i32 = 1; +pub const SQLITE_TXN_WRITE: i32 = 2; +pub const SQLITE_INDEX_SCAN_UNIQUE: i32 = 1; +pub const SQLITE_INDEX_CONSTRAINT_EQ: i32 = 2; +pub const SQLITE_INDEX_CONSTRAINT_GT: i32 = 4; +pub const SQLITE_INDEX_CONSTRAINT_LE: i32 = 8; +pub const SQLITE_INDEX_CONSTRAINT_LT: i32 = 16; +pub const SQLITE_INDEX_CONSTRAINT_GE: i32 = 32; +pub const SQLITE_INDEX_CONSTRAINT_MATCH: i32 = 64; +pub const SQLITE_INDEX_CONSTRAINT_LIKE: i32 = 65; +pub const SQLITE_INDEX_CONSTRAINT_GLOB: i32 = 66; +pub const SQLITE_INDEX_CONSTRAINT_REGEXP: i32 = 67; +pub const SQLITE_INDEX_CONSTRAINT_NE: i32 = 68; +pub const SQLITE_INDEX_CONSTRAINT_ISNOT: i32 = 69; +pub const SQLITE_INDEX_CONSTRAINT_ISNOTNULL: i32 = 70; +pub const SQLITE_INDEX_CONSTRAINT_ISNULL: i32 = 71; +pub const SQLITE_INDEX_CONSTRAINT_IS: i32 = 72; +pub const SQLITE_INDEX_CONSTRAINT_LIMIT: i32 = 73; +pub const SQLITE_INDEX_CONSTRAINT_OFFSET: i32 = 74; +pub const SQLITE_INDEX_CONSTRAINT_FUNCTION: i32 = 150; +pub const SQLITE_MUTEX_FAST: i32 = 0; +pub const SQLITE_MUTEX_RECURSIVE: i32 = 1; +pub const SQLITE_MUTEX_STATIC_MAIN: i32 = 2; +pub const SQLITE_MUTEX_STATIC_MEM: i32 = 3; +pub const SQLITE_MUTEX_STATIC_MEM2: i32 = 4; +pub const SQLITE_MUTEX_STATIC_OPEN: i32 = 4; +pub const SQLITE_MUTEX_STATIC_PRNG: i32 = 5; +pub const SQLITE_MUTEX_STATIC_LRU: i32 = 6; +pub const SQLITE_MUTEX_STATIC_LRU2: i32 = 7; +pub const SQLITE_MUTEX_STATIC_PMEM: i32 = 7; +pub const SQLITE_MUTEX_STATIC_APP1: i32 = 8; +pub const SQLITE_MUTEX_STATIC_APP2: i32 = 9; +pub const SQLITE_MUTEX_STATIC_APP3: i32 = 10; +pub const SQLITE_MUTEX_STATIC_VFS1: i32 = 11; +pub const SQLITE_MUTEX_STATIC_VFS2: i32 = 12; +pub const SQLITE_MUTEX_STATIC_VFS3: i32 = 13; +pub const SQLITE_MUTEX_STATIC_MASTER: i32 = 2; +pub const SQLITE_TESTCTRL_FIRST: i32 = 5; +pub const SQLITE_TESTCTRL_PRNG_SAVE: i32 = 5; +pub const SQLITE_TESTCTRL_PRNG_RESTORE: i32 = 6; +pub const SQLITE_TESTCTRL_PRNG_RESET: i32 = 7; +pub const SQLITE_TESTCTRL_BITVEC_TEST: i32 = 8; +pub const SQLITE_TESTCTRL_FAULT_INSTALL: i32 = 9; +pub const SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS: i32 = 10; +pub const SQLITE_TESTCTRL_PENDING_BYTE: i32 = 11; +pub const SQLITE_TESTCTRL_ASSERT: i32 = 12; +pub const SQLITE_TESTCTRL_ALWAYS: i32 = 13; +pub const SQLITE_TESTCTRL_RESERVE: i32 = 14; +pub const SQLITE_TESTCTRL_OPTIMIZATIONS: i32 = 15; +pub const SQLITE_TESTCTRL_ISKEYWORD: i32 = 16; +pub const SQLITE_TESTCTRL_SCRATCHMALLOC: i32 = 17; +pub const SQLITE_TESTCTRL_INTERNAL_FUNCTIONS: i32 = 17; +pub const SQLITE_TESTCTRL_LOCALTIME_FAULT: i32 = 18; +pub const SQLITE_TESTCTRL_EXPLAIN_STMT: i32 = 19; +pub const SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD: i32 = 19; +pub const SQLITE_TESTCTRL_NEVER_CORRUPT: i32 = 20; +pub const SQLITE_TESTCTRL_VDBE_COVERAGE: i32 = 21; +pub const SQLITE_TESTCTRL_BYTEORDER: i32 = 22; +pub const SQLITE_TESTCTRL_ISINIT: i32 = 23; +pub const SQLITE_TESTCTRL_SORTER_MMAP: i32 = 24; +pub const SQLITE_TESTCTRL_IMPOSTER: i32 = 25; +pub const SQLITE_TESTCTRL_PARSER_COVERAGE: i32 = 26; +pub const SQLITE_TESTCTRL_RESULT_INTREAL: i32 = 27; +pub const SQLITE_TESTCTRL_PRNG_SEED: i32 = 28; +pub const SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS: i32 = 29; +pub const SQLITE_TESTCTRL_SEEK_COUNT: i32 = 30; +pub const SQLITE_TESTCTRL_TRACEFLAGS: i32 = 31; +pub const SQLITE_TESTCTRL_TUNE: i32 = 32; +pub const SQLITE_TESTCTRL_LOGEST: i32 = 33; +pub const SQLITE_TESTCTRL_USELONGDOUBLE: i32 = 34; +pub const SQLITE_TESTCTRL_LAST: i32 = 34; +pub const SQLITE_STATUS_MEMORY_USED: i32 = 0; +pub const SQLITE_STATUS_PAGECACHE_USED: i32 = 1; +pub const SQLITE_STATUS_PAGECACHE_OVERFLOW: i32 = 2; +pub const SQLITE_STATUS_SCRATCH_USED: i32 = 3; +pub const SQLITE_STATUS_SCRATCH_OVERFLOW: i32 = 4; +pub const SQLITE_STATUS_MALLOC_SIZE: i32 = 5; +pub const SQLITE_STATUS_PARSER_STACK: i32 = 6; +pub const SQLITE_STATUS_PAGECACHE_SIZE: i32 = 7; +pub const SQLITE_STATUS_SCRATCH_SIZE: i32 = 8; +pub const SQLITE_STATUS_MALLOC_COUNT: i32 = 9; +pub const SQLITE_DBSTATUS_LOOKASIDE_USED: i32 = 0; +pub const SQLITE_DBSTATUS_CACHE_USED: i32 = 1; +pub const SQLITE_DBSTATUS_SCHEMA_USED: i32 = 2; +pub const SQLITE_DBSTATUS_STMT_USED: i32 = 3; +pub const SQLITE_DBSTATUS_LOOKASIDE_HIT: i32 = 4; +pub const SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE: i32 = 5; +pub const SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL: i32 = 6; +pub const SQLITE_DBSTATUS_CACHE_HIT: i32 = 7; +pub const SQLITE_DBSTATUS_CACHE_MISS: i32 = 8; +pub const SQLITE_DBSTATUS_CACHE_WRITE: i32 = 9; +pub const SQLITE_DBSTATUS_DEFERRED_FKS: i32 = 10; +pub const SQLITE_DBSTATUS_CACHE_USED_SHARED: i32 = 11; +pub const SQLITE_DBSTATUS_CACHE_SPILL: i32 = 12; +pub const SQLITE_DBSTATUS_MAX: i32 = 12; +pub const SQLITE_STMTSTATUS_FULLSCAN_STEP: i32 = 1; +pub const SQLITE_STMTSTATUS_SORT: i32 = 2; +pub const SQLITE_STMTSTATUS_AUTOINDEX: i32 = 3; +pub const SQLITE_STMTSTATUS_VM_STEP: i32 = 4; +pub const SQLITE_STMTSTATUS_REPREPARE: i32 = 5; +pub const SQLITE_STMTSTATUS_RUN: i32 = 6; +pub const SQLITE_STMTSTATUS_FILTER_MISS: i32 = 7; +pub const SQLITE_STMTSTATUS_FILTER_HIT: i32 = 8; +pub const SQLITE_STMTSTATUS_MEMUSED: i32 = 99; +pub const SQLITE_CHECKPOINT_PASSIVE: i32 = 0; +pub const SQLITE_CHECKPOINT_FULL: i32 = 1; +pub const SQLITE_CHECKPOINT_RESTART: i32 = 2; +pub const SQLITE_CHECKPOINT_TRUNCATE: i32 = 3; +pub const SQLITE_VTAB_CONSTRAINT_SUPPORT: i32 = 1; +pub const SQLITE_VTAB_INNOCUOUS: i32 = 2; +pub const SQLITE_VTAB_DIRECTONLY: i32 = 3; +pub const SQLITE_VTAB_USES_ALL_SCHEMAS: i32 = 4; +pub const SQLITE_ROLLBACK: i32 = 1; +pub const SQLITE_FAIL: i32 = 3; +pub const SQLITE_REPLACE: i32 = 5; +pub const SQLITE_SCANSTAT_NLOOP: i32 = 0; +pub const SQLITE_SCANSTAT_NVISIT: i32 = 1; +pub const SQLITE_SCANSTAT_EST: i32 = 2; +pub const SQLITE_SCANSTAT_NAME: i32 = 3; +pub const SQLITE_SCANSTAT_EXPLAIN: i32 = 4; +pub const SQLITE_SCANSTAT_SELECTID: i32 = 5; +pub const SQLITE_SCANSTAT_PARENTID: i32 = 6; +pub const SQLITE_SCANSTAT_NCYCLE: i32 = 7; +pub const SQLITE_SCANSTAT_COMPLEX: i32 = 1; +pub const SQLITE_SERIALIZE_NOCOPY: ::std::os::raw::c_uint = 1; +pub const SQLITE_DESERIALIZE_FREEONCLOSE: ::std::os::raw::c_uint = 1; +pub const SQLITE_DESERIALIZE_RESIZEABLE: ::std::os::raw::c_uint = 2; +pub const SQLITE_DESERIALIZE_READONLY: ::std::os::raw::c_uint = 4; +pub const NOT_WITHIN: i32 = 0; +pub const PARTLY_WITHIN: i32 = 1; +pub const FULLY_WITHIN: i32 = 2; +pub const SQLITE_SESSION_OBJCONFIG_SIZE: i32 = 1; +pub const SQLITE_SESSION_OBJCONFIG_ROWID: i32 = 2; +pub const SQLITE_CHANGESETSTART_INVERT: i32 = 2; +pub const SQLITE_CHANGESETAPPLY_NOSAVEPOINT: i32 = 1; +pub const SQLITE_CHANGESETAPPLY_INVERT: i32 = 2; +pub const SQLITE_CHANGESETAPPLY_IGNORENOOP: i32 = 4; +pub const SQLITE_CHANGESET_DATA: i32 = 1; +pub const SQLITE_CHANGESET_NOTFOUND: i32 = 2; +pub const SQLITE_CHANGESET_CONFLICT: i32 = 3; +pub const SQLITE_CHANGESET_CONSTRAINT: i32 = 4; +pub const SQLITE_CHANGESET_FOREIGN_KEY: i32 = 5; +pub const SQLITE_CHANGESET_OMIT: i32 = 0; +pub const SQLITE_CHANGESET_REPLACE: i32 = 1; +pub const SQLITE_CHANGESET_ABORT: i32 = 2; +pub const SQLITE_SESSION_CONFIG_STRMSIZE: i32 = 1; +pub const FTS5_TOKENIZE_QUERY: i32 = 1; +pub const FTS5_TOKENIZE_PREFIX: i32 = 2; +pub const FTS5_TOKENIZE_DOCUMENT: i32 = 4; +pub const FTS5_TOKENIZE_AUX: i32 = 8; +pub const FTS5_TOKEN_COLOCATED: i32 = 1; +extern "C" { + pub static sqlite3_version: [::std::os::raw::c_char; 0usize]; +} +extern "C" { + pub fn sqlite3_libversion() -> *const ::std::os::raw::c_char; +} +extern "C" { + pub fn sqlite3_sourceid() -> *const ::std::os::raw::c_char; +} +extern "C" { + pub fn sqlite3_libversion_number() -> ::std::os::raw::c_int; +} +extern "C" { + pub fn sqlite3_compileoption_used( + zOptName: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn sqlite3_compileoption_get(N: ::std::os::raw::c_int) -> *const ::std::os::raw::c_char; +} +extern "C" { + pub fn sqlite3_threadsafe() -> ::std::os::raw::c_int; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sqlite3 { + _unused: [u8; 0], +} +pub type sqlite_int64 = ::std::os::raw::c_longlong; +pub type sqlite_uint64 = ::std::os::raw::c_ulonglong; +pub type sqlite3_int64 = sqlite_int64; +pub type sqlite3_uint64 = sqlite_uint64; +extern "C" { + pub fn sqlite3_close(arg1: *mut sqlite3) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn sqlite3_close_v2(arg1: *mut sqlite3) -> ::std::os::raw::c_int; +} +pub type sqlite3_callback = ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut ::std::os::raw::c_char, + arg4: *mut *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, +>; +extern "C" { + pub fn sqlite3_exec( + arg1: *mut sqlite3, + sql: *const ::std::os::raw::c_char, + callback: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut ::std::os::raw::c_char, + arg4: *mut *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + arg2: *mut ::std::os::raw::c_void, + errmsg: *mut *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int; +} #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct sqlite3_file { @@ -356,50 +683,6 @@ pub struct sqlite3_io_methods { ) -> ::std::os::raw::c_int, >, } -pub const SQLITE_FCNTL_LOCKSTATE: i32 = 1; -pub const SQLITE_FCNTL_GET_LOCKPROXYFILE: i32 = 2; -pub const SQLITE_FCNTL_SET_LOCKPROXYFILE: i32 = 3; -pub const SQLITE_FCNTL_LAST_ERRNO: i32 = 4; -pub const SQLITE_FCNTL_SIZE_HINT: i32 = 5; -pub const SQLITE_FCNTL_CHUNK_SIZE: i32 = 6; -pub const SQLITE_FCNTL_FILE_POINTER: i32 = 7; -pub const SQLITE_FCNTL_SYNC_OMITTED: i32 = 8; -pub const SQLITE_FCNTL_WIN32_AV_RETRY: i32 = 9; -pub const SQLITE_FCNTL_PERSIST_WAL: i32 = 10; -pub const SQLITE_FCNTL_OVERWRITE: i32 = 11; -pub const SQLITE_FCNTL_VFSNAME: i32 = 12; -pub const SQLITE_FCNTL_POWERSAFE_OVERWRITE: i32 = 13; -pub const SQLITE_FCNTL_PRAGMA: i32 = 14; -pub const SQLITE_FCNTL_BUSYHANDLER: i32 = 15; -pub const SQLITE_FCNTL_TEMPFILENAME: i32 = 16; -pub const SQLITE_FCNTL_MMAP_SIZE: i32 = 18; -pub const SQLITE_FCNTL_TRACE: i32 = 19; -pub const SQLITE_FCNTL_HAS_MOVED: i32 = 20; -pub const SQLITE_FCNTL_SYNC: i32 = 21; -pub const SQLITE_FCNTL_COMMIT_PHASETWO: i32 = 22; -pub const SQLITE_FCNTL_WIN32_SET_HANDLE: i32 = 23; -pub const SQLITE_FCNTL_WAL_BLOCK: i32 = 24; -pub const SQLITE_FCNTL_ZIPVFS: i32 = 25; -pub const SQLITE_FCNTL_RBU: i32 = 26; -pub const SQLITE_FCNTL_VFS_POINTER: i32 = 27; -pub const SQLITE_FCNTL_JOURNAL_POINTER: i32 = 28; -pub const SQLITE_FCNTL_WIN32_GET_HANDLE: i32 = 29; -pub const SQLITE_FCNTL_PDB: i32 = 30; -pub const SQLITE_FCNTL_BEGIN_ATOMIC_WRITE: i32 = 31; -pub const SQLITE_FCNTL_COMMIT_ATOMIC_WRITE: i32 = 32; -pub const SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE: i32 = 33; -pub const SQLITE_FCNTL_LOCK_TIMEOUT: i32 = 34; -pub const SQLITE_FCNTL_DATA_VERSION: i32 = 35; -pub const SQLITE_FCNTL_SIZE_LIMIT: i32 = 36; -pub const SQLITE_FCNTL_CKPT_DONE: i32 = 37; -pub const SQLITE_FCNTL_RESERVE_BYTES: i32 = 38; -pub const SQLITE_FCNTL_CKPT_START: i32 = 39; -pub const SQLITE_FCNTL_EXTERNAL_READER: i32 = 40; -pub const SQLITE_FCNTL_CKSM_FILE: i32 = 41; -pub const SQLITE_FCNTL_RESET_CACHE: i32 = 42; -pub const SQLITE_GET_LOCKPROXYFILE: i32 = 2; -pub const SQLITE_SET_LOCKPROXYFILE: i32 = 3; -pub const SQLITE_LAST_ERRNO: i32 = 4; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct sqlite3_mutex { @@ -531,14 +814,6 @@ pub struct sqlite3_vfs { ) -> *const ::std::os::raw::c_char, >, } -pub const SQLITE_ACCESS_EXISTS: i32 = 0; -pub const SQLITE_ACCESS_READWRITE: i32 = 1; -pub const SQLITE_ACCESS_READ: i32 = 2; -pub const SQLITE_SHM_UNLOCK: i32 = 1; -pub const SQLITE_SHM_LOCK: i32 = 2; -pub const SQLITE_SHM_SHARED: i32 = 4; -pub const SQLITE_SHM_EXCLUSIVE: i32 = 8; -pub const SQLITE_SHM_NLOCK: i32 = 8; extern "C" { pub fn sqlite3_initialize() -> ::std::os::raw::c_int; } @@ -586,55 +861,6 @@ pub struct sqlite3_mem_methods { pub xShutdown: ::std::option::Option, pub pAppData: *mut ::std::os::raw::c_void, } -pub const SQLITE_CONFIG_SINGLETHREAD: i32 = 1; -pub const SQLITE_CONFIG_MULTITHREAD: i32 = 2; -pub const SQLITE_CONFIG_SERIALIZED: i32 = 3; -pub const SQLITE_CONFIG_MALLOC: i32 = 4; -pub const SQLITE_CONFIG_GETMALLOC: i32 = 5; -pub const SQLITE_CONFIG_SCRATCH: i32 = 6; -pub const SQLITE_CONFIG_PAGECACHE: i32 = 7; -pub const SQLITE_CONFIG_HEAP: i32 = 8; -pub const SQLITE_CONFIG_MEMSTATUS: i32 = 9; -pub const SQLITE_CONFIG_MUTEX: i32 = 10; -pub const SQLITE_CONFIG_GETMUTEX: i32 = 11; -pub const SQLITE_CONFIG_LOOKASIDE: i32 = 13; -pub const SQLITE_CONFIG_PCACHE: i32 = 14; -pub const SQLITE_CONFIG_GETPCACHE: i32 = 15; -pub const SQLITE_CONFIG_LOG: i32 = 16; -pub const SQLITE_CONFIG_URI: i32 = 17; -pub const SQLITE_CONFIG_PCACHE2: i32 = 18; -pub const SQLITE_CONFIG_GETPCACHE2: i32 = 19; -pub const SQLITE_CONFIG_COVERING_INDEX_SCAN: i32 = 20; -pub const SQLITE_CONFIG_SQLLOG: i32 = 21; -pub const SQLITE_CONFIG_MMAP_SIZE: i32 = 22; -pub const SQLITE_CONFIG_WIN32_HEAPSIZE: i32 = 23; -pub const SQLITE_CONFIG_PCACHE_HDRSZ: i32 = 24; -pub const SQLITE_CONFIG_PMASZ: i32 = 25; -pub const SQLITE_CONFIG_STMTJRNL_SPILL: i32 = 26; -pub const SQLITE_CONFIG_SMALL_MALLOC: i32 = 27; -pub const SQLITE_CONFIG_SORTERREF_SIZE: i32 = 28; -pub const SQLITE_CONFIG_MEMDB_MAXSIZE: i32 = 29; -pub const SQLITE_DBCONFIG_MAINDBNAME: i32 = 1000; -pub const SQLITE_DBCONFIG_LOOKASIDE: i32 = 1001; -pub const SQLITE_DBCONFIG_ENABLE_FKEY: i32 = 1002; -pub const SQLITE_DBCONFIG_ENABLE_TRIGGER: i32 = 1003; -pub const SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER: i32 = 1004; -pub const SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION: i32 = 1005; -pub const SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE: i32 = 1006; -pub const SQLITE_DBCONFIG_ENABLE_QPSG: i32 = 1007; -pub const SQLITE_DBCONFIG_TRIGGER_EQP: i32 = 1008; -pub const SQLITE_DBCONFIG_RESET_DATABASE: i32 = 1009; -pub const SQLITE_DBCONFIG_DEFENSIVE: i32 = 1010; -pub const SQLITE_DBCONFIG_WRITABLE_SCHEMA: i32 = 1011; -pub const SQLITE_DBCONFIG_LEGACY_ALTER_TABLE: i32 = 1012; -pub const SQLITE_DBCONFIG_DQS_DML: i32 = 1013; -pub const SQLITE_DBCONFIG_DQS_DDL: i32 = 1014; -pub const SQLITE_DBCONFIG_ENABLE_VIEW: i32 = 1015; -pub const SQLITE_DBCONFIG_LEGACY_FILE_FORMAT: i32 = 1016; -pub const SQLITE_DBCONFIG_TRUSTED_SCHEMA: i32 = 1017; -pub const SQLITE_DBCONFIG_STMT_SCANSTATUS: i32 = 1018; -pub const SQLITE_DBCONFIG_REVERSE_SCANORDER: i32 = 1019; -pub const SQLITE_DBCONFIG_MAX: i32 = 1019; extern "C" { pub fn sqlite3_extended_result_codes( arg1: *mut sqlite3, @@ -763,42 +989,6 @@ extern "C" { pUserData: *mut ::std::os::raw::c_void, ) -> ::std::os::raw::c_int; } -pub const SQLITE_DENY: i32 = 1; -pub const SQLITE_IGNORE: i32 = 2; -pub const SQLITE_CREATE_INDEX: i32 = 1; -pub const SQLITE_CREATE_TABLE: i32 = 2; -pub const SQLITE_CREATE_TEMP_INDEX: i32 = 3; -pub const SQLITE_CREATE_TEMP_TABLE: i32 = 4; -pub const SQLITE_CREATE_TEMP_TRIGGER: i32 = 5; -pub const SQLITE_CREATE_TEMP_VIEW: i32 = 6; -pub const SQLITE_CREATE_TRIGGER: i32 = 7; -pub const SQLITE_CREATE_VIEW: i32 = 8; -pub const SQLITE_DELETE: i32 = 9; -pub const SQLITE_DROP_INDEX: i32 = 10; -pub const SQLITE_DROP_TABLE: i32 = 11; -pub const SQLITE_DROP_TEMP_INDEX: i32 = 12; -pub const SQLITE_DROP_TEMP_TABLE: i32 = 13; -pub const SQLITE_DROP_TEMP_TRIGGER: i32 = 14; -pub const SQLITE_DROP_TEMP_VIEW: i32 = 15; -pub const SQLITE_DROP_TRIGGER: i32 = 16; -pub const SQLITE_DROP_VIEW: i32 = 17; -pub const SQLITE_INSERT: i32 = 18; -pub const SQLITE_PRAGMA: i32 = 19; -pub const SQLITE_READ: i32 = 20; -pub const SQLITE_SELECT: i32 = 21; -pub const SQLITE_TRANSACTION: i32 = 22; -pub const SQLITE_UPDATE: i32 = 23; -pub const SQLITE_ATTACH: i32 = 24; -pub const SQLITE_DETACH: i32 = 25; -pub const SQLITE_ALTER_TABLE: i32 = 26; -pub const SQLITE_REINDEX: i32 = 27; -pub const SQLITE_ANALYZE: i32 = 28; -pub const SQLITE_CREATE_VTABLE: i32 = 29; -pub const SQLITE_DROP_VTABLE: i32 = 30; -pub const SQLITE_FUNCTION: i32 = 31; -pub const SQLITE_SAVEPOINT: i32 = 32; -pub const SQLITE_COPY: i32 = 0; -pub const SQLITE_RECURSIVE: i32 = 33; extern "C" { pub fn sqlite3_trace( arg1: *mut sqlite3, @@ -824,10 +1014,6 @@ extern "C" { arg2: *mut ::std::os::raw::c_void, ) -> *mut ::std::os::raw::c_void; } -pub const SQLITE_TRACE_STMT: i32 = 1; -pub const SQLITE_TRACE_PROFILE: i32 = 2; -pub const SQLITE_TRACE_ROW: i32 = 4; -pub const SQLITE_TRACE_CLOSE: i32 = 8; extern "C" { pub fn sqlite3_trace_v2( arg1: *mut sqlite3, @@ -953,21 +1139,6 @@ extern "C" { newVal: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int; } -pub const SQLITE_LIMIT_LENGTH: i32 = 0; -pub const SQLITE_LIMIT_SQL_LENGTH: i32 = 1; -pub const SQLITE_LIMIT_COLUMN: i32 = 2; -pub const SQLITE_LIMIT_EXPR_DEPTH: i32 = 3; -pub const SQLITE_LIMIT_COMPOUND_SELECT: i32 = 4; -pub const SQLITE_LIMIT_VDBE_OP: i32 = 5; -pub const SQLITE_LIMIT_FUNCTION_ARG: i32 = 6; -pub const SQLITE_LIMIT_ATTACHED: i32 = 7; -pub const SQLITE_LIMIT_LIKE_PATTERN_LENGTH: i32 = 8; -pub const SQLITE_LIMIT_VARIABLE_NUMBER: i32 = 9; -pub const SQLITE_LIMIT_TRIGGER_DEPTH: i32 = 10; -pub const SQLITE_LIMIT_WORKER_THREADS: i32 = 11; -pub const SQLITE_PREPARE_PERSISTENT: ::std::os::raw::c_uint = 1; -pub const SQLITE_PREPARE_NORMALIZE: ::std::os::raw::c_uint = 2; -pub const SQLITE_PREPARE_NO_VTAB: ::std::os::raw::c_uint = 4; extern "C" { pub fn sqlite3_prepare( db: *mut sqlite3, @@ -1036,6 +1207,12 @@ extern "C" { extern "C" { pub fn sqlite3_stmt_isexplain(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int; } +extern "C" { + pub fn sqlite3_stmt_explain( + pStmt: *mut sqlite3_stmt, + eMode: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} extern "C" { pub fn sqlite3_stmt_busy(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int; } @@ -1239,12 +1416,6 @@ extern "C" { extern "C" { pub fn sqlite3_data_count(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int; } -pub const SQLITE_INTEGER: i32 = 1; -pub const SQLITE_FLOAT: i32 = 2; -pub const SQLITE_BLOB: i32 = 4; -pub const SQLITE_NULL: i32 = 5; -pub const SQLITE_TEXT: i32 = 3; -pub const SQLITE3_TEXT: i32 = 3; extern "C" { pub fn sqlite3_column_blob( arg1: *mut sqlite3_stmt, @@ -1407,16 +1578,6 @@ extern "C" { xDestroy: ::std::option::Option, ) -> ::std::os::raw::c_int; } -pub const SQLITE_UTF8: i32 = 1; -pub const SQLITE_UTF16LE: i32 = 2; -pub const SQLITE_UTF16BE: i32 = 3; -pub const SQLITE_UTF16: i32 = 4; -pub const SQLITE_ANY: i32 = 5; -pub const SQLITE_UTF16_ALIGNED: i32 = 8; -pub const SQLITE_DETERMINISTIC: i32 = 2048; -pub const SQLITE_DIRECTONLY: i32 = 524288; -pub const SQLITE_SUBTYPE: i32 = 1048576; -pub const SQLITE_INNOCUOUS: i32 = 2097152; extern "C" { pub fn sqlite3_aggregate_count(arg1: *mut sqlite3_context) -> ::std::os::raw::c_int; } @@ -1758,8 +1919,6 @@ extern "C" { zValue: *const ::std::os::raw::c_void, ) -> ::std::os::raw::c_int; } -pub const SQLITE_WIN32_DATA_DIRECTORY_TYPE: i32 = 1; -pub const SQLITE_WIN32_TEMP_DIRECTORY_TYPE: i32 = 2; extern "C" { pub fn sqlite3_get_autocommit(arg1: *mut sqlite3) -> ::std::os::raw::c_int; } @@ -1790,9 +1949,6 @@ extern "C" { zSchema: *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int; } -pub const SQLITE_TXN_NONE: i32 = 0; -pub const SQLITE_TXN_READ: i32 = 1; -pub const SQLITE_TXN_WRITE: i32 = 2; extern "C" { pub fn sqlite3_next_stmt(pDb: *mut sqlite3, pStmt: *mut sqlite3_stmt) -> *mut sqlite3_stmt; } @@ -2064,24 +2220,6 @@ pub struct sqlite3_index_constraint_usage { pub argvIndex: ::std::os::raw::c_int, pub omit: ::std::os::raw::c_uchar, } -pub const SQLITE_INDEX_SCAN_UNIQUE: i32 = 1; -pub const SQLITE_INDEX_CONSTRAINT_EQ: i32 = 2; -pub const SQLITE_INDEX_CONSTRAINT_GT: i32 = 4; -pub const SQLITE_INDEX_CONSTRAINT_LE: i32 = 8; -pub const SQLITE_INDEX_CONSTRAINT_LT: i32 = 16; -pub const SQLITE_INDEX_CONSTRAINT_GE: i32 = 32; -pub const SQLITE_INDEX_CONSTRAINT_MATCH: i32 = 64; -pub const SQLITE_INDEX_CONSTRAINT_LIKE: i32 = 65; -pub const SQLITE_INDEX_CONSTRAINT_GLOB: i32 = 66; -pub const SQLITE_INDEX_CONSTRAINT_REGEXP: i32 = 67; -pub const SQLITE_INDEX_CONSTRAINT_NE: i32 = 68; -pub const SQLITE_INDEX_CONSTRAINT_ISNOT: i32 = 69; -pub const SQLITE_INDEX_CONSTRAINT_ISNOTNULL: i32 = 70; -pub const SQLITE_INDEX_CONSTRAINT_ISNULL: i32 = 71; -pub const SQLITE_INDEX_CONSTRAINT_IS: i32 = 72; -pub const SQLITE_INDEX_CONSTRAINT_LIMIT: i32 = 73; -pub const SQLITE_INDEX_CONSTRAINT_OFFSET: i32 = 74; -pub const SQLITE_INDEX_CONSTRAINT_FUNCTION: i32 = 150; extern "C" { pub fn sqlite3_create_module( db: *mut sqlite3, @@ -2228,23 +2366,6 @@ extern "C" { extern "C" { pub fn sqlite3_mutex_notheld(arg1: *mut sqlite3_mutex) -> ::std::os::raw::c_int; } -pub const SQLITE_MUTEX_FAST: i32 = 0; -pub const SQLITE_MUTEX_RECURSIVE: i32 = 1; -pub const SQLITE_MUTEX_STATIC_MAIN: i32 = 2; -pub const SQLITE_MUTEX_STATIC_MEM: i32 = 3; -pub const SQLITE_MUTEX_STATIC_MEM2: i32 = 4; -pub const SQLITE_MUTEX_STATIC_OPEN: i32 = 4; -pub const SQLITE_MUTEX_STATIC_PRNG: i32 = 5; -pub const SQLITE_MUTEX_STATIC_LRU: i32 = 6; -pub const SQLITE_MUTEX_STATIC_LRU2: i32 = 7; -pub const SQLITE_MUTEX_STATIC_PMEM: i32 = 7; -pub const SQLITE_MUTEX_STATIC_APP1: i32 = 8; -pub const SQLITE_MUTEX_STATIC_APP2: i32 = 9; -pub const SQLITE_MUTEX_STATIC_APP3: i32 = 10; -pub const SQLITE_MUTEX_STATIC_VFS1: i32 = 11; -pub const SQLITE_MUTEX_STATIC_VFS2: i32 = 12; -pub const SQLITE_MUTEX_STATIC_VFS3: i32 = 13; -pub const SQLITE_MUTEX_STATIC_MASTER: i32 = 2; extern "C" { pub fn sqlite3_db_mutex(arg1: *mut sqlite3) -> *mut sqlite3_mutex; } @@ -2259,39 +2380,6 @@ extern "C" { extern "C" { pub fn sqlite3_test_control(op: ::std::os::raw::c_int, ...) -> ::std::os::raw::c_int; } -pub const SQLITE_TESTCTRL_FIRST: i32 = 5; -pub const SQLITE_TESTCTRL_PRNG_SAVE: i32 = 5; -pub const SQLITE_TESTCTRL_PRNG_RESTORE: i32 = 6; -pub const SQLITE_TESTCTRL_PRNG_RESET: i32 = 7; -pub const SQLITE_TESTCTRL_BITVEC_TEST: i32 = 8; -pub const SQLITE_TESTCTRL_FAULT_INSTALL: i32 = 9; -pub const SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS: i32 = 10; -pub const SQLITE_TESTCTRL_PENDING_BYTE: i32 = 11; -pub const SQLITE_TESTCTRL_ASSERT: i32 = 12; -pub const SQLITE_TESTCTRL_ALWAYS: i32 = 13; -pub const SQLITE_TESTCTRL_RESERVE: i32 = 14; -pub const SQLITE_TESTCTRL_OPTIMIZATIONS: i32 = 15; -pub const SQLITE_TESTCTRL_ISKEYWORD: i32 = 16; -pub const SQLITE_TESTCTRL_SCRATCHMALLOC: i32 = 17; -pub const SQLITE_TESTCTRL_INTERNAL_FUNCTIONS: i32 = 17; -pub const SQLITE_TESTCTRL_LOCALTIME_FAULT: i32 = 18; -pub const SQLITE_TESTCTRL_EXPLAIN_STMT: i32 = 19; -pub const SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD: i32 = 19; -pub const SQLITE_TESTCTRL_NEVER_CORRUPT: i32 = 20; -pub const SQLITE_TESTCTRL_VDBE_COVERAGE: i32 = 21; -pub const SQLITE_TESTCTRL_BYTEORDER: i32 = 22; -pub const SQLITE_TESTCTRL_ISINIT: i32 = 23; -pub const SQLITE_TESTCTRL_SORTER_MMAP: i32 = 24; -pub const SQLITE_TESTCTRL_IMPOSTER: i32 = 25; -pub const SQLITE_TESTCTRL_PARSER_COVERAGE: i32 = 26; -pub const SQLITE_TESTCTRL_RESULT_INTREAL: i32 = 27; -pub const SQLITE_TESTCTRL_PRNG_SEED: i32 = 28; -pub const SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS: i32 = 29; -pub const SQLITE_TESTCTRL_SEEK_COUNT: i32 = 30; -pub const SQLITE_TESTCTRL_TRACEFLAGS: i32 = 31; -pub const SQLITE_TESTCTRL_TUNE: i32 = 32; -pub const SQLITE_TESTCTRL_LOGEST: i32 = 33; -pub const SQLITE_TESTCTRL_LAST: i32 = 33; extern "C" { pub fn sqlite3_keyword_count() -> ::std::os::raw::c_int; } @@ -2367,16 +2455,6 @@ extern "C" { resetFlag: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int; } -pub const SQLITE_STATUS_MEMORY_USED: i32 = 0; -pub const SQLITE_STATUS_PAGECACHE_USED: i32 = 1; -pub const SQLITE_STATUS_PAGECACHE_OVERFLOW: i32 = 2; -pub const SQLITE_STATUS_SCRATCH_USED: i32 = 3; -pub const SQLITE_STATUS_SCRATCH_OVERFLOW: i32 = 4; -pub const SQLITE_STATUS_MALLOC_SIZE: i32 = 5; -pub const SQLITE_STATUS_PARSER_STACK: i32 = 6; -pub const SQLITE_STATUS_PAGECACHE_SIZE: i32 = 7; -pub const SQLITE_STATUS_SCRATCH_SIZE: i32 = 8; -pub const SQLITE_STATUS_MALLOC_COUNT: i32 = 9; extern "C" { pub fn sqlite3_db_status( arg1: *mut sqlite3, @@ -2386,20 +2464,6 @@ extern "C" { resetFlg: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int; } -pub const SQLITE_DBSTATUS_LOOKASIDE_USED: i32 = 0; -pub const SQLITE_DBSTATUS_CACHE_USED: i32 = 1; -pub const SQLITE_DBSTATUS_SCHEMA_USED: i32 = 2; -pub const SQLITE_DBSTATUS_STMT_USED: i32 = 3; -pub const SQLITE_DBSTATUS_LOOKASIDE_HIT: i32 = 4; -pub const SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE: i32 = 5; -pub const SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL: i32 = 6; -pub const SQLITE_DBSTATUS_CACHE_HIT: i32 = 7; -pub const SQLITE_DBSTATUS_CACHE_MISS: i32 = 8; -pub const SQLITE_DBSTATUS_CACHE_WRITE: i32 = 9; -pub const SQLITE_DBSTATUS_DEFERRED_FKS: i32 = 10; -pub const SQLITE_DBSTATUS_CACHE_USED_SHARED: i32 = 11; -pub const SQLITE_DBSTATUS_CACHE_SPILL: i32 = 12; -pub const SQLITE_DBSTATUS_MAX: i32 = 12; extern "C" { pub fn sqlite3_stmt_status( arg1: *mut sqlite3_stmt, @@ -2407,15 +2471,6 @@ extern "C" { resetFlg: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int; } -pub const SQLITE_STMTSTATUS_FULLSCAN_STEP: i32 = 1; -pub const SQLITE_STMTSTATUS_SORT: i32 = 2; -pub const SQLITE_STMTSTATUS_AUTOINDEX: i32 = 3; -pub const SQLITE_STMTSTATUS_VM_STEP: i32 = 4; -pub const SQLITE_STMTSTATUS_REPREPARE: i32 = 5; -pub const SQLITE_STMTSTATUS_RUN: i32 = 6; -pub const SQLITE_STMTSTATUS_FILTER_MISS: i32 = 7; -pub const SQLITE_STMTSTATUS_FILTER_HIT: i32 = 8; -pub const SQLITE_STMTSTATUS_MEMUSED: i32 = 99; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct sqlite3_pcache { @@ -2632,10 +2687,6 @@ extern "C" { pnCkpt: *mut ::std::os::raw::c_int, ) -> ::std::os::raw::c_int; } -pub const SQLITE_CHECKPOINT_PASSIVE: i32 = 0; -pub const SQLITE_CHECKPOINT_FULL: i32 = 1; -pub const SQLITE_CHECKPOINT_RESTART: i32 = 2; -pub const SQLITE_CHECKPOINT_TRUNCATE: i32 = 3; extern "C" { pub fn sqlite3_vtab_config( arg1: *mut sqlite3, @@ -2643,10 +2694,6 @@ extern "C" { ... ) -> ::std::os::raw::c_int; } -pub const SQLITE_VTAB_CONSTRAINT_SUPPORT: i32 = 1; -pub const SQLITE_VTAB_INNOCUOUS: i32 = 2; -pub const SQLITE_VTAB_DIRECTONLY: i32 = 3; -pub const SQLITE_VTAB_USES_ALL_SCHEMAS: i32 = 4; extern "C" { pub fn sqlite3_vtab_on_conflict(arg1: *mut sqlite3) -> ::std::os::raw::c_int; } @@ -2688,17 +2735,6 @@ extern "C" { ppVal: *mut *mut sqlite3_value, ) -> ::std::os::raw::c_int; } -pub const SQLITE_ROLLBACK: i32 = 1; -pub const SQLITE_FAIL: i32 = 3; -pub const SQLITE_REPLACE: i32 = 5; -pub const SQLITE_SCANSTAT_NLOOP: i32 = 0; -pub const SQLITE_SCANSTAT_NVISIT: i32 = 1; -pub const SQLITE_SCANSTAT_EST: i32 = 2; -pub const SQLITE_SCANSTAT_NAME: i32 = 3; -pub const SQLITE_SCANSTAT_EXPLAIN: i32 = 4; -pub const SQLITE_SCANSTAT_SELECTID: i32 = 5; -pub const SQLITE_SCANSTAT_PARENTID: i32 = 6; -pub const SQLITE_SCANSTAT_NCYCLE: i32 = 7; extern "C" { pub fn sqlite3_stmt_scanstatus( pStmt: *mut sqlite3_stmt, @@ -2716,7 +2752,6 @@ extern "C" { pOut: *mut ::std::os::raw::c_void, ) -> ::std::os::raw::c_int; } -pub const SQLITE_SCANSTAT_COMPLEX: i32 = 1; extern "C" { pub fn sqlite3_stmt_scanstatus_reset(arg1: *mut sqlite3_stmt); } @@ -2808,7 +2843,6 @@ extern "C" { mFlags: ::std::os::raw::c_uint, ) -> *mut ::std::os::raw::c_uchar; } -pub const SQLITE_SERIALIZE_NOCOPY: ::std::os::raw::c_uint = 1; extern "C" { pub fn sqlite3_deserialize( db: *mut sqlite3, @@ -2819,9 +2853,6 @@ extern "C" { mFlags: ::std::os::raw::c_uint, ) -> ::std::os::raw::c_int; } -pub const SQLITE_DESERIALIZE_FREEONCLOSE: ::std::os::raw::c_uint = 1; -pub const SQLITE_DESERIALIZE_RESIZEABLE: ::std::os::raw::c_uint = 2; -pub const SQLITE_DESERIALIZE_READONLY: ::std::os::raw::c_uint = 4; pub type sqlite3_rtree_dbl = f64; extern "C" { pub fn sqlite3_rtree_geometry_callback( @@ -2878,9 +2909,6 @@ pub struct sqlite3_rtree_query_info { pub rScore: sqlite3_rtree_dbl, pub apSqlParam: *mut *mut sqlite3_value, } -pub const NOT_WITHIN: i32 = 0; -pub const PARTLY_WITHIN: i32 = 1; -pub const FULLY_WITHIN: i32 = 2; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct sqlite3_session { @@ -2908,8 +2936,6 @@ extern "C" { pArg: *mut ::std::os::raw::c_void, ) -> ::std::os::raw::c_int; } -pub const SQLITE_SESSION_OBJCONFIG_SIZE: i32 = 1; -pub const SQLITE_SESSION_OBJCONFIG_ROWID: i32 = 2; extern "C" { pub fn sqlite3session_enable( pSession: *mut sqlite3_session, @@ -2986,7 +3012,6 @@ extern "C" { flags: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int; } -pub const SQLITE_CHANGESETSTART_INVERT: i32 = 2; extern "C" { pub fn sqlite3changeset_next(pIter: *mut sqlite3_changeset_iter) -> ::std::os::raw::c_int; } @@ -3124,17 +3149,6 @@ extern "C" { flags: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int; } -pub const SQLITE_CHANGESETAPPLY_NOSAVEPOINT: i32 = 1; -pub const SQLITE_CHANGESETAPPLY_INVERT: i32 = 2; -pub const SQLITE_CHANGESETAPPLY_IGNORENOOP: i32 = 4; -pub const SQLITE_CHANGESET_DATA: i32 = 1; -pub const SQLITE_CHANGESET_NOTFOUND: i32 = 2; -pub const SQLITE_CHANGESET_CONFLICT: i32 = 3; -pub const SQLITE_CHANGESET_CONSTRAINT: i32 = 4; -pub const SQLITE_CHANGESET_FOREIGN_KEY: i32 = 5; -pub const SQLITE_CHANGESET_OMIT: i32 = 0; -pub const SQLITE_CHANGESET_REPLACE: i32 = 1; -pub const SQLITE_CHANGESET_ABORT: i32 = 2; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct sqlite3_rebaser { @@ -3373,7 +3387,6 @@ extern "C" { pArg: *mut ::std::os::raw::c_void, ) -> ::std::os::raw::c_int; } -pub const SQLITE_SESSION_CONFIG_STRMSIZE: i32 = 1; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct Fts5Context { @@ -3573,11 +3586,6 @@ pub struct fts5_tokenizer { ) -> ::std::os::raw::c_int, >, } -pub const FTS5_TOKENIZE_QUERY: i32 = 1; -pub const FTS5_TOKENIZE_PREFIX: i32 = 2; -pub const FTS5_TOKENIZE_DOCUMENT: i32 = 4; -pub const FTS5_TOKENIZE_AUX: i32 = 8; -pub const FTS5_TOKEN_COLOCATED: i32 = 1; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct fts5_api { @@ -3586,7 +3594,7 @@ pub struct fts5_api { unsafe extern "C" fn( pApi: *mut fts5_api, zName: *const ::std::os::raw::c_char, - pContext: *mut ::std::os::raw::c_void, + pUserData: *mut ::std::os::raw::c_void, pTokenizer: *mut fts5_tokenizer, xDestroy: ::std::option::Option, ) -> ::std::os::raw::c_int, @@ -3595,7 +3603,7 @@ pub struct fts5_api { unsafe extern "C" fn( pApi: *mut fts5_api, zName: *const ::std::os::raw::c_char, - ppContext: *mut *mut ::std::os::raw::c_void, + ppUserData: *mut *mut ::std::os::raw::c_void, pTokenizer: *mut fts5_tokenizer, ) -> ::std::os::raw::c_int, >, @@ -3603,7 +3611,7 @@ pub struct fts5_api { unsafe extern "C" fn( pApi: *mut fts5_api, zName: *const ::std::os::raw::c_char, - pContext: *mut ::std::os::raw::c_void, + pUserData: *mut ::std::os::raw::c_void, xFunction: fts5_extension_function, xDestroy: ::std::option::Option, ) -> ::std::os::raw::c_int, diff --git a/libsqlite3-sys/sqlite3/sqlite3.c b/libsqlite3-sys/sqlite3/sqlite3.c index dd3b5c5..310583f 100644 --- a/libsqlite3-sys/sqlite3/sqlite3.c +++ b/libsqlite3-sys/sqlite3/sqlite3.c @@ -1,6 +1,6 @@ /****************************************************************************** ** This file is an amalgamation of many separate C source files from SQLite -** version 3.42.0. By combining all the individual C code files into this +** version 3.43.0. By combining all the individual C code files into this ** single large file, the entire code can be compiled as a single translation ** unit. This allows many compilers to do optimizations that would not be ** possible if the files were compiled separately. Performance improvements @@ -16,6 +16,9 @@ ** if you want a wrapper to interface SQLite with your choice of programming ** language. The code for the "sqlite3" command-line shell is also in a ** separate file. This file contains only code for the core SQLite library. +** +** The content in this amalgamation comes from Fossil check-in +** f80b798b3f4b81a7bb4233c58294edd0f11. */ #define SQLITE_CORE 1 #define SQLITE_AMALGAMATION 1 @@ -50,11 +53,11 @@ ** used on lines of code that actually ** implement parts of coverage testing. ** -** OPTIMIZATION-IF-TRUE - This branch is allowed to alway be false +** OPTIMIZATION-IF-TRUE - This branch is allowed to always be false ** and the correct answer is still obtained, ** though perhaps more slowly. ** -** OPTIMIZATION-IF-FALSE - This branch is allowed to alway be true +** OPTIMIZATION-IF-FALSE - This branch is allowed to always be true ** and the correct answer is still obtained, ** though perhaps more slowly. ** @@ -456,9 +459,9 @@ extern "C" { ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ -#define SQLITE_VERSION "3.42.0" -#define SQLITE_VERSION_NUMBER 3042000 -#define SQLITE_SOURCE_ID "2023-05-16 12:36:15 831d0fb2836b71c9bc51067c49fee4b8f18047814f2ff22d817d25195cf350b0" +#define SQLITE_VERSION "3.43.0" +#define SQLITE_VERSION_NUMBER 3043000 +#define SQLITE_SOURCE_ID "2023-08-24 12:36:59 0f80b798b3f4b81a7bb4233c58294edd0f1156f36b6ecf5ab8e83631d468778c" /* ** CAPI3REF: Run-Time Library Version Numbers @@ -838,6 +841,7 @@ SQLITE_API int sqlite3_exec( #define SQLITE_IOERR_ROLLBACK_ATOMIC (SQLITE_IOERR | (31<<8)) #define SQLITE_IOERR_DATA (SQLITE_IOERR | (32<<8)) #define SQLITE_IOERR_CORRUPTFS (SQLITE_IOERR | (33<<8)) +#define SQLITE_IOERR_IN_PAGE (SQLITE_IOERR | (34<<8)) #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8)) #define SQLITE_LOCKED_VTAB (SQLITE_LOCKED | (2<<8)) #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8)) @@ -1500,7 +1504,7 @@ struct sqlite3_io_methods { ** by clients within the current process, only within other processes. ** **
  • [[SQLITE_FCNTL_CKSM_FILE]] -** The [SQLITE_FCNTL_CKSM_FILE] opcode is for use interally by the +** The [SQLITE_FCNTL_CKSM_FILE] opcode is for use internally by the ** [checksum VFS shim] only. ** **
  • [[SQLITE_FCNTL_RESET_CACHE]] @@ -2764,7 +2768,7 @@ struct sqlite3_mem_methods { ** the [VACUUM] command will fail with an obscure error when attempting to ** process a table with generated columns and a descending index. This is ** not considered a bug since SQLite versions 3.3.0 and earlier do not support -** either generated columns or decending indexes. +** either generated columns or descending indexes. ** ** ** [[SQLITE_DBCONFIG_STMT_SCANSTATUS]] @@ -3045,6 +3049,7 @@ SQLITE_API sqlite3_int64 sqlite3_total_changes64(sqlite3*); ** ** ^The [sqlite3_is_interrupted(D)] interface can be used to determine whether ** or not an interrupt is currently in effect for [database connection] D. +** It returns 1 if an interrupt is currently in effect, or 0 otherwise. */ SQLITE_API void sqlite3_interrupt(sqlite3*); SQLITE_API int sqlite3_is_interrupted(sqlite3*); @@ -3698,8 +3703,10 @@ SQLITE_API SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, ** M argument should be the bitwise OR-ed combination of ** zero or more [SQLITE_TRACE] constants. ** -** ^Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides -** (cancels) any prior calls to sqlite3_trace() or sqlite3_trace_v2(). +** ^Each call to either sqlite3_trace(D,X,P) or sqlite3_trace_v2(D,M,X,P) +** overrides (cancels) all prior calls to sqlite3_trace(D,X,P) or +** sqlite3_trace_v2(D,M,X,P) for the [database connection] D. Each +** database connection may have at most one trace callback. ** ** ^The X callback is invoked whenever any of the events identified by ** mask M occur. ^The integer return value from the callback is currently @@ -4068,7 +4075,7 @@ SQLITE_API int sqlite3_open_v2( ** as F) must be one of: **
      **
    • A database filename pointer created by the SQLite core and -** passed into the xOpen() method of a VFS implemention, or +** passed into the xOpen() method of a VFS implementation, or **
    • A filename obtained from [sqlite3_db_filename()], or **
    • A new filename constructed using [sqlite3_create_filename()]. **
    @@ -4181,7 +4188,7 @@ SQLITE_API sqlite3_file *sqlite3_database_file_object(const char*); /* ** CAPI3REF: Create and Destroy VFS Filenames ** -** These interfces are provided for use by [VFS shim] implementations and +** These interfaces are provided for use by [VFS shim] implementations and ** are not useful outside of that context. ** ** The sqlite3_create_filename(D,J,W,N,P) allocates memory to hold a version of @@ -4728,6 +4735,41 @@ SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); */ SQLITE_API int sqlite3_stmt_isexplain(sqlite3_stmt *pStmt); +/* +** CAPI3REF: Change The EXPLAIN Setting For A Prepared Statement +** METHOD: sqlite3_stmt +** +** The sqlite3_stmt_explain(S,E) interface changes the EXPLAIN +** setting for [prepared statement] S. If E is zero, then S becomes +** a normal prepared statement. If E is 1, then S behaves as if +** its SQL text began with "[EXPLAIN]". If E is 2, then S behaves as if +** its SQL text began with "[EXPLAIN QUERY PLAN]". +** +** Calling sqlite3_stmt_explain(S,E) might cause S to be reprepared. +** SQLite tries to avoid a reprepare, but a reprepare might be necessary +** on the first transition into EXPLAIN or EXPLAIN QUERY PLAN mode. +** +** Because of the potential need to reprepare, a call to +** sqlite3_stmt_explain(S,E) will fail with SQLITE_ERROR if S cannot be +** reprepared because it was created using [sqlite3_prepare()] instead of +** the newer [sqlite3_prepare_v2()] or [sqlite3_prepare_v3()] interfaces and +** hence has no saved SQL text with which to reprepare. +** +** Changing the explain setting for a prepared statement does not change +** the original SQL text for the statement. Hence, if the SQL text originally +** began with EXPLAIN or EXPLAIN QUERY PLAN, but sqlite3_stmt_explain(S,0) +** is called to convert the statement into an ordinary statement, the EXPLAIN +** or EXPLAIN QUERY PLAN keywords will still appear in the sqlite3_sql(S) +** output, even though the statement now acts like a normal SQL statement. +** +** This routine returns SQLITE_OK if the explain mode is successfully +** changed, or an error code if the explain mode could not be changed. +** The explain mode cannot be changed while a statement is active. +** Hence, it is good practice to call [sqlite3_reset(S)] +** immediately prior to calling sqlite3_stmt_explain(S,E). +*/ +SQLITE_API int sqlite3_stmt_explain(sqlite3_stmt *pStmt, int eMode); + /* ** CAPI3REF: Determine If A Prepared Statement Has Been Reset ** METHOD: sqlite3_stmt @@ -4891,7 +4933,7 @@ typedef struct sqlite3_context sqlite3_context; ** with it may be passed. ^It is called to dispose of the BLOB or string even ** if the call to the bind API fails, except the destructor is not called if ** the third parameter is a NULL pointer or the fourth parameter is negative. -** ^ (2) The special constant, [SQLITE_STATIC], may be passsed to indicate that +** ^ (2) The special constant, [SQLITE_STATIC], may be passed to indicate that ** the application remains responsible for disposing of the object. ^In this ** case, the object and the provided pointer to it must remain valid until ** either the prepared statement is finalized or the same SQL parameter is @@ -5570,14 +5612,26 @@ SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt); ** ^The [sqlite3_reset(S)] interface resets the [prepared statement] S ** back to the beginning of its program. ** -** ^If the most recent call to [sqlite3_step(S)] for the -** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE], -** or if [sqlite3_step(S)] has never before been called on S, -** then [sqlite3_reset(S)] returns [SQLITE_OK]. +** ^The return code from [sqlite3_reset(S)] indicates whether or not +** the previous evaluation of prepared statement S completed successfully. +** ^If [sqlite3_step(S)] has never before been called on S or if +** [sqlite3_step(S)] has not been called since the previous call +** to [sqlite3_reset(S)], then [sqlite3_reset(S)] will return +** [SQLITE_OK]. ** ** ^If the most recent call to [sqlite3_step(S)] for the ** [prepared statement] S indicated an error, then ** [sqlite3_reset(S)] returns an appropriate [error code]. +** ^The [sqlite3_reset(S)] interface might also return an [error code] +** if there were no prior errors but the process of resetting +** the prepared statement caused a new error. ^For example, if an +** [INSERT] statement with a [RETURNING] clause is only stepped one time, +** that one call to [sqlite3_step(S)] might return SQLITE_ROW but +** the overall statement might still fail and the [sqlite3_reset(S)] call +** might return SQLITE_BUSY if locking constraints prevent the +** database change from committing. Therefore, it is important that +** applications check the return code from [sqlite3_reset(S)] even if +** no prior call to [sqlite3_step(S)] indicated a problem. ** ** ^The [sqlite3_reset(S)] interface does not change the values ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S. @@ -5794,7 +5848,7 @@ SQLITE_API int sqlite3_create_window_function( ** [application-defined SQL function] ** that has side-effects or that could potentially leak sensitive information. ** This will prevent attacks in which an application is tricked -** into using a database file that has had its schema surreptiously +** into using a database file that has had its schema surreptitiously ** modified to invoke the application-defined function in ways that are ** harmful. **

    @@ -8471,7 +8525,8 @@ SQLITE_API int sqlite3_test_control(int op, ...); #define SQLITE_TESTCTRL_TRACEFLAGS 31 #define SQLITE_TESTCTRL_TUNE 32 #define SQLITE_TESTCTRL_LOGEST 33 -#define SQLITE_TESTCTRL_LAST 33 /* Largest TESTCTRL */ +#define SQLITE_TESTCTRL_USELONGDOUBLE 34 +#define SQLITE_TESTCTRL_LAST 34 /* Largest TESTCTRL */ /* ** CAPI3REF: SQL Keyword Checking @@ -9503,8 +9558,8 @@ SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p); ** blocked connection already has a registered unlock-notify callback, ** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is ** called with a NULL pointer as its second argument, then any existing -** unlock-notify callback is canceled. ^The blocked connections -** unlock-notify callback may also be canceled by closing the blocked +** unlock-notify callback is cancelled. ^The blocked connections +** unlock-notify callback may also be cancelled by closing the blocked ** connection using [sqlite3_close()]. ** ** The unlock-notify callback is not reentrant. If an application invokes @@ -9927,7 +9982,7 @@ SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...); ** [[SQLITE_VTAB_DIRECTONLY]]

    SQLITE_VTAB_DIRECTONLY
    **
    Calls of the form ** [sqlite3_vtab_config](db,SQLITE_VTAB_DIRECTONLY) from within the -** the [xConnect] or [xCreate] methods of a [virtual table] implmentation +** the [xConnect] or [xCreate] methods of a [virtual table] implementation ** prohibits that virtual table from being used from within triggers and ** views. **
    @@ -10117,7 +10172,7 @@ SQLITE_API int sqlite3_vtab_distinct(sqlite3_index_info*); ** communicated to the xBestIndex method as a ** [SQLITE_INDEX_CONSTRAINT_EQ] constraint.)^ If xBestIndex wants to use ** this constraint, it must set the corresponding -** aConstraintUsage[].argvIndex to a postive integer. ^(Then, under +** aConstraintUsage[].argvIndex to a positive integer. ^(Then, under ** the usual mode of handling IN operators, SQLite generates [bytecode] ** that invokes the [xFilter|xFilter() method] once for each value ** on the right-hand side of the IN operator.)^ Thus the virtual table @@ -10546,7 +10601,7 @@ SQLITE_API int sqlite3_db_cacheflush(sqlite3*); ** When the [sqlite3_blob_write()] API is used to update a blob column, ** the pre-update hook is invoked with SQLITE_DELETE. This is because the ** in this case the new values are not available. In this case, when a -** callback made with op==SQLITE_DELETE is actuall a write using the +** callback made with op==SQLITE_DELETE is actually a write using the ** sqlite3_blob_write() API, the [sqlite3_preupdate_blobwrite()] returns ** the index of the column being written. In other cases, where the ** pre-update hook is being invoked for some other reason, including a @@ -13064,7 +13119,7 @@ struct Fts5PhraseIter { ** See xPhraseFirstColumn above. */ struct Fts5ExtensionApi { - int iVersion; /* Currently always set to 3 */ + int iVersion; /* Currently always set to 2 */ void *(*xUserData)(Fts5Context*); @@ -13293,8 +13348,8 @@ struct Fts5ExtensionApi { ** as separate queries of the FTS index are required for each synonym. ** ** When using methods (2) or (3), it is important that the tokenizer only -** provide synonyms when tokenizing document text (method (2)) or query -** text (method (3)), not both. Doing so will not cause any errors, but is +** provide synonyms when tokenizing document text (method (3)) or query +** text (method (2)), not both. Doing so will not cause any errors, but is ** inefficient. */ typedef struct Fts5Tokenizer Fts5Tokenizer; @@ -13342,7 +13397,7 @@ struct fts5_api { int (*xCreateTokenizer)( fts5_api *pApi, const char *zName, - void *pContext, + void *pUserData, fts5_tokenizer *pTokenizer, void (*xDestroy)(void*) ); @@ -13351,7 +13406,7 @@ struct fts5_api { int (*xFindTokenizer)( fts5_api *pApi, const char *zName, - void **ppContext, + void **ppUserData, fts5_tokenizer *pTokenizer ); @@ -13359,7 +13414,7 @@ struct fts5_api { int (*xCreateFunction)( fts5_api *pApi, const char *zName, - void *pContext, + void *pUserData, fts5_extension_function xFunction, void (*xDestroy)(void*) ); @@ -13470,7 +13525,7 @@ struct fts5_api { ** level of recursion for each term. A stack overflow can result ** if the number of terms is too large. In practice, most SQL ** never has more than 3 or 4 terms. Use a value of 0 to disable -** any limit on the number of terms in a compount SELECT. +** any limit on the number of terms in a compound SELECT. */ #ifndef SQLITE_MAX_COMPOUND_SELECT # define SQLITE_MAX_COMPOUND_SELECT 500 @@ -14573,8 +14628,31 @@ typedef INT16_TYPE LogEst; ** the end of buffer S. This macro returns true if P points to something ** contained within the buffer S. */ -#define SQLITE_WITHIN(P,S,E) (((uptr)(P)>=(uptr)(S))&&((uptr)(P)<(uptr)(E))) +#define SQLITE_WITHIN(P,S,E) (((uptr)(P)>=(uptr)(S))&&((uptr)(P)<(uptr)(E))) +/* +** P is one byte past the end of a large buffer. Return true if a span of bytes +** between S..E crosses the end of that buffer. In other words, return true +** if the sub-buffer S..E-1 overflows the buffer whose last byte is P-1. +** +** S is the start of the span. E is one byte past the end of end of span. +** +** P +** |-----------------| FALSE +** |-------| +** S E +** +** P +** |-----------------| +** |-------| TRUE +** S E +** +** P +** |-----------------| +** |-------| FALSE +** S E +*/ +#define SQLITE_OVERFLOW(P,S,E) (((uptr)(S)<(uptr)(P))&&((uptr)(E)>(uptr)(P))) /* ** Macros to determine whether the machine is big or little endian, @@ -14808,7 +14886,7 @@ struct BusyHandler { /* ** Name of table that holds the database schema. ** -** The PREFERRED names are used whereever possible. But LEGACY is also +** The PREFERRED names are used wherever possible. But LEGACY is also ** used for backwards compatibility. ** ** 1. Queries can use either the PREFERRED or the LEGACY names @@ -14922,6 +15000,7 @@ typedef struct Schema Schema; typedef struct Expr Expr; typedef struct ExprList ExprList; typedef struct FKey FKey; +typedef struct FpDecode FpDecode; typedef struct FuncDestructor FuncDestructor; typedef struct FuncDef FuncDef; typedef struct FuncDefHash FuncDefHash; @@ -14940,6 +15019,7 @@ typedef struct Parse Parse; typedef struct ParseCleanup ParseCleanup; typedef struct PreUpdate PreUpdate; typedef struct PrintfArguments PrintfArguments; +typedef struct RCStr RCStr; typedef struct RenameToken RenameToken; typedef struct Returning Returning; typedef struct RowSet RowSet; @@ -15577,6 +15657,10 @@ SQLITE_PRIVATE void sqlite3PagerRefdump(Pager*); # define enable_simulated_io_errors() #endif +#if defined(SQLITE_USE_SEH) && !defined(SQLITE_OMIT_WAL) +SQLITE_PRIVATE int sqlite3PagerWalSystemErrno(Pager*); +#endif + #endif /* SQLITE_PAGER_H */ /************** End of pager.h ***********************************************/ @@ -15906,9 +15990,7 @@ SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor*, int flags); SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor*); SQLITE_PRIVATE void sqlite3BtreeCursorPin(BtCursor*); SQLITE_PRIVATE void sqlite3BtreeCursorUnpin(BtCursor*); -#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC SQLITE_PRIVATE i64 sqlite3BtreeOffset(BtCursor*); -#endif SQLITE_PRIVATE int sqlite3BtreePayload(BtCursor*, u32 offset, u32 amt, void*); SQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt); SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor*); @@ -16383,7 +16465,7 @@ typedef struct VdbeOpList VdbeOpList; /* 8 */ 0x01, 0x01, 0x01, 0x01, 0x03, 0x03, 0x01, 0x01,\ /* 16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0x49, 0x49, 0x49,\ /* 24 */ 0x49, 0x01, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49,\ -/* 32 */ 0x41, 0x01, 0x01, 0x01, 0x41, 0x01, 0x41, 0x41,\ +/* 32 */ 0x41, 0x01, 0x41, 0x41, 0x41, 0x01, 0x41, 0x41,\ /* 40 */ 0x41, 0x41, 0x41, 0x26, 0x26, 0x41, 0x23, 0x0b,\ /* 48 */ 0x01, 0x01, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\ /* 56 */ 0x0b, 0x0b, 0x01, 0x03, 0x03, 0x03, 0x01, 0x41,\ @@ -16395,7 +16477,7 @@ typedef struct VdbeOpList VdbeOpList; /* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,\ /* 112 */ 0x40, 0x00, 0x12, 0x40, 0x40, 0x10, 0x40, 0x00,\ /* 120 */ 0x00, 0x00, 0x40, 0x00, 0x40, 0x40, 0x10, 0x10,\ -/* 128 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50,\ +/* 128 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x50,\ /* 136 */ 0x00, 0x40, 0x04, 0x04, 0x00, 0x40, 0x50, 0x40,\ /* 144 */ 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\ /* 152 */ 0x00, 0x10, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04,\ @@ -16577,7 +16659,7 @@ SQLITE_PRIVATE void sqlite3VdbeNoopComment(Vdbe*, const char*, ...); ** The VdbeCoverage macros are used to set a coverage testing point ** for VDBE branch instructions. The coverage testing points are line ** numbers in the sqlite3.c source file. VDBE branch coverage testing -** only works with an amalagmation build. That's ok since a VDBE branch +** only works with an amalgamation build. That's ok since a VDBE branch ** coverage build designed for testing the test suite only. No application ** should ever ship with VDBE branch coverage measuring turned on. ** @@ -16595,7 +16677,7 @@ SQLITE_PRIVATE void sqlite3VdbeNoopComment(Vdbe*, const char*, ...); ** // NULL option is not possible ** ** VdbeCoverageEqNe(v) // Previous OP_Jump is only interested -** // in distingishing equal and not-equal. +** // in distinguishing equal and not-equal. ** ** Every VDBE branch operation must be tagged with one of the macros above. ** If not, then when "make test" is run with -DSQLITE_VDBE_COVERAGE and @@ -16605,7 +16687,7 @@ SQLITE_PRIVATE void sqlite3VdbeNoopComment(Vdbe*, const char*, ...); ** During testing, the test application will invoke ** sqlite3_test_control(SQLITE_TESTCTRL_VDBE_COVERAGE,...) to set a callback ** routine that is invoked as each bytecode branch is taken. The callback -** contains the sqlite3.c source line number ov the VdbeCoverage macro and +** contains the sqlite3.c source line number of the VdbeCoverage macro and ** flags to indicate whether or not the branch was taken. The test application ** is responsible for keeping track of this and reporting byte-code branches ** that are never taken. @@ -16944,7 +17026,7 @@ SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*); /* ** Default synchronous levels. ** -** Note that (for historcal reasons) the PAGER_SYNCHRONOUS_* macros differ +** Note that (for historical reasons) the PAGER_SYNCHRONOUS_* macros differ ** from the SQLITE_DEFAULT_SYNCHRONOUS value by 1. ** ** PAGER_SYNCHRONOUS DEFAULT_SYNCHRONOUS @@ -16983,7 +17065,7 @@ struct Db { ** An instance of the following structure stores a database schema. ** ** Most Schema objects are associated with a Btree. The exception is -** the Schema for the TEMP databaes (sqlite3.aDb[1]) which is free-standing. +** the Schema for the TEMP database (sqlite3.aDb[1]) which is free-standing. ** In shared cache mode, a single Schema object can be shared by multiple ** Btrees that refer to the same underlying BtShared object. ** @@ -17094,7 +17176,7 @@ struct Lookaside { LookasideSlot *pInit; /* List of buffers not previously used */ LookasideSlot *pFree; /* List of available buffers */ #ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE - LookasideSlot *pSmallInit; /* List of small buffers not prediously used */ + LookasideSlot *pSmallInit; /* List of small buffers not previously used */ LookasideSlot *pSmallFree; /* List of available small buffers */ void *pMiddle; /* First byte past end of full-size buffers and ** the first byte of LOOKASIDE_SMALL buffers */ @@ -17111,7 +17193,7 @@ struct LookasideSlot { #define EnableLookaside db->lookaside.bDisable--;\ db->lookaside.sz=db->lookaside.bDisable?0:db->lookaside.szTrue -/* Size of the smaller allocations in two-size lookside */ +/* Size of the smaller allocations in two-size lookaside */ #ifdef SQLITE_OMIT_TWOSIZE_LOOKASIDE # define LOOKASIDE_SMALL 0 #else @@ -17450,6 +17532,7 @@ struct sqlite3 { #define SQLITE_IndexedExpr 0x01000000 /* Pull exprs from index when able */ #define SQLITE_Coroutines 0x02000000 /* Co-routines for subqueries */ #define SQLITE_NullUnusedCols 0x04000000 /* NULL unused columns in subqueries */ +#define SQLITE_OnePass 0x08000000 /* Single-pass DELETE and UPDATE */ #define SQLITE_AllOpts 0xffffffff /* All optimizations */ /* @@ -17532,6 +17615,7 @@ struct FuncDestructor { ** SQLITE_FUNC_ANYORDER == NC_OrderAgg == SF_OrderByReqd ** SQLITE_FUNC_LENGTH == OPFLAG_LENGTHARG ** SQLITE_FUNC_TYPEOF == OPFLAG_TYPEOFARG +** SQLITE_FUNC_BYTELEN == OPFLAG_BYTELENARG ** SQLITE_FUNC_CONSTANT == SQLITE_DETERMINISTIC from the API ** SQLITE_FUNC_DIRECT == SQLITE_DIRECTONLY from the API ** SQLITE_FUNC_UNSAFE == SQLITE_INNOCUOUS -- opposite meanings!!! @@ -17539,7 +17623,7 @@ struct FuncDestructor { ** ** Note that even though SQLITE_FUNC_UNSAFE and SQLITE_INNOCUOUS have the ** same bit value, their meanings are inverted. SQLITE_FUNC_UNSAFE is -** used internally and if set means tha the function has side effects. +** used internally and if set means that the function has side effects. ** SQLITE_INNOCUOUS is used by application code and means "not unsafe". ** See multiple instances of tag-20230109-1. */ @@ -17550,6 +17634,7 @@ struct FuncDestructor { #define SQLITE_FUNC_NEEDCOLL 0x0020 /* sqlite3GetFuncCollSeq() might be called*/ #define SQLITE_FUNC_LENGTH 0x0040 /* Built-in length() function */ #define SQLITE_FUNC_TYPEOF 0x0080 /* Built-in typeof() function */ +#define SQLITE_FUNC_BYTELEN 0x00c0 /* Built-in octet_length() function */ #define SQLITE_FUNC_COUNT 0x0100 /* Built-in count(*) aggregate */ /* 0x0200 -- available for reuse */ #define SQLITE_FUNC_UNLIKELY 0x0400 /* Built-in unlikely() function */ @@ -18129,7 +18214,7 @@ struct FKey { ** foreign key. ** ** The OE_Default value is a place holder that means to use whatever -** conflict resolution algorthm is required from context. +** conflict resolution algorithm is required from context. ** ** The following symbolic values are used to record which type ** of conflict resolution action to take. @@ -18543,7 +18628,7 @@ struct Expr { ** TK_REGISTER: register number ** TK_TRIGGER: 1 -> new, 0 -> old ** EP_Unlikely: 134217728 times likelihood - ** TK_IN: ephemerial table holding RHS + ** TK_IN: ephemeral table holding RHS ** TK_SELECT_COLUMN: Number of columns on the LHS ** TK_SELECT: 1st register of result vector */ ynVar iColumn; /* TK_COLUMN: column index. -1 for rowid. @@ -18625,6 +18710,8 @@ struct Expr { */ #define ExprUseUToken(E) (((E)->flags&EP_IntValue)==0) #define ExprUseUValue(E) (((E)->flags&EP_IntValue)!=0) +#define ExprUseWOfst(E) (((E)->flags&(EP_InnerON|EP_OuterON))==0) +#define ExprUseWJoin(E) (((E)->flags&(EP_InnerON|EP_OuterON))!=0) #define ExprUseXList(E) (((E)->flags&EP_xIsSelect)==0) #define ExprUseXSelect(E) (((E)->flags&EP_xIsSelect)!=0) #define ExprUseYTab(E) (((E)->flags&(EP_WinFunc|EP_Subrtn))==0) @@ -18813,7 +18900,7 @@ struct SrcItem { unsigned notCte :1; /* This item may not match a CTE */ unsigned isUsing :1; /* u3.pUsing is valid */ unsigned isOn :1; /* u3.pOn was once valid and non-NULL */ - unsigned isSynthUsing :1; /* u3.pUsing is synthensized from NATURAL */ + unsigned isSynthUsing :1; /* u3.pUsing is synthesized from NATURAL */ unsigned isNestedFrom :1; /* pSelect is a SF_NestedFrom subquery */ } fg; int iCursor; /* The VDBE cursor number used to access this table */ @@ -19349,6 +19436,9 @@ struct Parse { int regRoot; /* Register holding root page number for new objects */ int nMaxArg; /* Max args passed to user function by sub-program */ int nSelect; /* Number of SELECT stmts. Counter for Select.selId */ +#ifndef SQLITE_OMIT_PROGRESS_CALLBACK + u32 nProgressSteps; /* xProgress steps taken during sqlite3_prepare() */ +#endif #ifndef SQLITE_OMIT_SHARED_CACHE int nTableLock; /* Number of locks in aTableLock */ TableLock *aTableLock; /* Required table locks for shared-cache mode */ @@ -19362,12 +19452,9 @@ struct Parse { int addrCrTab; /* Address of OP_CreateBtree on CREATE TABLE */ Returning *pReturning; /* The RETURNING clause */ } u1; - u32 nQueryLoop; /* Est number of iterations of a query (10*log2(N)) */ u32 oldmask; /* Mask of old.* columns referenced */ u32 newmask; /* Mask of new.* columns referenced */ -#ifndef SQLITE_OMIT_PROGRESS_CALLBACK - u32 nProgressSteps; /* xProgress steps taken during sqlite3_prepare() */ -#endif + LogEst nQueryLoop; /* Est number of iterations of a query (10*log2(N)) */ u8 eTriggerOp; /* TK_UPDATE, TK_INSERT or TK_DELETE */ u8 bReturning; /* Coding a RETURNING trigger */ u8 eOrconf; /* Default ON CONFLICT policy for trigger steps */ @@ -19491,6 +19578,7 @@ struct AuthContext { #define OPFLAG_ISNOOP 0x40 /* OP_Delete does pre-update-hook only */ #define OPFLAG_LENGTHARG 0x40 /* OP_Column only used for length() */ #define OPFLAG_TYPEOFARG 0x80 /* OP_Column only used for typeof() */ +#define OPFLAG_BYTELENARG 0xc0 /* OP_Column only for octet_length() */ #define OPFLAG_BULKCSR 0x01 /* OP_Open** used to open bulk cursor */ #define OPFLAG_SEEKEQ 0x02 /* OP_Open** cursor uses EQ seek only */ #define OPFLAG_FORDELETE 0x08 /* OP_Open should use BTREE_FORDELETE */ @@ -19633,6 +19721,25 @@ struct sqlite3_str { #define isMalloced(X) (((X)->printfFlags & SQLITE_PRINTF_MALLOCED)!=0) +/* +** The following object is the header for an "RCStr" or "reference-counted +** string". An RCStr is passed around and used like any other char* +** that has been dynamically allocated. The important interface +** differences: +** +** 1. RCStr strings are reference counted. They are deallocated +** when the reference count reaches zero. +** +** 2. Use sqlite3RCStrUnref() to free an RCStr string rather than +** sqlite3_free() +** +** 3. Make a (read-only) copy of a read-only RCStr string using +** sqlite3RCStrRef(). +*/ +struct RCStr { + u64 nRCRef; /* Number of references */ + /* Total structure size should be a multiple of 8 bytes for alignment */ +}; /* ** A pointer to this structure is used to communicate information @@ -19659,7 +19766,7 @@ typedef struct { /* Tuning parameters are set using SQLITE_TESTCTRL_TUNE and are controlled ** on debug-builds of the CLI using ".testctrl tune ID VALUE". Tuning ** parameters are for temporary use during development, to help find -** optimial values for parameters in the query planner. The should not +** optimal values for parameters in the query planner. The should not ** be used on trunk check-ins. They are a temporary mechanism available ** for transient development builds only. ** @@ -19685,6 +19792,7 @@ struct Sqlite3Config { u8 bUseCis; /* Use covering indices for full-scans */ u8 bSmallMalloc; /* Avoid large memory allocations if true */ u8 bExtraSchemaChecks; /* Verify type,name,tbl_name in schema */ + u8 bUseLongDouble; /* Make use of long double */ int mxStrlen; /* Maximum string length */ int neverCorrupt; /* Database is always well-formed */ int szLookaside; /* Default lookaside buffer size */ @@ -19771,6 +19879,7 @@ struct Walker { void (*xSelectCallback2)(Walker*,Select*);/* Second callback for SELECTs */ int walkerDepth; /* Number of subqueries */ u16 eCode; /* A small processing code */ + u16 mWFlags; /* Use-dependent flags */ union { /* Extra data for callback */ NameContext *pNC; /* Naming context */ int n; /* A counter */ @@ -19810,6 +19919,7 @@ struct DbFixer { /* Forward declarations */ SQLITE_PRIVATE int sqlite3WalkExpr(Walker*, Expr*); +SQLITE_PRIVATE int sqlite3WalkExprNN(Walker*, Expr*); SQLITE_PRIVATE int sqlite3WalkExprList(Walker*, ExprList*); SQLITE_PRIVATE int sqlite3WalkSelect(Walker*, Select*); SQLITE_PRIVATE int sqlite3WalkSelectExpr(Walker*, Select*); @@ -20191,6 +20301,20 @@ struct PrintfArguments { sqlite3_value **apArg; /* The argument values */ }; +/* +** An instance of this object receives the decoding of a floating point +** value into an approximate decimal representation. +*/ +struct FpDecode { + char sign; /* '+' or '-' */ + char isSpecial; /* 1: Infinity 2: NaN */ + int n; /* Significant digits in the decode */ + int iDP; /* Location of the decimal point */ + char *z; /* Start of significant digits */ + char zBuf[24]; /* Storage for significant digits */ +}; + +SQLITE_PRIVATE void sqlite3FpDecode(FpDecode*,double,int,int); SQLITE_PRIVATE char *sqlite3MPrintf(sqlite3*,const char*, ...); SQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3*,const char*, va_list); #if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE) @@ -20481,7 +20605,7 @@ SQLITE_PRIVATE int sqlite3ExprCompare(const Parse*,const Expr*,const Expr*, int) SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr*,Expr*,int); SQLITE_PRIVATE int sqlite3ExprListCompare(const ExprList*,const ExprList*, int); SQLITE_PRIVATE int sqlite3ExprImpliesExpr(const Parse*,const Expr*,const Expr*, int); -SQLITE_PRIVATE int sqlite3ExprImpliesNonNullRow(Expr*,int); +SQLITE_PRIVATE int sqlite3ExprImpliesNonNullRow(Expr*,int,int); SQLITE_PRIVATE void sqlite3AggInfoPersistWalkerInit(Walker*,Parse*); SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*); SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*); @@ -20630,6 +20754,7 @@ SQLITE_PRIVATE int sqlite3FixSrcList(DbFixer*, SrcList*); SQLITE_PRIVATE int sqlite3FixSelect(DbFixer*, Select*); SQLITE_PRIVATE int sqlite3FixExpr(DbFixer*, Expr*); SQLITE_PRIVATE int sqlite3FixTriggerStep(DbFixer*, TriggerStep*); + SQLITE_PRIVATE int sqlite3RealSameAsInt(double,sqlite3_int64); SQLITE_PRIVATE i64 sqlite3RealToI64(double); SQLITE_PRIVATE int sqlite3Int64ToText(i64,char*); @@ -20734,6 +20859,7 @@ SQLITE_PRIVATE void sqlite3FileSuffix3(const char*, char*); SQLITE_PRIVATE u8 sqlite3GetBoolean(const char *z,u8); SQLITE_PRIVATE const void *sqlite3ValueText(sqlite3_value*, u8); +SQLITE_PRIVATE int sqlite3ValueIsOfClass(const sqlite3_value*, void(*)(void*)); SQLITE_PRIVATE int sqlite3ValueBytes(sqlite3_value*, u8); SQLITE_PRIVATE void sqlite3ValueSetStr(sqlite3_value*, int, const void *,u8, void(*)(void*)); @@ -20841,6 +20967,11 @@ SQLITE_PRIVATE void sqlite3OomClear(sqlite3*); SQLITE_PRIVATE int sqlite3ApiExit(sqlite3 *db, int); SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *); +SQLITE_PRIVATE char *sqlite3RCStrRef(char*); +SQLITE_PRIVATE void sqlite3RCStrUnref(char*); +SQLITE_PRIVATE char *sqlite3RCStrNew(u64); +SQLITE_PRIVATE char *sqlite3RCStrResize(char*,u64); + SQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum*, sqlite3*, char*, int, int); SQLITE_PRIVATE int sqlite3StrAccumEnlarge(StrAccum*, i64); SQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum*); @@ -21092,6 +21223,7 @@ SQLITE_PRIVATE int sqlite3ExprCheckHeight(Parse*, int); #define sqlite3SelectExprHeight(x) 0 #define sqlite3ExprCheckHeight(x,y) #endif +SQLITE_PRIVATE void sqlite3ExprSetErrorOffset(Expr*,int); SQLITE_PRIVATE u32 sqlite3Get4byte(const u8*); SQLITE_PRIVATE void sqlite3Put4byte(u8*, u32); @@ -21377,9 +21509,6 @@ static const char * const sqlite3azCompileOpt[] = { #ifdef SQLITE_4_BYTE_ALIGNED_MALLOC "4_BYTE_ALIGNED_MALLOC", #endif -#ifdef SQLITE_64BIT_STATS - "64BIT_STATS", -#endif #ifdef SQLITE_ALLOW_COVERING_INDEX_SCAN # if SQLITE_ALLOW_COVERING_INDEX_SCAN != 1 "ALLOW_COVERING_INDEX_SCAN=" CTIMEOPT_VAL(SQLITE_ALLOW_COVERING_INDEX_SCAN), @@ -21716,6 +21845,9 @@ static const char * const sqlite3azCompileOpt[] = { #ifdef SQLITE_INTEGRITY_CHECK_ERROR_MAX "INTEGRITY_CHECK_ERROR_MAX=" CTIMEOPT_VAL(SQLITE_INTEGRITY_CHECK_ERROR_MAX), #endif +#ifdef SQLITE_LEGACY_JSON_VALID + "LEGACY_JSON_VALID", +#endif #ifdef SQLITE_LIKE_DOESNT_MATCH_BLOBS "LIKE_DOESNT_MATCH_BLOBS", #endif @@ -22350,6 +22482,7 @@ SQLITE_PRIVATE SQLITE_WSD struct Sqlite3Config sqlite3Config = { SQLITE_ALLOW_COVERING_INDEX_SCAN, /* bUseCis */ 0, /* bSmallMalloc */ 1, /* bExtraSchemaChecks */ + sizeof(LONGDOUBLE_TYPE)>8, /* bUseLongDouble */ 0x7ffffffe, /* mxStrlen */ 0, /* neverCorrupt */ SQLITE_DEFAULT_LOOKASIDE, /* szLookaside, nLookaside */ @@ -22579,6 +22712,9 @@ typedef struct VdbeSorter VdbeSorter; /* Elements of the linked list at Vdbe.pAuxData */ typedef struct AuxData AuxData; +/* A cache of large TEXT or BLOB values in a VdbeCursor */ +typedef struct VdbeTxtBlbCache VdbeTxtBlbCache; + /* Types of VDBE cursors */ #define CURTYPE_BTREE 0 #define CURTYPE_SORTER 1 @@ -22610,6 +22746,7 @@ struct VdbeCursor { Bool useRandomRowid:1; /* Generate new record numbers semi-randomly */ Bool isOrdered:1; /* True if the table is not BTREE_UNORDERED */ Bool noReuse:1; /* OpenEphemeral may not reuse this cursor */ + Bool colCache:1; /* pCache pointer is initialized and non-NULL */ u16 seekHit; /* See the OP_SeekHit and OP_IfNoHope opcodes */ union { /* pBtx for isEphermeral. pAltMap otherwise */ Btree *pBtx; /* Separate file holding temporary table */ @@ -22650,6 +22787,7 @@ struct VdbeCursor { #ifdef SQLITE_ENABLE_COLUMN_USED_MASK u64 maskUsed; /* Mask of columns used by this cursor */ #endif + VdbeTxtBlbCache *pCache; /* Cache of large TEXT or BLOB values */ /* 2*nField extra array elements allocated for aType[], beyond the one ** static element declared in the structure. nField total array slots for @@ -22662,12 +22800,25 @@ struct VdbeCursor { #define IsNullCursor(P) \ ((P)->eCurType==CURTYPE_PSEUDO && (P)->nullRow && (P)->seekResult==0) - /* ** A value for VdbeCursor.cacheStatus that means the cache is always invalid. */ #define CACHE_STALE 0 +/* +** Large TEXT or BLOB values can be slow to load, so we want to avoid +** loading them more than once. For that reason, large TEXT and BLOB values +** can be stored in a cache defined by this object, and attached to the +** VdbeCursor using the pCache field. +*/ +struct VdbeTxtBlbCache { + char *pCValue; /* A RCStr buffer to hold the value */ + i64 iOffset; /* File offset of the row being cached */ + int iCol; /* Column for which the cache is valid */ + u32 cacheStatus; /* Vdbe.cacheCtr value */ + u32 colCacheCtr; /* Column cache counter */ +}; + /* ** When a sub-program is executed (OP_Program), a structure of this type ** is allocated to store the current value of the program counter, as @@ -22988,16 +23139,18 @@ struct Vdbe { u32 nWrite; /* Number of write operations that have occurred */ #endif u16 nResColumn; /* Number of columns in one row of the result set */ + u16 nResAlloc; /* Column slots allocated to aColName[] */ u8 errorAction; /* Recovery action to do in case of an error */ u8 minWriteFileFormat; /* Minimum file format for writable database files */ u8 prepFlags; /* SQLITE_PREPARE_* flags */ u8 eVdbeState; /* On of the VDBE_*_STATE values */ bft expired:2; /* 1: recompile VM immediately 2: when convenient */ - bft explain:2; /* True if EXPLAIN present on SQL command */ + bft explain:2; /* 0: normal, 1: EXPLAIN, 2: EXPLAIN QUERY PLAN */ bft changeCntOn:1; /* True to update the change-counter */ bft usesStmtJournal:1; /* True if uses a statement journal */ bft readOnly:1; /* True for statements that do not write */ bft bIsReader:1; /* True for statements that read */ + bft haveEqpOps:1; /* Bytecode supports EXPLAIN QUERY PLAN */ yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */ yDbMask lockMask; /* Subset of btreeMask that requires a lock */ u32 aCounter[9]; /* Counters used by sqlite3_stmt_status() */ @@ -23044,7 +23197,7 @@ struct PreUpdate { i64 iKey1; /* First key value passed to hook */ i64 iKey2; /* Second key value passed to hook */ Mem *aNew; /* Array of new.* values */ - Table *pTab; /* Schema object being upated */ + Table *pTab; /* Schema object being updated */ Index *pPk; /* PK index if pTab is WITHOUT ROWID */ }; @@ -23134,6 +23287,7 @@ SQLITE_PRIVATE int sqlite3VdbeMemSetZeroBlob(Mem*,int); SQLITE_PRIVATE int sqlite3VdbeMemIsRowSet(const Mem*); #endif SQLITE_PRIVATE int sqlite3VdbeMemSetRowSet(Mem*); +SQLITE_PRIVATE void sqlite3VdbeMemZeroTerminateIfAble(Mem*); SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*); SQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem*, u8, u8); SQLITE_PRIVATE int sqlite3IntFloatCompare(i64,double); @@ -23730,8 +23884,8 @@ struct DateTime { */ static int getDigits(const char *zDate, const char *zFormat, ...){ /* The aMx[] array translates the 3rd character of each format - ** spec into a max size: a b c d e f */ - static const u16 aMx[] = { 12, 14, 24, 31, 59, 9999 }; + ** spec into a max size: a b c d e f */ + static const u16 aMx[] = { 12, 14, 24, 31, 59, 14712 }; va_list ap; int cnt = 0; char nextC; @@ -24072,17 +24226,14 @@ static void computeYMD(DateTime *p){ ** Compute the Hour, Minute, and Seconds from the julian day number. */ static void computeHMS(DateTime *p){ - int s; + int day_ms, day_min; /* milliseconds, minutes into the day */ if( p->validHMS ) return; computeJD(p); - s = (int)((p->iJD + 43200000) % 86400000); - p->s = s/1000.0; - s = (int)p->s; - p->s -= s; - p->h = s/3600; - s -= p->h*3600; - p->m = s/60; - p->s += s - p->m*60; + day_ms = (int)((p->iJD + 43200000) % 86400000); + p->s = (day_ms % 60000)/1000.0; + day_min = day_ms/60000; + p->m = day_min % 60; + p->h = day_min / 60; p->rawS = 0; p->validHMS = 1; } @@ -24261,6 +24412,25 @@ static const struct { { 4, "year", 14713.0, 31536000.0 }, }; +/* +** If the DateTime p is raw number, try to figure out if it is +** a julian day number of a unix timestamp. Set the p value +** appropriately. +*/ +static void autoAdjustDate(DateTime *p){ + if( !p->rawS || p->validJD ){ + p->rawS = 0; + }else if( p->s>=-21086676*(i64)10000 /* -4713-11-24 12:00:00 */ + && p->s<=(25340230*(i64)10000)+799 /* 9999-12-31 23:59:59 */ + ){ + double r = p->s*1000.0 + 210866760000000.0; + clearYMD_HMS_TZ(p); + p->iJD = (sqlite3_int64)(r + 0.5); + p->validJD = 1; + p->rawS = 0; + } +} + /* ** Process a modifier to a date-time stamp. The modifiers are ** as follows: @@ -24304,19 +24474,8 @@ static int parseModifier( */ if( sqlite3_stricmp(z, "auto")==0 ){ if( idx>1 ) return 1; /* IMP: R-33611-57934 */ - if( !p->rawS || p->validJD ){ - rc = 0; - p->rawS = 0; - }else if( p->s>=-21086676*(i64)10000 /* -4713-11-24 12:00:00 */ - && p->s<=(25340230*(i64)10000)+799 /* 9999-12-31 23:59:59 */ - ){ - r = p->s*1000.0 + 210866760000000.0; - clearYMD_HMS_TZ(p); - p->iJD = (sqlite3_int64)(r + 0.5); - p->validJD = 1; - p->rawS = 0; - rc = 0; - } + autoAdjustDate(p); + rc = 0; } break; } @@ -24482,18 +24641,73 @@ static int parseModifier( case '9': { double rRounder; int i; - for(n=1; z[n] && z[n]!=':' && !sqlite3Isspace(z[n]); n++){} + int Y,M,D,h,m,x; + const char *z2 = z; + char z0 = z[0]; + for(n=1; z[n]; n++){ + if( z[n]==':' ) break; + if( sqlite3Isspace(z[n]) ) break; + if( z[n]=='-' ){ + if( n==5 && getDigits(&z[1], "40f", &Y)==1 ) break; + if( n==6 && getDigits(&z[1], "50f", &Y)==1 ) break; + } + } if( sqlite3AtoF(z, &r, n, SQLITE_UTF8)<=0 ){ - rc = 1; + assert( rc==1 ); break; } - if( z[n]==':' ){ + if( z[n]=='-' ){ + /* A modifier of the form (+|-)YYYY-MM-DD adds or subtracts the + ** specified number of years, months, and days. MM is limited to + ** the range 0-11 and DD is limited to 0-30. + */ + if( z0!='+' && z0!='-' ) break; /* Must start with +/- */ + if( n==5 ){ + if( getDigits(&z[1], "40f-20a-20d", &Y, &M, &D)!=3 ) break; + }else{ + assert( n==6 ); + if( getDigits(&z[1], "50f-20a-20d", &Y, &M, &D)!=3 ) break; + z++; + } + if( M>=12 ) break; /* M range 0..11 */ + if( D>=31 ) break; /* D range 0..30 */ + computeYMD_HMS(p); + p->validJD = 0; + if( z0=='-' ){ + p->Y -= Y; + p->M -= M; + D = -D; + }else{ + p->Y += Y; + p->M += M; + } + x = p->M>0 ? (p->M-1)/12 : (p->M-12)/12; + p->Y += x; + p->M -= x*12; + computeJD(p); + p->validHMS = 0; + p->validYMD = 0; + p->iJD += (i64)D*86400000; + if( z[11]==0 ){ + rc = 0; + break; + } + if( sqlite3Isspace(z[11]) + && getDigits(&z[12], "20c:20e", &h, &m)==2 + ){ + z2 = &z[12]; + n = 2; + }else{ + break; + } + } + if( z2[n]==':' ){ /* A modifier of the form (+|-)HH:MM:SS.FFF adds (or subtracts) the ** specified number of hours, minutes, seconds, and fractional seconds ** to the time. The ".FFF" may be omitted. The ":SS.FFF" may be ** omitted. */ - const char *z2 = z; + DateTime tx; sqlite3_int64 day; if( !sqlite3Isdigit(*z2) ) z2++; @@ -24503,7 +24717,7 @@ static int parseModifier( tx.iJD -= 43200000; day = tx.iJD/86400000; tx.iJD -= day*86400000; - if( z[0]=='-' ) tx.iJD = -tx.iJD; + if( z0=='-' ) tx.iJD = -tx.iJD; computeJD(p); clearYMD_HMS_TZ(p); p->iJD += tx.iJD; @@ -24519,7 +24733,7 @@ static int parseModifier( if( n>10 || n<3 ) break; if( sqlite3UpperToLower[(u8)z[n-1]]=='s' ) n--; computeJD(p); - rc = 1; + assert( rc==1 ); rRounder = r<0 ? -0.5 : +0.5; for(i=0; iM += (int)r; @@ -24687,7 +24900,7 @@ static void datetimeFunc( zBuf[16] = '0' + (x.m)%10; zBuf[17] = ':'; if( x.useSubsec ){ - s = (int)1000.0*x.s; + s = (int)(1000.0*x.s + 0.5); zBuf[18] = '0' + (s/10000)%10; zBuf[19] = '0' + (s/1000)%10; zBuf[20] = '.'; @@ -24734,7 +24947,7 @@ static void timeFunc( zBuf[4] = '0' + (x.m)%10; zBuf[5] = ':'; if( x.useSubsec ){ - s = (int)1000.0*x.s; + s = (int)(1000.0*x.s + 0.5); zBuf[6] = '0' + (s/10000)%10; zBuf[7] = '0' + (s/1000)%10; zBuf[8] = '.'; @@ -24805,7 +25018,7 @@ static void dateFunc( ** %M minute 00-59 ** %s seconds since 1970-01-01 ** %S seconds 00-59 -** %w day of week 0-6 sunday==0 +** %w day of week 0-6 Sunday==0 ** %W week of year 00-53 ** %Y year 0000-9999 ** %% % @@ -24945,6 +25158,117 @@ static void cdateFunc( dateFunc(context, 0, 0); } +/* +** timediff(DATE1, DATE2) +** +** Return the amount of time that must be added to DATE2 in order to +** convert it into DATE2. The time difference format is: +** +** +YYYY-MM-DD HH:MM:SS.SSS +** +** The initial "+" becomes "-" if DATE1 occurs before DATE2. For +** date/time values A and B, the following invariant should hold: +** +** datetime(A) == (datetime(B, timediff(A,B)) +** +** Both DATE arguments must be either a julian day number, or an +** ISO-8601 string. The unix timestamps are not supported by this +** routine. +*/ +static void timediffFunc( + sqlite3_context *context, + int NotUsed1, + sqlite3_value **argv +){ + char sign; + int Y, M; + DateTime d1, d2; + sqlite3_str sRes; + UNUSED_PARAMETER(NotUsed1); + if( isDate(context, 1, &argv[0], &d1) ) return; + if( isDate(context, 1, &argv[1], &d2) ) return; + computeYMD_HMS(&d1); + computeYMD_HMS(&d2); + if( d1.iJD>=d2.iJD ){ + sign = '+'; + Y = d1.Y - d2.Y; + if( Y ){ + d2.Y = d1.Y; + d2.validJD = 0; + computeJD(&d2); + } + M = d1.M - d2.M; + if( M<0 ){ + Y--; + M += 12; + } + if( M!=0 ){ + d2.M = d1.M; + d2.validJD = 0; + computeJD(&d2); + } + while( d1.iJDd2.iJD ){ + M--; + if( M<0 ){ + M = 11; + Y--; + } + d2.M++; + if( d2.M>12 ){ + d2.M = 1; + d2.Y++; + } + d2.validJD = 0; + computeJD(&d2); + } + d1.iJD = d2.iJD - d1.iJD; + d1.iJD += (u64)1486995408 * (u64)100000; + } + d1.validYMD = 0; + d1.validHMS = 0; + d1.validTZ = 0; + computeYMD_HMS(&d1); + sqlite3StrAccumInit(&sRes, 0, 0, 0, 100); + sqlite3_str_appendf(&sRes, "%c%04d-%02d-%02d %02d:%02d:%06.3f", + sign, Y, M, d1.D-1, d1.h, d1.m, d1.s); + sqlite3ResultStrAccum(context, &sRes); +} + + /* ** current_timestamp() ** @@ -25019,6 +25343,7 @@ SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void){ PURE_DATE(time, -1, 0, 0, timeFunc ), PURE_DATE(datetime, -1, 0, 0, datetimeFunc ), PURE_DATE(strftime, -1, 0, 0, strftimeFunc ), + PURE_DATE(timediff, 2, 0, 0, timediffFunc ), DFUNCTION(current_time, 0, 0, 0, ctimeFunc ), DFUNCTION(current_timestamp, 0, 0, 0, ctimestampFunc), DFUNCTION(current_date, 0, 0, 0, cdateFunc ), @@ -25172,7 +25497,7 @@ SQLITE_PRIVATE int sqlite3OsFileControl(sqlite3_file *id, int op, void *pArg){ /* Faults are not injected into COMMIT_PHASETWO because, assuming SQLite ** is using a regular VFS, it is called after the corresponding ** transaction has been committed. Injecting a fault at this point - ** confuses the test scripts - the COMMIT comand returns SQLITE_NOMEM + ** confuses the test scripts - the COMMIT command returns SQLITE_NOMEM ** but the transaction is committed anyway. ** ** The core must call OsFileControl() though, not OsFileControlHint(), @@ -25793,7 +26118,7 @@ static void *sqlite3MemMalloc(int nByte){ ** or sqlite3MemRealloc(). ** ** For this low-level routine, we already know that pPrior!=0 since -** cases where pPrior==0 will have been intecepted and dealt with +** cases where pPrior==0 will have been intercepted and dealt with ** by higher-level routines. */ static void sqlite3MemFree(void *pPrior){ @@ -25881,7 +26206,7 @@ static int sqlite3MemInit(void *NotUsed){ return SQLITE_OK; } len = sizeof(cpuCount); - /* One usually wants to use hw.acctivecpu for MT decisions, but not here */ + /* One usually wants to use hw.activecpu for MT decisions, but not here */ sysctlbyname("hw.ncpu", &cpuCount, &len, NULL, 0); if( cpuCount>1 ){ /* defer MT decisions to system malloc */ @@ -28348,7 +28673,7 @@ SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){ /* ** The sqlite3_mutex.id, sqlite3_mutex.nRef, and sqlite3_mutex.owner fields -** are necessary under two condidtions: (1) Debug builds and (2) using +** are necessary under two conditions: (1) Debug builds and (2) using ** home-grown mutexes. Encapsulate these conditions into a single #define. */ #if defined(SQLITE_DEBUG) || defined(SQLITE_HOMEGROWN_RECURSIVE_MUTEX) @@ -28849,7 +29174,7 @@ struct sqlite3_mutex { CRITICAL_SECTION mutex; /* Mutex controlling the lock */ int id; /* Mutex type */ #ifdef SQLITE_DEBUG - volatile int nRef; /* Number of enterances */ + volatile int nRef; /* Number of entrances */ volatile DWORD owner; /* Thread holding this mutex */ volatile LONG trace; /* True to trace changes */ #endif @@ -30221,57 +30546,6 @@ static const et_info fmtinfo[] = { ** %!S Like %S but prefer the zName over the zAlias */ -/* Floating point constants used for rounding */ -static const double arRound[] = { - 5.0e-01, 5.0e-02, 5.0e-03, 5.0e-04, 5.0e-05, - 5.0e-06, 5.0e-07, 5.0e-08, 5.0e-09, 5.0e-10, -}; - -/* -** If SQLITE_OMIT_FLOATING_POINT is defined, then none of the floating point -** conversions will work. -*/ -#ifndef SQLITE_OMIT_FLOATING_POINT -/* -** "*val" is a double such that 0.1 <= *val < 10.0 -** Return the ascii code for the leading digit of *val, then -** multiply "*val" by 10.0 to renormalize. -** -** Example: -** input: *val = 3.14159 -** output: *val = 1.4159 function return = '3' -** -** The counter *cnt is incremented each time. After counter exceeds -** 16 (the number of significant digits in a 64-bit float) '0' is -** always returned. -*/ -static char et_getdigit(LONGDOUBLE_TYPE *val, int *cnt){ - int digit; - LONGDOUBLE_TYPE d; - if( (*cnt)<=0 ) return '0'; - (*cnt)--; - digit = (int)*val; - d = digit; - digit += '0'; - *val = (*val - d)*10.0; - return (char)digit; -} -#endif /* SQLITE_OMIT_FLOATING_POINT */ - -#ifndef SQLITE_OMIT_FLOATING_POINT -/* -** "*val" is a u64. *msd is a divisor used to extract the -** most significant digit of *val. Extract that most significant -** digit and return it. -*/ -static char et_getdigit_int(u64 *val, u64 *msd){ - u64 x = (*val)/(*msd); - *val -= x*(*msd); - if( *msd>=10 ) *msd /= 10; - return '0' + (char)(x & 15); -} -#endif /* SQLITE_OMIT_FLOATING_POINT */ - /* ** Set the StrAccum object to an error mode. */ @@ -30363,20 +30637,15 @@ SQLITE_API void sqlite3_str_vappendf( u8 bArgList; /* True for SQLITE_PRINTF_SQLFUNC */ char prefix; /* Prefix character. "+" or "-" or " " or '\0'. */ sqlite_uint64 longvalue; /* Value for integer types */ - LONGDOUBLE_TYPE realvalue; /* Value for real types */ - sqlite_uint64 msd; /* Divisor to get most-significant-digit - ** of longvalue */ + double realvalue; /* Value for real types */ const et_info *infop; /* Pointer to the appropriate info structure */ char *zOut; /* Rendering buffer */ int nOut; /* Size of the rendering buffer */ char *zExtra = 0; /* Malloced memory used by some conversion */ -#ifndef SQLITE_OMIT_FLOATING_POINT - int exp, e2; /* exponent of real numbers */ - int nsd; /* Number of significant digits returned */ - double rounder; /* Used for rounding floating point values */ + int exp, e2; /* exponent of real numbers */ etByte flag_dp; /* True if decimal point should be shown */ etByte flag_rtz; /* True if trailing zeros should be removed */ -#endif + PrintfArguments *pArgList = 0; /* Arguments for SQLITE_PRINTF_SQLFUNC */ char buf[etBUFSIZE]; /* Conversion buffer */ @@ -30651,94 +30920,61 @@ SQLITE_API void sqlite3_str_vappendf( break; case etFLOAT: case etEXP: - case etGENERIC: + case etGENERIC: { + FpDecode s; + int iRound; + int j; + if( bArgList ){ realvalue = getDoubleArg(pArgList); }else{ realvalue = va_arg(ap,double); } -#ifdef SQLITE_OMIT_FLOATING_POINT - length = 0; -#else if( precision<0 ) precision = 6; /* Set default precision */ #ifdef SQLITE_FP_PRECISION_LIMIT if( precision>SQLITE_FP_PRECISION_LIMIT ){ precision = SQLITE_FP_PRECISION_LIMIT; } #endif - if( realvalue<0.0 ){ - realvalue = -realvalue; + if( xtype==etFLOAT ){ + iRound = -precision; + }else if( xtype==etGENERIC ){ + iRound = precision; + }else{ + iRound = precision+1; + } + sqlite3FpDecode(&s, realvalue, iRound, flag_altform2 ? 26 : 16); + if( s.isSpecial ){ + if( s.isSpecial==2 ){ + bufpt = flag_zeropad ? "null" : "NaN"; + length = sqlite3Strlen30(bufpt); + break; + }else if( flag_zeropad ){ + s.z[0] = '9'; + s.iDP = 1000; + s.n = 1; + }else{ + memcpy(buf, "-Inf", 5); + bufpt = buf; + if( s.sign=='-' ){ + /* no-op */ + }else if( flag_prefix ){ + buf[0] = flag_prefix; + }else{ + bufpt++; + } + length = sqlite3Strlen30(bufpt); + break; + } + } + if( s.sign=='-' ){ prefix = '-'; }else{ prefix = flag_prefix; } - exp = 0; - if( xtype==etGENERIC && precision>0 ) precision--; - testcase( precision>0xfff ); - if( realvalue<1.0e+16 - && realvalue==(LONGDOUBLE_TYPE)(longvalue = (u64)realvalue) - ){ - /* Number is a pure integer that can be represented as u64 */ - for(msd=1; msd*10<=longvalue; msd *= 10, exp++){} - if( exp>precision && xtype!=etFLOAT ){ - u64 rnd = msd/2; - int kk = precision; - while( kk-- > 0 ){ rnd /= 10; } - longvalue += rnd; - } - }else{ - msd = 0; - longvalue = 0; /* To prevent a compiler warning */ - idx = precision & 0xfff; - rounder = arRound[idx%10]; - while( idx>=10 ){ rounder *= 1.0e-10; idx -= 10; } - if( xtype==etFLOAT ){ - double rx = (double)realvalue; - sqlite3_uint64 u; - int ex; - memcpy(&u, &rx, sizeof(u)); - ex = -1023 + (int)((u>>52)&0x7ff); - if( precision+(ex/3) < 15 ) rounder += realvalue*3e-16; - realvalue += rounder; - } - if( sqlite3IsNaN((double)realvalue) ){ - if( flag_zeropad ){ - bufpt = "null"; - length = 4; - }else{ - bufpt = "NaN"; - length = 3; - } - break; - } - /* Normalize realvalue to within 10.0 > realvalue >= 1.0 */ - if( ALWAYS(realvalue>0.0) ){ - LONGDOUBLE_TYPE scale = 1.0; - while( realvalue>=1e100*scale && exp<=350){ scale*=1e100;exp+=100;} - while( realvalue>=1e10*scale && exp<=350 ){ scale*=1e10; exp+=10; } - while( realvalue>=10.0*scale && exp<=350 ){ scale *= 10.0; exp++; } - realvalue /= scale; - while( realvalue<1e-8 ){ realvalue *= 1e8; exp-=8; } - while( realvalue<1.0 ){ realvalue *= 10.0; exp--; } - if( exp>350 ){ - if( flag_zeropad ){ - realvalue = 9.0; - exp = 999; - }else{ - bufpt = buf; - buf[0] = prefix; - memcpy(buf+(prefix!=0),"Inf",4); - length = 3+(prefix!=0); - break; - } - } - if( xtype!=etFLOAT ){ - realvalue += rounder; - if( realvalue>=10.0 ){ realvalue *= 0.1; exp++; } - } - } - } + exp = s.iDP-1; + if( xtype==etGENERIC && precision>0 ) precision--; /* ** If the field type is etGENERIC, then convert to either etEXP @@ -30758,9 +30994,8 @@ SQLITE_API void sqlite3_str_vappendf( if( xtype==etEXP ){ e2 = 0; }else{ - e2 = exp; + e2 = s.iDP - 1; } - nsd = 16 + flag_altform2*10; bufpt = buf; { i64 szBufNeeded; /* Size of a temporary buffer needed */ @@ -30778,16 +31013,12 @@ SQLITE_API void sqlite3_str_vappendf( *(bufpt++) = prefix; } /* Digits prior to the decimal point */ + j = 0; if( e2<0 ){ *(bufpt++) = '0'; - }else if( msd>0 ){ - for(; e2>=0; e2--){ - *(bufpt++) = et_getdigit_int(&longvalue,&msd); - if( cThousand && (e2%3)==0 && e2>1 ) *(bufpt++) = ','; - } }else{ for(; e2>=0; e2--){ - *(bufpt++) = et_getdigit(&realvalue,&nsd); + *(bufpt++) = j1 ) *(bufpt++) = ','; } } @@ -30797,19 +31028,12 @@ SQLITE_API void sqlite3_str_vappendf( } /* "0" digits after the decimal point but before the first ** significant digit of the number */ - for(e2++; e2<0; precision--, e2++){ - assert( precision>0 ); + for(e2++; e2<0 && precision>0; precision--, e2++){ *(bufpt++) = '0'; } /* Significant digits after the decimal point */ - if( msd>0 ){ - while( (precision--)>0 ){ - *(bufpt++) = et_getdigit_int(&longvalue,&msd); - } - }else{ - while( (precision--)>0 ){ - *(bufpt++) = et_getdigit(&realvalue,&nsd); - } + while( (precision--)>0 ){ + *(bufpt++) = jcharset]; if( exp<0 ){ *(bufpt++) = '-'; exp = -exp; @@ -30858,8 +31083,8 @@ SQLITE_API void sqlite3_str_vappendf( while( nPad-- ) bufpt[i++] = '0'; length = width; } -#endif /* !defined(SQLITE_OMIT_FLOATING_POINT) */ break; + } case etSIZE: if( !bArgList ){ *(va_arg(ap,int*)) = pAccum->nChar; @@ -31583,6 +31808,75 @@ SQLITE_API void sqlite3_str_appendf(StrAccum *p, const char *zFormat, ...){ va_end(ap); } + +/***************************************************************************** +** Reference counted string storage +*****************************************************************************/ + +/* +** Increase the reference count of the string by one. +** +** The input parameter is returned. +*/ +SQLITE_PRIVATE char *sqlite3RCStrRef(char *z){ + RCStr *p = (RCStr*)z; + assert( p!=0 ); + p--; + p->nRCRef++; + return z; +} + +/* +** Decrease the reference count by one. Free the string when the +** reference count reaches zero. +*/ +SQLITE_PRIVATE void sqlite3RCStrUnref(char *z){ + RCStr *p = (RCStr*)z; + assert( p!=0 ); + p--; + assert( p->nRCRef>0 ); + if( p->nRCRef>=2 ){ + p->nRCRef--; + }else{ + sqlite3_free(p); + } +} + +/* +** Create a new string that is capable of holding N bytes of text, not counting +** the zero byte at the end. The string is uninitialized. +** +** The reference count is initially 1. Call sqlite3RCStrUnref() to free the +** newly allocated string. +** +** This routine returns 0 on an OOM. +*/ +SQLITE_PRIVATE char *sqlite3RCStrNew(u64 N){ + RCStr *p = sqlite3_malloc64( N + sizeof(*p) + 1 ); + if( p==0 ) return 0; + p->nRCRef = 1; + return (char*)&p[1]; +} + +/* +** Change the size of the string so that it is able to hold N bytes. +** The string might be reallocated, so return the new allocation. +*/ +SQLITE_PRIVATE char *sqlite3RCStrResize(char *z, u64 N){ + RCStr *p = (RCStr*)z; + RCStr *pNew; + assert( p!=0 ); + p--; + assert( p->nRCRef==1 ); + pNew = sqlite3_realloc64(p, N+sizeof(RCStr)+1); + if( pNew==0 ){ + sqlite3_free(p); + return 0; + }else{ + return (char*)&pNew[1]; + } +} + /************** End of printf.c **********************************************/ /************** Begin file treeview.c ****************************************/ /* @@ -32230,7 +32524,8 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m }; assert( pExpr->op2==TK_IS || pExpr->op2==TK_ISNOT ); assert( pExpr->pRight ); - assert( sqlite3ExprSkipCollate(pExpr->pRight)->op==TK_TRUEFALSE ); + assert( sqlite3ExprSkipCollateAndLikely(pExpr->pRight)->op + == TK_TRUEFALSE ); x = (pExpr->op2==TK_ISNOT)*2 + sqlite3ExprTruthValue(pExpr->pRight); zUniOp = azOp[x]; break; @@ -33889,7 +34184,7 @@ SQLITE_PRIVATE void sqlite3UtfSelfTest(void){ /* ** Calls to sqlite3FaultSim() are used to simulate a failure during testing, ** or to bypass normal error detection during testing in order to let -** execute proceed futher downstream. +** execute proceed further downstream. ** ** In deployment, sqlite3FaultSim() *always* return SQLITE_OK (0). The ** sqlite3FaultSim() function only returns non-zero during testing. @@ -34006,6 +34301,23 @@ SQLITE_PRIVATE void sqlite3ErrorClear(sqlite3 *db){ */ SQLITE_PRIVATE void sqlite3SystemError(sqlite3 *db, int rc){ if( rc==SQLITE_IOERR_NOMEM ) return; +#ifdef SQLITE_USE_SEH + if( rc==SQLITE_IOERR_IN_PAGE ){ + int ii; + int iErr; + sqlite3BtreeEnterAll(db); + for(ii=0; iinDb; ii++){ + if( db->aDb[ii].pBt ){ + iErr = sqlite3PagerWalSystemErrno(sqlite3BtreePager(db->aDb[ii].pBt)); + if( iErr ){ + db->iSysErrno = iErr; + } + } + } + sqlite3BtreeLeaveAll(db); + return; + } +#endif rc &= 0xff; if( rc==SQLITE_CANTOPEN || rc==SQLITE_IOERR ){ db->iSysErrno = sqlite3OsGetLastError(db->pVfs); @@ -34251,43 +34563,40 @@ SQLITE_PRIVATE u8 sqlite3StrIHash(const char *z){ return h; } -/* -** Compute 10 to the E-th power. Examples: E==1 results in 10. -** E==2 results in 100. E==50 results in 1.0e50. +/* Double-Double multiplication. (x[0],x[1]) *= (y,yy) ** -** This routine only works for values of E between 1 and 341. +** Reference: +** T. J. Dekker, "A Floating-Point Technique for Extending the +** Available Precision". 1971-07-26. */ -static LONGDOUBLE_TYPE sqlite3Pow10(int E){ -#if defined(_MSC_VER) - static const LONGDOUBLE_TYPE x[] = { - 1.0e+001L, - 1.0e+002L, - 1.0e+004L, - 1.0e+008L, - 1.0e+016L, - 1.0e+032L, - 1.0e+064L, - 1.0e+128L, - 1.0e+256L - }; - LONGDOUBLE_TYPE r = 1.0; - int i; - assert( E>=0 && E<=307 ); - for(i=0; E!=0; i++, E >>=1){ - if( E & 1 ) r *= x[i]; - } - return r; -#else - LONGDOUBLE_TYPE x = 10.0; - LONGDOUBLE_TYPE r = 1.0; - while(1){ - if( E & 1 ) r *= x; - E >>= 1; - if( E==0 ) break; - x *= x; - } - return r; -#endif +static void dekkerMul2(volatile double *x, double y, double yy){ + /* + ** The "volatile" keywords on parameter x[] and on local variables + ** below are needed force intermediate results to be truncated to + ** binary64 rather than be carried around in an extended-precision + ** format. The truncation is necessary for the Dekker algorithm to + ** work. Intel x86 floating point might omit the truncation without + ** the use of volatile. + */ + volatile double tx, ty, p, q, c, cc; + double hx, hy; + u64 m; + memcpy(&m, (void*)&x[0], 8); + m &= 0xfffffffffc000000LL; + memcpy(&hx, &m, 8); + tx = x[0] - hx; + memcpy(&m, &y, 8); + m &= 0xfffffffffc000000LL; + memcpy(&hy, &m, 8); + ty = y - hy; + p = hx*hy; + q = hx*ty + tx*hy; + c = p+q; + cc = p - c + q + tx*ty; + cc = x[0]*yy + x[1]*y + cc; + x[0] = c + cc; + x[1] = c - x[0]; + x[1] += cc; } /* @@ -34328,12 +34637,11 @@ SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult, int length, u8 en const char *zEnd; /* sign * significand * (10 ^ (esign * exponent)) */ int sign = 1; /* sign of significand */ - i64 s = 0; /* significand */ + u64 s = 0; /* significand */ int d = 0; /* adjust exponent for shifting decimal point */ int esign = 1; /* sign of exponent */ int e = 0; /* exponent */ int eValid = 1; /* True exponent is either not used or is well-formed */ - double result; int nDigit = 0; /* Number of digits processed */ int eType = 1; /* 1: pure integer, 2+: fractional -1 or less: bad UTF16 */ @@ -34373,7 +34681,7 @@ SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult, int length, u8 en while( z=((LARGEST_INT64-9)/10) ){ + if( s>=((LARGEST_UINT64-9)/10) ){ /* skip non-significant significand digits ** (increase exponent by d to shift decimal left) */ while( z0 && s<(LARGEST_UINT64/10) ){ + s *= 10; + e--; + } + while( e<0 && (s%10)==0 ){ + s /= 10; + e++; } - if( s==0 ) { - /* In the IEEE 754 standard, zero is signed. */ - result = sign<0 ? -(double)0 : (double)0; - } else { - /* Attempt to reduce exponent. - ** - ** Branches that are not required for the correct answer but which only - ** help to obtain the correct answer faster are marked with special - ** comments, as a hint to the mutation tester. - */ - while( e>0 ){ /*OPTIMIZATION-IF-TRUE*/ - if( esign>0 ){ - if( s>=(LARGEST_INT64/10) ) break; /*OPTIMIZATION-IF-FALSE*/ - s *= 10; - }else{ - if( s%10!=0 ) break; /*OPTIMIZATION-IF-FALSE*/ - s /= 10; - } - e--; - } - - /* adjust the sign of significand */ - s = sign<0 ? -s : s; - - if( e==0 ){ /*OPTIMIZATION-IF-TRUE*/ - result = (double)s; + if( e==0 ){ + *pResult = s; + }else if( sqlite3Config.bUseLongDouble ){ + LONGDOUBLE_TYPE r = (LONGDOUBLE_TYPE)s; + if( e>0 ){ + while( e>=100 ){ e-=100; r *= 1.0e+100L; } + while( e>=10 ){ e-=10; r *= 1.0e+10L; } + while( e>=1 ){ e-=1; r *= 1.0e+01L; } }else{ - /* attempt to handle extremely small/large numbers better */ - if( e>307 ){ /*OPTIMIZATION-IF-TRUE*/ - if( e<342 ){ /*OPTIMIZATION-IF-TRUE*/ - LONGDOUBLE_TYPE scale = sqlite3Pow10(e-308); - if( esign<0 ){ - result = s / scale; - result /= 1.0e+308; - }else{ - result = s * scale; - result *= 1.0e+308; - } - }else{ assert( e>=342 ); - if( esign<0 ){ - result = 0.0*s; - }else{ + while( e<=-100 ){ e+=100; r *= 1.0e-100L; } + while( e<=-10 ){ e+=10; r *= 1.0e-10L; } + while( e<=-1 ){ e+=1; r *= 1.0e-01L; } + } + assert( r>=0.0 ); + if( r>+1.7976931348623157081452742373e+308L ){ #ifdef INFINITY - result = INFINITY*s; + *pResult = +INFINITY; #else - result = 1e308*1e308*s; /* Infinity */ + *pResult = 1.0e308*10.0; #endif - } - } - }else{ - LONGDOUBLE_TYPE scale = sqlite3Pow10(e); - if( esign<0 ){ - result = s / scale; - }else{ - result = s * scale; - } + }else{ + *pResult = (double)r; + } + }else{ + double rr[2]; + u64 s2; + rr[0] = (double)s; + s2 = (u64)rr[0]; + rr[1] = s>=s2 ? (double)(s - s2) : -(double)(s2 - s); + if( e>0 ){ + while( e>=100 ){ + e -= 100; + dekkerMul2(rr, 1.0e+100, -1.5902891109759918046e+83); + } + while( e>=10 ){ + e -= 10; + dekkerMul2(rr, 1.0e+10, 0.0); + } + while( e>=1 ){ + e -= 1; + dekkerMul2(rr, 1.0e+01, 0.0); + } + }else{ + while( e<=-100 ){ + e += 100; + dekkerMul2(rr, 1.0e-100, -1.99918998026028836196e-117); + } + while( e<=-10 ){ + e += 10; + dekkerMul2(rr, 1.0e-10, -3.6432197315497741579e-27); + } + while( e<=-1 ){ + e += 1; + dekkerMul2(rr, 1.0e-01, -5.5511151231257827021e-18); } } + *pResult = rr[0]+rr[1]; + if( sqlite3IsNaN(*pResult) ) *pResult = 1e300*1e300; } + if( sign<0 ) *pResult = -*pResult; + assert( !sqlite3IsNaN(*pResult) ); - /* store the result */ - *pResult = result; - - /* return true if number and no extra non-whitespace chracters after */ +atof_return: + /* return true if number and no extra non-whitespace characters after */ if( z==zEnd && nDigit>0 && eValid && eType>0 ){ return eType; }else if( eType>=2 && (eType==3 || eValid) && nDigit>0 ){ @@ -34636,7 +34954,7 @@ SQLITE_PRIVATE int sqlite3Atoi64(const char *zNum, i64 *pNum, int length, u8 enc /* This test and assignment is needed only to suppress UB warnings ** from clang and -fsanitize=undefined. This test and assignment make ** the code a little larger and slower, and no harm comes from omitting - ** them, but we must appaise the undefined-behavior pharisees. */ + ** them, but we must appease the undefined-behavior pharisees. */ *pNum = neg ? SMALLEST_INT64 : LARGEST_INT64; }else if( neg ){ *pNum = -(i64)u; @@ -34714,7 +35032,9 @@ SQLITE_PRIVATE int sqlite3DecOrHexToI64(const char *z, i64 *pOut){ }else #endif /* SQLITE_OMIT_HEX_INTEGER */ { - return sqlite3Atoi64(z, pOut, sqlite3Strlen30(z), SQLITE_UTF8); + int n = (int)(0x3fffffff&strspn(z,"+- \n\t0123456789")); + if( z[n] ) n++; + return sqlite3Atoi64(z, pOut, n, SQLITE_UTF8); } } @@ -34793,6 +35113,153 @@ SQLITE_PRIVATE int sqlite3Atoi(const char *z){ return x; } +/* +** Decode a floating-point value into an approximate decimal +** representation. +** +** Round the decimal representation to n significant digits if +** n is positive. Or round to -n signficant digits after the +** decimal point if n is negative. No rounding is performed if +** n is zero. +** +** The significant digits of the decimal representation are +** stored in p->z[] which is a often (but not always) a pointer +** into the middle of p->zBuf[]. There are p->n significant digits. +** The p->z[] array is *not* zero-terminated. +*/ +SQLITE_PRIVATE void sqlite3FpDecode(FpDecode *p, double r, int iRound, int mxRound){ + int i; + u64 v; + int e, exp = 0; + p->isSpecial = 0; + p->z = p->zBuf; + + /* Convert negative numbers to positive. Deal with Infinity, 0.0, and + ** NaN. */ + if( r<0.0 ){ + p->sign = '-'; + r = -r; + }else if( r==0.0 ){ + p->sign = '+'; + p->n = 1; + p->iDP = 1; + p->z = "0"; + return; + }else{ + p->sign = '+'; + } + memcpy(&v,&r,8); + e = v>>52; + if( (e&0x7ff)==0x7ff ){ + p->isSpecial = 1 + (v!=0x7ff0000000000000LL); + p->n = 0; + p->iDP = 0; + return; + } + + /* Multiply r by powers of ten until it lands somewhere in between + ** 1.0e+19 and 1.0e+17. + */ + if( sqlite3Config.bUseLongDouble ){ + LONGDOUBLE_TYPE rr = r; + if( rr>=1.0e+19 ){ + while( rr>=1.0e+119L ){ exp+=100; rr *= 1.0e-100L; } + while( rr>=1.0e+29L ){ exp+=10; rr *= 1.0e-10L; } + while( rr>=1.0e+19L ){ exp++; rr *= 1.0e-1L; } + }else{ + while( rr<1.0e-97L ){ exp-=100; rr *= 1.0e+100L; } + while( rr<1.0e+07L ){ exp-=10; rr *= 1.0e+10L; } + while( rr<1.0e+17L ){ exp--; rr *= 1.0e+1L; } + } + v = (u64)rr; + }else{ + /* If high-precision floating point is not available using "long double", + ** then use Dekker-style double-double computation to increase the + ** precision. + ** + ** The error terms on constants like 1.0e+100 computed using the + ** decimal extension, for example as follows: + ** + ** SELECT decimal_exp(decimal_sub('1.0e+100',decimal(1.0e+100))); + */ + double rr[2]; + rr[0] = r; + rr[1] = 0.0; + if( rr[0]>1.84e+19 ){ + while( rr[0]>1.84e+119 ){ + exp += 100; + dekkerMul2(rr, 1.0e-100, -1.99918998026028836196e-117); + } + while( rr[0]>1.84e+29 ){ + exp += 10; + dekkerMul2(rr, 1.0e-10, -3.6432197315497741579e-27); + } + while( rr[0]>1.84e+19 ){ + exp += 1; + dekkerMul2(rr, 1.0e-01, -5.5511151231257827021e-18); + } + }else{ + while( rr[0]<1.84e-82 ){ + exp -= 100; + dekkerMul2(rr, 1.0e+100, -1.5902891109759918046e+83); + } + while( rr[0]<1.84e+08 ){ + exp -= 10; + dekkerMul2(rr, 1.0e+10, 0.0); + } + while( rr[0]<1.84e+18 ){ + exp -= 1; + dekkerMul2(rr, 1.0e+01, 0.0); + } + } + v = rr[1]<0.0 ? (u64)rr[0]-(u64)(-rr[1]) : (u64)rr[0]+(u64)rr[1]; + } + + + /* Extract significant digits. */ + i = sizeof(p->zBuf)-1; + assert( v>0 ); + while( v ){ p->zBuf[i--] = (v%10) + '0'; v /= 10; } + assert( i>=0 && izBuf)-1 ); + p->n = sizeof(p->zBuf) - 1 - i; + assert( p->n>0 ); + assert( p->nzBuf) ); + p->iDP = p->n + exp; + if( iRound<0 ){ + iRound = p->iDP - iRound; + if( iRound==0 && p->zBuf[i+1]>='5' ){ + iRound = 1; + p->zBuf[i--] = '0'; + p->n++; + p->iDP++; + } + } + if( iRound>0 && (iRoundn || p->n>mxRound) ){ + char *z = &p->zBuf[i+1]; + if( iRound>mxRound ) iRound = mxRound; + p->n = iRound; + if( z[iRound]>='5' ){ + int j = iRound-1; + while( 1 /*exit-by-break*/ ){ + z[j]++; + if( z[j]<='9' ) break; + z[j] = '0'; + if( j==0 ){ + p->z[i--] = '1'; + p->n++; + p->iDP++; + break; + }else{ + j--; + } + } + } + } + p->z = &p->zBuf[i+1]; + assert( i+p->n < sizeof(p->zBuf) ); + while( ALWAYS(p->n>0) && p->z[p->n-1]=='0' ){ p->n--; } +} + /* ** Try to convert z into an unsigned 32-bit integer. Return true on ** success and false if there is an error. @@ -35321,7 +35788,7 @@ SQLITE_PRIVATE int sqlite3SafetyCheckSickOrOk(sqlite3 *db){ } /* -** Attempt to add, substract, or multiply the 64-bit signed value iB against +** Attempt to add, subtract, or multiply the 64-bit signed value iB against ** the other 64-bit signed integer at *pA and store the result in *pA. ** Return 0 on success. Or if the operation would have resulted in an ** overflow, leave *pA unchanged and return 1. @@ -35634,7 +36101,7 @@ SQLITE_PRIVATE int sqlite3VListNameToNum(VList *pIn, const char *zName, int nNam #define SQLITE_HWTIME_H /* -** The following routine only works on pentium-class (or newer) processors. +** The following routine only works on Pentium-class (or newer) processors. ** It uses the RDTSC opcode to read the cycle count value out of the ** processor and returns that value. This can be used for high-res ** profiling. @@ -35806,7 +36273,7 @@ static void insertElement( } -/* Resize the hash table so that it cantains "new_size" buckets. +/* Resize the hash table so that it contains "new_size" buckets. ** ** The hash table might fail to resize if sqlite3_malloc() fails or ** if the new size is the same as the prior size. @@ -37192,7 +37659,7 @@ SQLITE_PRIVATE int sqlite3KvvfsInit(void){ ** This source file is organized into divisions where the logic for various ** subfunctions is contained within the appropriate division. PLEASE ** KEEP THE STRUCTURE OF THIS FILE INTACT. New code should be placed -** in the correct division and should be clearly labeled. +** in the correct division and should be clearly labelled. ** ** The layout of divisions is as follows: ** @@ -37779,7 +38246,7 @@ static int robustFchown(int fd, uid_t uid, gid_t gid){ /* ** This is the xSetSystemCall() method of sqlite3_vfs for all of the -** "unix" VFSes. Return SQLITE_OK opon successfully updating the +** "unix" VFSes. Return SQLITE_OK upon successfully updating the ** system call pointer, or SQLITE_NOTFOUND if there is no configurable ** system call named zName. */ @@ -38301,7 +38768,7 @@ static void vxworksReleaseFileId(struct vxworksFileId *pId){ ** If you close a file descriptor that points to a file that has locks, ** all locks on that file that are owned by the current process are ** released. To work around this problem, each unixInodeInfo object -** maintains a count of the number of pending locks on tha inode. +** maintains a count of the number of pending locks on the inode. ** When an attempt is made to close an unixFile, if there are ** other unixFile open on the same inode that are holding locks, the call ** to close() the file descriptor is deferred until all of the locks clear. @@ -38315,7 +38782,7 @@ static void vxworksReleaseFileId(struct vxworksFileId *pId){ ** not posix compliant. Under LinuxThreads, a lock created by thread ** A cannot be modified or overridden by a different thread B. ** Only thread A can modify the lock. Locking behavior is correct -** if the appliation uses the newer Native Posix Thread Library (NPTL) +** if the application uses the newer Native Posix Thread Library (NPTL) ** on linux - with NPTL a lock created by thread A can override locks ** in thread B. But there is no way to know at compile-time which ** threading library is being used. So there is no way to know at @@ -38517,7 +38984,7 @@ static void storeLastErrno(unixFile *pFile, int error){ } /* -** Close all file descriptors accumuated in the unixInodeInfo->pUnused list. +** Close all file descriptors accumulated in the unixInodeInfo->pUnused list. */ static void closePendingFds(unixFile *pFile){ unixInodeInfo *pInode = pFile->pInode; @@ -38880,7 +39347,7 @@ static int unixLock(sqlite3_file *id, int eFileLock){ ** slightly in order to be compatible with Windows95 systems simultaneously ** accessing the same database file, in case that is ever required. ** - ** Symbols defined in os.h indentify the 'pending byte' and the 'reserved + ** Symbols defined in os.h identify the 'pending byte' and the 'reserved ** byte', each single bytes at well known offsets, and the 'shared byte ** range', a range of 510 bytes at a well known offset. ** @@ -38888,7 +39355,7 @@ static int unixLock(sqlite3_file *id, int eFileLock){ ** byte'. If this is successful, 'shared byte range' is read-locked ** and the lock on the 'pending byte' released. (Legacy note: When ** SQLite was first developed, Windows95 systems were still very common, - ** and Widnows95 lacks a shared-lock capability. So on Windows95, a + ** and Windows95 lacks a shared-lock capability. So on Windows95, a ** single randomly selected by from the 'shared byte range' is locked. ** Windows95 is now pretty much extinct, but this work-around for the ** lack of shared-locks on Windows95 lives on, for backwards @@ -38909,7 +39376,7 @@ static int unixLock(sqlite3_file *id, int eFileLock){ ** obtaining a write-lock on the 'pending byte'. This ensures that no new ** SHARED locks can be obtained, but existing SHARED locks are allowed to ** persist. If the call to this function fails to obtain the EXCLUSIVE - ** lock in this case, it holds the PENDING lock intead. The client may + ** lock in this case, it holds the PENDING lock instead. The client may ** then re-attempt the EXCLUSIVE lock later on, after existing SHARED ** locks have cleared. */ @@ -38937,7 +39404,7 @@ static int unixLock(sqlite3_file *id, int eFileLock){ /* Make sure the locking sequence is correct. ** (1) We never move from unlocked to anything higher than shared lock. - ** (2) SQLite never explicitly requests a pendig lock. + ** (2) SQLite never explicitly requests a pending lock. ** (3) A shared lock is always held when a reserve lock is requested. */ assert( pFile->eFileLock!=NO_LOCK || eFileLock==SHARED_LOCK ); @@ -40155,7 +40622,7 @@ static int afpLock(sqlite3_file *id, int eFileLock){ /* Make sure the locking sequence is correct ** (1) We never move from unlocked to anything higher than shared lock. - ** (2) SQLite never explicitly requests a pendig lock. + ** (2) SQLite never explicitly requests a pending lock. ** (3) A shared lock is always held when a reserve lock is requested. */ assert( pFile->eFileLock!=NO_LOCK || eFileLock==SHARED_LOCK ); @@ -40271,7 +40738,7 @@ static int afpLock(sqlite3_file *id, int eFileLock){ if( !(failed = afpSetLock(context->dbPath, pFile, SHARED_FIRST + pInode->sharedByte, 1, 0)) ){ int failed2 = SQLITE_OK; - /* now attemmpt to get the exclusive lock range */ + /* now attempt to get the exclusive lock range */ failed = afpSetLock(context->dbPath, pFile, SHARED_FIRST, SHARED_SIZE, 1); if( failed && (failed2 = afpSetLock(context->dbPath, pFile, @@ -40566,7 +41033,7 @@ static int unixRead( #endif #if SQLITE_MAX_MMAP_SIZE>0 - /* Deal with as much of this read request as possible by transfering + /* Deal with as much of this read request as possible by transferring ** data from the memory mapping using memcpy(). */ if( offsetmmapSize ){ if( offset+amt <= pFile->mmapSize ){ @@ -40718,7 +41185,7 @@ static int unixWrite( #endif #if defined(SQLITE_MMAP_READWRITE) && SQLITE_MAX_MMAP_SIZE>0 - /* Deal with as much of this write request as possible by transfering + /* Deal with as much of this write request as possible by transferring ** data from the memory mapping using memcpy(). */ if( offsetmmapSize ){ if( offset+amt <= pFile->mmapSize ){ @@ -40840,7 +41307,7 @@ static int full_fsync(int fd, int fullSync, int dataOnly){ /* If we compiled with the SQLITE_NO_SYNC flag, then syncing is a ** no-op. But go ahead and call fstat() to validate the file ** descriptor as we need a method to provoke a failure during - ** coverate testing. + ** coverage testing. */ #ifdef SQLITE_NO_SYNC { @@ -43885,12 +44352,17 @@ static int unixRandomness(sqlite3_vfs *NotUsed, int nBuf, char *zBuf){ ** than the argument. */ static int unixSleep(sqlite3_vfs *NotUsed, int microseconds){ -#if OS_VXWORKS || _POSIX_C_SOURCE >= 199309L +#if !defined(HAVE_NANOSLEEP) || HAVE_NANOSLEEP+0 struct timespec sp; - sp.tv_sec = microseconds / 1000000; sp.tv_nsec = (microseconds % 1000000) * 1000; + + /* Almost all modern unix systems support nanosleep(). But if you are + ** compiling for one of the rare exceptions, you can use + ** -DHAVE_NANOSLEEP=0 (perhaps in conjuction with -DHAVE_USLEEP if + ** usleep() is available) in order to bypass the use of nanosleep() */ nanosleep(&sp, NULL); + UNUSED_PARAMETER(NotUsed); return microseconds; #elif defined(HAVE_USLEEP) && HAVE_USLEEP @@ -46480,7 +46952,7 @@ static struct win_syscall { /* ** This is the xSetSystemCall() method of sqlite3_vfs for all of the -** "win32" VFSes. Return SQLITE_OK opon successfully updating the +** "win32" VFSes. Return SQLITE_OK upon successfully updating the ** system call pointer, or SQLITE_NOTFOUND if there is no configurable ** system call named zName. */ @@ -48060,7 +48532,7 @@ static int winRead( pFile->h, pBuf, amt, offset, pFile->locktype)); #if SQLITE_MAX_MMAP_SIZE>0 - /* Deal with as much of this read request as possible by transfering + /* Deal with as much of this read request as possible by transferring ** data from the memory mapping using memcpy(). */ if( offsetmmapSize ){ if( offset+amt <= pFile->mmapSize ){ @@ -48138,7 +48610,7 @@ static int winWrite( pFile->h, pBuf, amt, offset, pFile->locktype)); #if defined(SQLITE_MMAP_READWRITE) && SQLITE_MAX_MMAP_SIZE>0 - /* Deal with as much of this write request as possible by transfering + /* Deal with as much of this write request as possible by transferring ** data from the memory mapping using memcpy(). */ if( offsetmmapSize ){ if( offset+amt <= pFile->mmapSize ){ @@ -48248,7 +48720,7 @@ static int winTruncate(sqlite3_file *id, sqlite3_int64 nByte){ ** all references to memory-mapped content are closed. That is doable, ** but involves adding a few branches in the common write code path which ** could slow down normal operations slightly. Hence, we have decided for - ** now to simply make trancations a no-op if there are pending reads. We + ** now to simply make transactions a no-op if there are pending reads. We ** can maybe revisit this decision in the future. */ return SQLITE_OK; @@ -48307,7 +48779,7 @@ static int winTruncate(sqlite3_file *id, sqlite3_int64 nByte){ #ifdef SQLITE_TEST /* ** Count the number of fullsyncs and normal syncs. This is used to test -** that syncs and fullsyncs are occuring at the right times. +** that syncs and fullsyncs are occurring at the right times. */ SQLITE_API int sqlite3_sync_count = 0; SQLITE_API int sqlite3_fullsync_count = 0; @@ -48664,7 +49136,7 @@ static int winLock(sqlite3_file *id, int locktype){ */ if( locktype==EXCLUSIVE_LOCK && res ){ assert( pFile->locktype>=SHARED_LOCK ); - res = winUnlockReadLock(pFile); + (void)winUnlockReadLock(pFile); res = winLockFile(&pFile->h, SQLITE_LOCKFILE_FLAGS, SHARED_FIRST, 0, SHARED_SIZE, 0); if( res ){ @@ -50068,6 +50540,7 @@ static int winGetTempname(sqlite3_vfs *pVfs, char **pzBuf){ "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789"; size_t i, j; + DWORD pid; int nPre = sqlite3Strlen30(SQLITE_TEMP_FILE_PREFIX); int nMax, nBuf, nDir, nLen; char *zBuf; @@ -50280,7 +50753,10 @@ static int winGetTempname(sqlite3_vfs *pVfs, char **pzBuf){ j = sqlite3Strlen30(zBuf); sqlite3_randomness(15, &zBuf[j]); + pid = osGetCurrentProcessId(); for(i=0; i<15; i++, j++){ + zBuf[j] += pid & 0xff; + pid >>= 8; zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ]; } zBuf[j] = 0; @@ -52645,7 +53121,7 @@ SQLITE_PRIVATE int sqlite3BitvecSet(Bitvec *p, u32 i){ h = BITVEC_HASH(i++); /* if there wasn't a hash collision, and this doesn't */ /* completely fill the hash, then just add it without */ - /* worring about sub-dividing and re-hashing. */ + /* worrying about sub-dividing and re-hashing. */ if( !p->u.aHash[h] ){ if (p->nSet<(BITVEC_NINT-1)) { goto bitvec_set_end; @@ -52978,7 +53454,7 @@ struct PCache { ** Return 1 if pPg is on the dirty list for pCache. Return 0 if not. ** This routine runs inside of assert() statements only. */ -#ifdef SQLITE_DEBUG +#if defined(SQLITE_ENABLE_EXPENSIVE_ASSERT) static int pageOnDirtyList(PCache *pCache, PgHdr *pPg){ PgHdr *p; for(p=pCache->pDirty; p; p=p->pDirtyNext){ @@ -52986,6 +53462,16 @@ static int pageOnDirtyList(PCache *pCache, PgHdr *pPg){ } return 0; } +static int pageNotOnDirtyList(PCache *pCache, PgHdr *pPg){ + PgHdr *p; + for(p=pCache->pDirty; p; p=p->pDirtyNext){ + if( p==pPg ) return 0; + } + return 1; +} +#else +# define pageOnDirtyList(A,B) 1 +# define pageNotOnDirtyList(A,B) 1 #endif /* @@ -53006,7 +53492,7 @@ SQLITE_PRIVATE int sqlite3PcachePageSanity(PgHdr *pPg){ assert( pCache!=0 ); /* Every page has an associated PCache */ if( pPg->flags & PGHDR_CLEAN ){ assert( (pPg->flags & PGHDR_DIRTY)==0 );/* Cannot be both CLEAN and DIRTY */ - assert( !pageOnDirtyList(pCache, pPg) );/* CLEAN pages not on dirty list */ + assert( pageNotOnDirtyList(pCache, pPg) );/* CLEAN pages not on dirtylist */ }else{ assert( (pPg->flags & PGHDR_DIRTY)!=0 );/* If not CLEAN must be DIRTY */ assert( pPg->pDirtyNext==0 || pPg->pDirtyNext->pDirtyPrev==pPg ); @@ -53142,7 +53628,7 @@ static int numberOfCachePages(PCache *p){ return p->szCache; }else{ i64 n; - /* IMPLEMANTATION-OF: R-59858-46238 If the argument N is negative, then the + /* IMPLEMENTATION-OF: R-59858-46238 If the argument N is negative, then the ** number of cache pages is adjusted to be a number of pages that would ** use approximately abs(N*1024) bytes of memory based on the current ** page size. */ @@ -53630,7 +54116,7 @@ static PgHdr *pcacheMergeDirtyList(PgHdr *pA, PgHdr *pB){ } /* -** Sort the list of pages in accending order by pgno. Pages are +** Sort the list of pages in ascending order by pgno. Pages are ** connected by pDirty pointers. The pDirtyPrev pointers are ** corrupted by this sort. ** @@ -53870,7 +54356,7 @@ SQLITE_PRIVATE void sqlite3PcacheIterateDirty(PCache *pCache, void (*xIter)(PgHd ** If N is positive, then N pages worth of memory are allocated using a single ** sqlite3Malloc() call and that memory is used for the first N pages allocated. ** Or if N is negative, then -1024*N bytes of memory are allocated and used -** for as many pages as can be accomodated. +** for as many pages as can be accommodated. ** ** Only one of (2) or (3) can be used. Once the memory available to (2) or ** (3) is exhausted, subsequent allocations fail over to the general-purpose @@ -53904,7 +54390,7 @@ typedef struct PGroup PGroup; ** in memory directly after the associated page data, if the database is ** corrupt, code at the b-tree layer may overread the page buffer and ** read part of this structure before the corruption is detected. This -** can cause a valgrind error if the unitialized gap is accessed. Using u16 +** can cause a valgrind error if the uninitialized gap is accessed. Using u16 ** ensures there is no such gap, and therefore no bytes of uninitialized ** memory in the structure. ** @@ -55124,7 +55610,7 @@ SQLITE_PRIVATE void sqlite3PcacheStats( ** The TEST primitive includes a "batch" number. The TEST primitive ** will only see elements that were inserted before the last change ** in the batch number. In other words, if an INSERT occurs between -** two TESTs where the TESTs have the same batch nubmer, then the +** two TESTs where the TESTs have the same batch number, then the ** value added by the INSERT will not be visible to the second TEST. ** The initial batch number is zero, so if the very first TEST contains ** a non-zero batch number, it will see all prior INSERTs. @@ -55656,6 +56142,7 @@ SQLITE_PRIVATE int sqlite3RowSetTest(RowSet *pRowSet, int iBatch, sqlite3_int64 # define sqlite3WalFramesize(z) 0 # define sqlite3WalFindFrame(x,y,z) 0 # define sqlite3WalFile(x) 0 +# undef SQLITE_USE_SEH #else #define WAL_SAVEPOINT_NDATA 4 @@ -55762,6 +56249,10 @@ SQLITE_PRIVATE int sqlite3WalWriteLock(Wal *pWal, int bLock); SQLITE_PRIVATE void sqlite3WalDb(Wal *pWal, sqlite3 *db); #endif +#ifdef SQLITE_USE_SEH +SQLITE_PRIVATE int sqlite3WalSystemErrno(Wal*); +#endif + #endif /* ifndef SQLITE_OMIT_WAL */ #endif /* SQLITE_WAL_H */ @@ -56047,7 +56538,7 @@ int sqlite3PagerTrace=1; /* True to enable tracing */ ** outstanding transactions have been abandoned, the pager is able to ** transition back to OPEN state, discarding the contents of the ** page-cache and any other in-memory state at the same time. Everything -** is reloaded from disk (and, if necessary, hot-journal rollback peformed) +** is reloaded from disk (and, if necessary, hot-journal rollback performed) ** when a read-transaction is next opened on the pager (transitioning ** the pager into READER state). At that point the system has recovered ** from the error. @@ -57420,7 +57911,7 @@ static int readJournalHdr( ** + 4 bytes: super-journal name checksum. ** + 8 bytes: aJournalMagic[]. ** -** The super-journal page checksum is the sum of the bytes in thesuper-journal +** The super-journal page checksum is the sum of the bytes in the super-journal ** name, where each byte is interpreted as a signed 8-bit integer. ** ** If zSuper is a NULL pointer (occurs for a single database transaction), @@ -57473,7 +57964,7 @@ static int writeSuperJournal(Pager *pPager, const char *zSuper){ } pPager->journalOff += (nSuper+20); - /* If the pager is in peristent-journal mode, then the physical + /* If the pager is in persistent-journal mode, then the physical ** journal-file may extend past the end of the super-journal name ** and 8 bytes of magic data just written to the file. This is ** dangerous because the code to rollback a hot-journal file @@ -57643,7 +58134,7 @@ static void pager_unlock(Pager *pPager){ /* ** This function is called whenever an IOERR or FULL error that requires -** the pager to transition into the ERROR state may ahve occurred. +** the pager to transition into the ERROR state may have occurred. ** The first argument is a pointer to the pager structure, the second ** the error-code about to be returned by a pager API function. The ** value returned is a copy of the second argument to this function. @@ -57918,7 +58409,7 @@ static void pagerUnlockAndRollback(Pager *pPager){ /* ** Parameter aData must point to a buffer of pPager->pageSize bytes -** of data. Compute and return a checksum based ont the contents of the +** of data. Compute and return a checksum based on the contents of the ** page of data and the current value of pPager->cksumInit. ** ** This is not a real checksum. It is really just the sum of the @@ -58884,7 +59375,7 @@ static int pagerWalFrames( assert( pPager->pWal ); assert( pList ); #ifdef SQLITE_DEBUG - /* Verify that the page list is in accending order */ + /* Verify that the page list is in ascending order */ for(p=pList; p && p->pDirty; p=p->pDirty){ assert( p->pgno < p->pDirty->pgno ); } @@ -59015,7 +59506,7 @@ static int pagerPagecount(Pager *pPager, Pgno *pnPage){ #ifndef SQLITE_OMIT_WAL /* ** Check if the *-wal file that corresponds to the database opened by pPager -** exists if the database is not empy, or verify that the *-wal file does +** exists if the database is not empty, or verify that the *-wal file does ** not exist (by deleting it) if the database file is empty. ** ** If the database is not empty and the *-wal file exists, open the pager @@ -60425,11 +60916,7 @@ SQLITE_PRIVATE int sqlite3PagerOpen( int rc = SQLITE_OK; /* Return code */ int tempFile = 0; /* True for temp files (incl. in-memory files) */ int memDb = 0; /* True if this is an in-memory file */ -#ifndef SQLITE_OMIT_DESERIALIZE int memJM = 0; /* Memory journal mode */ -#else -# define memJM 0 -#endif int readOnly = 0; /* True if this is a read-only file */ int journalFileSize; /* Bytes to allocate for each journal fd */ char *zPathname = 0; /* Full path to database file */ @@ -60548,12 +61035,13 @@ SQLITE_PRIVATE int sqlite3PagerOpen( ** specific formatting and order of the various filenames, so if the format ** changes here, be sure to change it there as well. */ + assert( SQLITE_PTRSIZE==sizeof(Pager*) ); pPtr = (u8 *)sqlite3MallocZero( ROUND8(sizeof(*pPager)) + /* Pager structure */ ROUND8(pcacheSize) + /* PCache object */ ROUND8(pVfs->szOsFile) + /* The main db file */ journalFileSize * 2 + /* The two journal files */ - sizeof(pPager) + /* Space to hold a pointer */ + SQLITE_PTRSIZE + /* Space to hold a pointer */ 4 + /* Database prefix */ nPathname + 1 + /* database filename */ nUriByte + /* query parameters */ @@ -60574,7 +61062,7 @@ SQLITE_PRIVATE int sqlite3PagerOpen( pPager->sjfd = (sqlite3_file*)pPtr; pPtr += journalFileSize; pPager->jfd = (sqlite3_file*)pPtr; pPtr += journalFileSize; assert( EIGHT_BYTE_ALIGNMENT(pPager->jfd) ); - memcpy(pPtr, &pPager, sizeof(pPager)); pPtr += sizeof(pPager); + memcpy(pPtr, &pPager, SQLITE_PTRSIZE); pPtr += SQLITE_PTRSIZE; /* Fill in the Pager.zFilename and pPager.zQueryParam fields */ pPtr += 4; /* Skip zero prefix */ @@ -60628,9 +61116,7 @@ SQLITE_PRIVATE int sqlite3PagerOpen( int fout = 0; /* VFS flags returned by xOpen() */ rc = sqlite3OsOpen(pVfs, pPager->zFilename, pPager->fd, vfsFlags, &fout); assert( !memDb ); -#ifndef SQLITE_OMIT_DESERIALIZE pPager->memVfs = memJM = (fout&SQLITE_OPEN_MEMORY)!=0; -#endif readOnly = (fout&SQLITE_OPEN_READONLY)!=0; /* If the file was successfully opened for read/write access, @@ -60767,7 +61253,7 @@ act_like_temp_file: /* ** Return the sqlite3_file for the main database given the name -** of the corresonding WAL or Journal name as passed into +** of the corresponding WAL or Journal name as passed into ** xOpen. */ SQLITE_API sqlite3_file *sqlite3_database_file_object(const char *zName){ @@ -63052,7 +63538,7 @@ SQLITE_PRIVATE int sqlite3PagerSetJournalMode(Pager *pPager, int eMode){ assert( pPager->eState!=PAGER_ERROR ); pPager->journalMode = (u8)eMode; - /* When transistioning from TRUNCATE or PERSIST to any other journal + /* When transitioning from TRUNCATE or PERSIST to any other journal ** mode except WAL, unless the pager is in locking_mode=exclusive mode, ** delete the journal file. */ @@ -63480,6 +63966,12 @@ SQLITE_PRIVATE int sqlite3PagerWalFramesize(Pager *pPager){ } #endif +#ifdef SQLITE_USE_SEH +SQLITE_PRIVATE int sqlite3PagerWalSystemErrno(Pager *pPager){ + return sqlite3WalSystemErrno(pPager->pWal); +} +#endif + #endif /* SQLITE_OMIT_DISKIO */ /************** End of pager.c ***********************************************/ @@ -63770,7 +64262,7 @@ SQLITE_PRIVATE int sqlite3WalTrace = 0; ** ** Technically, the various VFSes are free to implement these locks however ** they see fit. However, compatibility is encouraged so that VFSes can -** interoperate. The standard implemention used on both unix and windows +** interoperate. The standard implementation used on both unix and windows ** is for the index number to indicate a byte offset into the ** WalCkptInfo.aLock[] array in the wal-index header. In other words, all ** locks are on the shm file. The WALINDEX_LOCK_OFFSET constant (which @@ -63846,7 +64338,7 @@ struct WalIndexHdr { ** the mxFrame for that reader. The value READMARK_NOT_USED (0xffffffff) ** for any aReadMark[] means that entry is unused. aReadMark[0] is ** a special case; its value is never used and it exists as a place-holder -** to avoid having to offset aReadMark[] indexs by one. Readers holding +** to avoid having to offset aReadMark[] indexes by one. Readers holding ** WAL_READ_LOCK(0) always ignore the entire WAL and read all content ** directly from the database. ** @@ -64014,7 +64506,15 @@ struct Wal { u32 iReCksum; /* On commit, recalculate checksums from here */ const char *zWalName; /* Name of WAL file */ u32 nCkpt; /* Checkpoint sequence counter in the wal-header */ +#ifdef SQLITE_USE_SEH + u32 lockMask; /* Mask of locks held */ + void *pFree; /* Pointer to sqlite3_free() if exception thrown */ + u32 *pWiValue; /* Value to write into apWiData[iWiPg] */ + int iWiPg; /* Write pWiValue into apWiData[iWiPg] */ + int iSysErrno; /* System error code following exception */ +#endif #ifdef SQLITE_DEBUG + int nSehTry; /* Number of nested SEH_TRY{} blocks */ u8 lockError; /* True if a locking error has occurred */ #endif #ifdef SQLITE_ENABLE_SNAPSHOT @@ -64096,6 +64596,113 @@ struct WalIterator { sizeof(ht_slot)*HASHTABLE_NSLOT + HASHTABLE_NPAGE*sizeof(u32) \ ) +/* +** Structured Exception Handling (SEH) is a Windows-specific technique +** for catching exceptions raised while accessing memory-mapped files. +** +** The -DSQLITE_USE_SEH compile-time option means to use SEH to catch and +** deal with system-level errors that arise during WAL -shm file processing. +** Without this compile-time option, any system-level faults that appear +** while accessing the memory-mapped -shm file will cause a process-wide +** signal to be deliver, which will more than likely cause the entire +** process to exit. +*/ +#ifdef SQLITE_USE_SEH +#include + +/* Beginning of a block of code in which an exception might occur */ +# define SEH_TRY __try { \ + assert( walAssertLockmask(pWal) && pWal->nSehTry==0 ); \ + VVA_ONLY(pWal->nSehTry++); + +/* The end of a block of code in which an exception might occur */ +# define SEH_EXCEPT(X) \ + VVA_ONLY(pWal->nSehTry--); \ + assert( pWal->nSehTry==0 ); \ + } __except( sehExceptionFilter(pWal, GetExceptionCode(), GetExceptionInformation() ) ){ X } + +/* Simulate a memory-mapping fault in the -shm file for testing purposes */ +# define SEH_INJECT_FAULT sehInjectFault(pWal) + +/* +** The second argument is the return value of GetExceptionCode() for the +** current exception. Return EXCEPTION_EXECUTE_HANDLER if the exception code +** indicates that the exception may have been caused by accessing the *-shm +** file mapping. Or EXCEPTION_CONTINUE_SEARCH otherwise. +*/ +static int sehExceptionFilter(Wal *pWal, int eCode, EXCEPTION_POINTERS *p){ + VVA_ONLY(pWal->nSehTry--); + if( eCode==EXCEPTION_IN_PAGE_ERROR ){ + if( p && p->ExceptionRecord && p->ExceptionRecord->NumberParameters>=3 ){ + /* From MSDN: For this type of exception, the first element of the + ** ExceptionInformation[] array is a read-write flag - 0 if the exception + ** was thrown while reading, 1 if while writing. The second element is + ** the virtual address being accessed. The "third array element specifies + ** the underlying NTSTATUS code that resulted in the exception". */ + pWal->iSysErrno = (int)p->ExceptionRecord->ExceptionInformation[2]; + } + return EXCEPTION_EXECUTE_HANDLER; + } + return EXCEPTION_CONTINUE_SEARCH; +} + +/* +** If one is configured, invoke the xTestCallback callback with 650 as +** the argument. If it returns true, throw the same exception that is +** thrown by the system if the *-shm file mapping is accessed after it +** has been invalidated. +*/ +static void sehInjectFault(Wal *pWal){ + int res; + assert( pWal->nSehTry>0 ); + + res = sqlite3FaultSim(650); + if( res!=0 ){ + ULONG_PTR aArg[3]; + aArg[0] = 0; + aArg[1] = 0; + aArg[2] = (ULONG_PTR)res; + RaiseException(EXCEPTION_IN_PAGE_ERROR, 0, 3, (const ULONG_PTR*)aArg); + } +} + +/* +** There are two ways to use this macro. To set a pointer to be freed +** if an exception is thrown: +** +** SEH_FREE_ON_ERROR(0, pPtr); +** +** and to cancel the same: +** +** SEH_FREE_ON_ERROR(pPtr, 0); +** +** In the first case, there must not already be a pointer registered to +** be freed. In the second case, pPtr must be the registered pointer. +*/ +#define SEH_FREE_ON_ERROR(X,Y) \ + assert( (X==0 || Y==0) && pWal->pFree==X ); pWal->pFree = Y + +/* +** There are two ways to use this macro. To arrange for pWal->apWiData[iPg] +** to be set to pValue if an exception is thrown: +** +** SEH_SET_ON_ERROR(iPg, pValue); +** +** and to cancel the same: +** +** SEH_SET_ON_ERROR(0, 0); +*/ +#define SEH_SET_ON_ERROR(X,Y) pWal->iWiPg = X; pWal->pWiValue = Y + +#else +# define SEH_TRY VVA_ONLY(pWal->nSehTry++); +# define SEH_EXCEPT(X) VVA_ONLY(pWal->nSehTry--); assert( pWal->nSehTry==0 ); +# define SEH_INJECT_FAULT assert( pWal->nSehTry>0 ); +# define SEH_FREE_ON_ERROR(X,Y) +# define SEH_SET_ON_ERROR(X,Y) +#endif /* ifdef SQLITE_USE_SEH */ + + /* ** Obtain a pointer to the iPage'th page of the wal-index. The wal-index ** is broken into pages of WALINDEX_PGSZ bytes. Wal-index pages are @@ -64168,6 +64775,7 @@ static int walIndexPage( int iPage, /* The page we seek */ volatile u32 **ppPage /* Write the page pointer here */ ){ + SEH_INJECT_FAULT; if( pWal->nWiData<=iPage || (*ppPage = pWal->apWiData[iPage])==0 ){ return walIndexPageRealloc(pWal, iPage, ppPage); } @@ -64179,6 +64787,7 @@ static int walIndexPage( */ static volatile WalCkptInfo *walCkptInfo(Wal *pWal){ assert( pWal->nWiData>0 && pWal->apWiData[0] ); + SEH_INJECT_FAULT; return (volatile WalCkptInfo*)&(pWal->apWiData[0][sizeof(WalIndexHdr)/2]); } @@ -64187,6 +64796,7 @@ static volatile WalCkptInfo *walCkptInfo(Wal *pWal){ */ static volatile WalIndexHdr *walIndexHdr(Wal *pWal){ assert( pWal->nWiData>0 && pWal->apWiData[0] ); + SEH_INJECT_FAULT; return (volatile WalIndexHdr*)pWal->apWiData[0]; } @@ -64376,7 +64986,7 @@ static int walDecodeFrame( return 0; } - /* A frame is only valid if the page number is creater than zero. + /* A frame is only valid if the page number is greater than zero. */ pgno = sqlite3Get4byte(&aFrame[0]); if( pgno==0 ){ @@ -64384,7 +64994,7 @@ static int walDecodeFrame( } /* A frame is only valid if a checksum of the WAL header, - ** all prior frams, the first 16 bytes of this frame-header, + ** all prior frames, the first 16 bytes of this frame-header, ** and the frame-data matches the checksum in the last 8 ** bytes of this frame-header. */ @@ -64444,12 +65054,18 @@ static int walLockShared(Wal *pWal, int lockIdx){ WALTRACE(("WAL%p: acquire SHARED-%s %s\n", pWal, walLockName(lockIdx), rc ? "failed" : "ok")); VVA_ONLY( pWal->lockError = (u8)(rc!=SQLITE_OK && (rc&0xFF)!=SQLITE_BUSY); ) +#ifdef SQLITE_USE_SEH + if( rc==SQLITE_OK ) pWal->lockMask |= (1 << lockIdx); +#endif return rc; } static void walUnlockShared(Wal *pWal, int lockIdx){ if( pWal->exclusiveMode ) return; (void)sqlite3OsShmLock(pWal->pDbFd, lockIdx, 1, SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED); +#ifdef SQLITE_USE_SEH + pWal->lockMask &= ~(1 << lockIdx); +#endif WALTRACE(("WAL%p: release SHARED-%s\n", pWal, walLockName(lockIdx))); } static int walLockExclusive(Wal *pWal, int lockIdx, int n){ @@ -64460,12 +65076,20 @@ static int walLockExclusive(Wal *pWal, int lockIdx, int n){ WALTRACE(("WAL%p: acquire EXCLUSIVE-%s cnt=%d %s\n", pWal, walLockName(lockIdx), n, rc ? "failed" : "ok")); VVA_ONLY( pWal->lockError = (u8)(rc!=SQLITE_OK && (rc&0xFF)!=SQLITE_BUSY); ) +#ifdef SQLITE_USE_SEH + if( rc==SQLITE_OK ){ + pWal->lockMask |= (((1<exclusiveMode ) return; (void)sqlite3OsShmLock(pWal->pDbFd, lockIdx, n, SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE); +#ifdef SQLITE_USE_SEH + pWal->lockMask &= ~(((1<apWiData[0][WALINDEX_HDR_SIZE/sizeof(u32) + iFrame - 1]; } @@ -64816,6 +65441,7 @@ static int walIndexRecover(Wal *pWal){ /* Malloc a buffer to read frames into. */ szFrame = szPage + WAL_FRAME_HDRSIZE; aFrame = (u8 *)sqlite3_malloc64(szFrame + WALINDEX_PGSZ); + SEH_FREE_ON_ERROR(0, aFrame); if( !aFrame ){ rc = SQLITE_NOMEM_BKPT; goto recovery_error; @@ -64834,6 +65460,7 @@ static int walIndexRecover(Wal *pWal){ rc = walIndexPage(pWal, iPg, (volatile u32**)&aShare); assert( aShare!=0 || rc!=SQLITE_OK ); if( aShare==0 ) break; + SEH_SET_ON_ERROR(iPg, aShare); pWal->apWiData[iPg] = aPrivate; for(iFrame=iFirst; iFrame<=iLast; iFrame++){ @@ -64861,6 +65488,7 @@ static int walIndexRecover(Wal *pWal){ } } pWal->apWiData[iPg] = aShare; + SEH_SET_ON_ERROR(0,0); nHdr = (iPg==0 ? WALINDEX_HDR_SIZE : 0); nHdr32 = nHdr / sizeof(u32); #ifndef SQLITE_SAFER_WALINDEX_RECOVERY @@ -64891,9 +65519,11 @@ static int walIndexRecover(Wal *pWal){ } } #endif + SEH_INJECT_FAULT; if( iFrame<=iLast ) break; } + SEH_FREE_ON_ERROR(aFrame, 0); sqlite3_free(aFrame); } @@ -64921,6 +65551,7 @@ finished: }else{ pInfo->aReadMark[i] = READMARK_NOT_USED; } + SEH_INJECT_FAULT; walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1); }else if( rc!=SQLITE_BUSY ){ goto recovery_error; @@ -65078,7 +65709,7 @@ SQLITE_PRIVATE int sqlite3WalOpen( } /* -** Change the size to which the WAL file is trucated on each reset. +** Change the size to which the WAL file is truncated on each reset. */ SQLITE_PRIVATE void sqlite3WalLimit(Wal *pWal, i64 iLimit){ if( pWal ) pWal->mxWalSize = iLimit; @@ -65304,23 +65935,16 @@ static int walIteratorInit(Wal *pWal, u32 nBackfill, WalIterator **pp){ nByte = sizeof(WalIterator) + (nSegment-1)*sizeof(struct WalSegment) + iLast*sizeof(ht_slot); - p = (WalIterator *)sqlite3_malloc64(nByte); + p = (WalIterator *)sqlite3_malloc64(nByte + + sizeof(ht_slot) * (iLast>HASHTABLE_NPAGE?HASHTABLE_NPAGE:iLast) + ); if( !p ){ return SQLITE_NOMEM_BKPT; } memset(p, 0, nByte); p->nSegment = nSegment; - - /* Allocate temporary space used by the merge-sort routine. This block - ** of memory will be freed before this function returns. - */ - aTmp = (ht_slot *)sqlite3_malloc64( - sizeof(ht_slot) * (iLast>HASHTABLE_NPAGE?HASHTABLE_NPAGE:iLast) - ); - if( !aTmp ){ - rc = SQLITE_NOMEM_BKPT; - } - + aTmp = (ht_slot*)&(((u8*)p)[nByte]); + SEH_FREE_ON_ERROR(0, p); for(i=walFramePage(nBackfill+1); rc==SQLITE_OK && iaSegment[i].aPgno = (u32 *)sLoc.aPgno; } } - sqlite3_free(aTmp); - if( rc!=SQLITE_OK ){ + SEH_FREE_ON_ERROR(p, 0); walIteratorFree(p); p = 0; } @@ -65576,13 +66199,13 @@ static int walCheckpoint( mxSafeFrame = pWal->hdr.mxFrame; mxPage = pWal->hdr.nPage; for(i=1; iaReadMark+i); + u32 y = AtomicLoad(pInfo->aReadMark+i); SEH_INJECT_FAULT; if( mxSafeFrame>y ){ assert( y<=pWal->hdr.mxFrame ); rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(i), 1); if( rc==SQLITE_OK ){ u32 iMark = (i==1 ? mxSafeFrame : READMARK_NOT_USED); - AtomicStore(pInfo->aReadMark+i, iMark); + AtomicStore(pInfo->aReadMark+i, iMark); SEH_INJECT_FAULT; walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1); }else if( rc==SQLITE_BUSY ){ mxSafeFrame = y; @@ -65603,8 +66226,7 @@ static int walCheckpoint( && (rc = walBusyLock(pWal,xBusy,pBusyArg,WAL_READ_LOCK(0),1))==SQLITE_OK ){ u32 nBackfill = pInfo->nBackfill; - - pInfo->nBackfillAttempted = mxSafeFrame; + pInfo->nBackfillAttempted = mxSafeFrame; SEH_INJECT_FAULT; /* Sync the WAL to disk */ rc = sqlite3OsSync(pWal->pWalFd, CKPT_SYNC_FLAGS(sync_flags)); @@ -65635,6 +66257,7 @@ static int walCheckpoint( while( rc==SQLITE_OK && 0==walIteratorNext(pIter, &iDbpage, &iFrame) ){ i64 iOffset; assert( walFramePgno(pWal, iFrame)==iDbpage ); + SEH_INJECT_FAULT; if( AtomicLoad(&db->u1.isInterrupted) ){ rc = db->mallocFailed ? SQLITE_NOMEM_BKPT : SQLITE_INTERRUPT; break; @@ -65664,7 +66287,7 @@ static int walCheckpoint( } } if( rc==SQLITE_OK ){ - AtomicStore(&pInfo->nBackfill, mxSafeFrame); + AtomicStore(&pInfo->nBackfill, mxSafeFrame); SEH_INJECT_FAULT; } } @@ -65686,6 +66309,7 @@ static int walCheckpoint( */ if( rc==SQLITE_OK && eMode!=SQLITE_CHECKPOINT_PASSIVE ){ assert( pWal->writeLock ); + SEH_INJECT_FAULT; if( pInfo->nBackfillhdr.mxFrame ){ rc = SQLITE_BUSY; }else if( eMode>=SQLITE_CHECKPOINT_RESTART ){ @@ -65717,6 +66341,7 @@ static int walCheckpoint( } walcheckpoint_out: + SEH_FREE_ON_ERROR(pIter, 0); walIteratorFree(pIter); return rc; } @@ -65739,6 +66364,93 @@ static void walLimitSize(Wal *pWal, i64 nMax){ } } +#ifdef SQLITE_USE_SEH +/* +** This is the "standard" exception handler used in a few places to handle +** an exception thrown by reading from the *-shm mapping after it has become +** invalid in SQLITE_USE_SEH builds. It is used as follows: +** +** SEH_TRY { ... } +** SEH_EXCEPT( rc = walHandleException(pWal); ) +** +** This function does three things: +** +** 1) Determines the locks that should be held, based on the contents of +** the Wal.readLock, Wal.writeLock and Wal.ckptLock variables. All other +** held locks are assumed to be transient locks that would have been +** released had the exception not been thrown and are dropped. +** +** 2) Frees the pointer at Wal.pFree, if any, using sqlite3_free(). +** +** 3) Set pWal->apWiData[pWal->iWiPg] to pWal->pWiValue if not NULL +** +** 4) Returns SQLITE_IOERR. +*/ +static int walHandleException(Wal *pWal){ + if( pWal->exclusiveMode==0 ){ + static const int S = 1; + static const int E = (1<lockMask & ~( + (pWal->readLock<0 ? 0 : (S << WAL_READ_LOCK(pWal->readLock))) + | (pWal->writeLock ? (E << WAL_WRITE_LOCK) : 0) + | (pWal->ckptLock ? (E << WAL_CKPT_LOCK) : 0) + ); + for(ii=0; iipFree); + pWal->pFree = 0; + if( pWal->pWiValue ){ + pWal->apWiData[pWal->iWiPg] = pWal->pWiValue; + pWal->pWiValue = 0; + } + return SQLITE_IOERR_IN_PAGE; +} + +/* +** Assert that the Wal.lockMask mask, which indicates the locks held +** by the connenction, is consistent with the Wal.readLock, Wal.writeLock +** and Wal.ckptLock variables. To be used as: +** +** assert( walAssertLockmask(pWal) ); +*/ +static int walAssertLockmask(Wal *pWal){ + if( pWal->exclusiveMode==0 ){ + static const int S = 1; + static const int E = (1<readLock<0 ? 0 : (S << WAL_READ_LOCK(pWal->readLock))) + | (pWal->writeLock ? (E << WAL_WRITE_LOCK) : 0) + | (pWal->ckptLock ? (E << WAL_CKPT_LOCK) : 0) +#ifdef SQLITE_ENABLE_SNAPSHOT + | (pWal->pSnapshot ? (pWal->lockMask & (1 << WAL_CKPT_LOCK)) : 0) +#endif + ); + assert( mExpect==pWal->lockMask ); + } + return 1; +} + +/* +** Return and zero the "system error" field set when an +** EXCEPTION_IN_PAGE_ERROR exception is caught. +*/ +SQLITE_PRIVATE int sqlite3WalSystemErrno(Wal *pWal){ + int iRet = 0; + if( pWal ){ + iRet = pWal->iSysErrno; + pWal->iSysErrno = 0; + } + return iRet; +} + +#else +# define walAssertLockmask(x) 1 +#endif /* ifdef SQLITE_USE_SEH */ + /* ** Close a connection to a log file. */ @@ -65753,6 +66465,8 @@ SQLITE_PRIVATE int sqlite3WalClose( if( pWal ){ int isDelete = 0; /* True to unlink wal and wal-index files */ + assert( walAssertLockmask(pWal) ); + /* If an EXCLUSIVE lock can be obtained on the database file (using the ** ordinary, rollback-mode locking methods, this guarantees that the ** connection associated with this log file is the only connection to @@ -65777,7 +66491,7 @@ SQLITE_PRIVATE int sqlite3WalClose( ); if( bPersist!=1 ){ /* Try to delete the WAL file if the checkpoint completed and - ** fsyned (rc==SQLITE_OK) and if we are not in persistent-wal + ** fsynced (rc==SQLITE_OK) and if we are not in persistent-wal ** mode (!bPersist) */ isDelete = 1; }else if( pWal->mxWalSize>=0 ){ @@ -65844,7 +66558,7 @@ static SQLITE_NO_TSAN int walIndexTryHdr(Wal *pWal, int *pChanged){ ** give false-positive warnings about these accesses because the tools do not ** account for the double-read and the memory barrier. The use of mutexes ** here would be problematic as the memory being accessed is potentially - ** shared among multiple processes and not all mutex implementions work + ** shared among multiple processes and not all mutex implementations work ** reliably in that environment. */ aHdr = walIndexHdr(pWal); @@ -66295,6 +67009,7 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){ assert( pWal->nWiData>0 ); assert( pWal->apWiData[0]!=0 ); pInfo = walCkptInfo(pWal); + SEH_INJECT_FAULT; if( !useWal && AtomicLoad(&pInfo->nBackfill)==pWal->hdr.mxFrame #ifdef SQLITE_ENABLE_SNAPSHOT && (pWal->pSnapshot==0 || pWal->hdr.mxFrame==0) @@ -66344,7 +67059,7 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){ } #endif for(i=1; iaReadMark+i); + u32 thisMark = AtomicLoad(pInfo->aReadMark+i); SEH_INJECT_FAULT; if( mxReadMark<=thisMark && thisMark<=mxFrame ){ assert( thisMark!=READMARK_NOT_USED ); mxReadMark = thisMark; @@ -66410,7 +67125,7 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){ ** we can guarantee that the checkpointer that set nBackfill could not ** see any pages past pWal->hdr.mxFrame, this problem does not come up. */ - pWal->minFrame = AtomicLoad(&pInfo->nBackfill)+1; + pWal->minFrame = AtomicLoad(&pInfo->nBackfill)+1; SEH_INJECT_FAULT; walShmBarrier(pWal); if( AtomicLoad(pInfo->aReadMark+mxI)!=mxReadMark || memcmp((void *)walIndexHdr(pWal), &pWal->hdr, sizeof(WalIndexHdr)) @@ -66425,6 +67140,54 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){ } #ifdef SQLITE_ENABLE_SNAPSHOT +/* +** This function does the work of sqlite3WalSnapshotRecover(). +*/ +static int walSnapshotRecover( + Wal *pWal, /* WAL handle */ + void *pBuf1, /* Temp buffer pWal->szPage bytes in size */ + void *pBuf2 /* Temp buffer pWal->szPage bytes in size */ +){ + int szPage = (int)pWal->szPage; + int rc; + i64 szDb; /* Size of db file in bytes */ + + rc = sqlite3OsFileSize(pWal->pDbFd, &szDb); + if( rc==SQLITE_OK ){ + volatile WalCkptInfo *pInfo = walCkptInfo(pWal); + u32 i = pInfo->nBackfillAttempted; + for(i=pInfo->nBackfillAttempted; i>AtomicLoad(&pInfo->nBackfill); i--){ + WalHashLoc sLoc; /* Hash table location */ + u32 pgno; /* Page number in db file */ + i64 iDbOff; /* Offset of db file entry */ + i64 iWalOff; /* Offset of wal file entry */ + + rc = walHashGet(pWal, walFramePage(i), &sLoc); + if( rc!=SQLITE_OK ) break; + assert( i - sLoc.iZero - 1 >=0 ); + pgno = sLoc.aPgno[i-sLoc.iZero-1]; + iDbOff = (i64)(pgno-1) * szPage; + + if( iDbOff+szPage<=szDb ){ + iWalOff = walFrameOffset(i, szPage) + WAL_FRAME_HDRSIZE; + rc = sqlite3OsRead(pWal->pWalFd, pBuf1, szPage, iWalOff); + + if( rc==SQLITE_OK ){ + rc = sqlite3OsRead(pWal->pDbFd, pBuf2, szPage, iDbOff); + } + + if( rc!=SQLITE_OK || 0==memcmp(pBuf1, pBuf2, szPage) ){ + break; + } + } + + pInfo->nBackfillAttempted = i-1; + } + } + + return rc; +} + /* ** Attempt to reduce the value of the WalCkptInfo.nBackfillAttempted ** variable so that older snapshots can be accessed. To do this, loop @@ -66450,50 +67213,21 @@ SQLITE_PRIVATE int sqlite3WalSnapshotRecover(Wal *pWal){ assert( pWal->readLock>=0 ); rc = walLockExclusive(pWal, WAL_CKPT_LOCK, 1); if( rc==SQLITE_OK ){ - volatile WalCkptInfo *pInfo = walCkptInfo(pWal); - int szPage = (int)pWal->szPage; - i64 szDb; /* Size of db file in bytes */ - - rc = sqlite3OsFileSize(pWal->pDbFd, &szDb); - if( rc==SQLITE_OK ){ - void *pBuf1 = sqlite3_malloc(szPage); - void *pBuf2 = sqlite3_malloc(szPage); - if( pBuf1==0 || pBuf2==0 ){ - rc = SQLITE_NOMEM; - }else{ - u32 i = pInfo->nBackfillAttempted; - for(i=pInfo->nBackfillAttempted; i>AtomicLoad(&pInfo->nBackfill); i--){ - WalHashLoc sLoc; /* Hash table location */ - u32 pgno; /* Page number in db file */ - i64 iDbOff; /* Offset of db file entry */ - i64 iWalOff; /* Offset of wal file entry */ - - rc = walHashGet(pWal, walFramePage(i), &sLoc); - if( rc!=SQLITE_OK ) break; - assert( i - sLoc.iZero - 1 >=0 ); - pgno = sLoc.aPgno[i-sLoc.iZero-1]; - iDbOff = (i64)(pgno-1) * szPage; - - if( iDbOff+szPage<=szDb ){ - iWalOff = walFrameOffset(i, szPage) + WAL_FRAME_HDRSIZE; - rc = sqlite3OsRead(pWal->pWalFd, pBuf1, szPage, iWalOff); - - if( rc==SQLITE_OK ){ - rc = sqlite3OsRead(pWal->pDbFd, pBuf2, szPage, iDbOff); - } - - if( rc!=SQLITE_OK || 0==memcmp(pBuf1, pBuf2, szPage) ){ - break; - } - } - - pInfo->nBackfillAttempted = i-1; - } + void *pBuf1 = sqlite3_malloc(pWal->szPage); + void *pBuf2 = sqlite3_malloc(pWal->szPage); + if( pBuf1==0 || pBuf2==0 ){ + rc = SQLITE_NOMEM; + }else{ + pWal->ckptLock = 1; + SEH_TRY { + rc = walSnapshotRecover(pWal, pBuf1, pBuf2); } - - sqlite3_free(pBuf1); - sqlite3_free(pBuf2); + SEH_EXCEPT( rc = SQLITE_IOERR_IN_PAGE; ) + pWal->ckptLock = 0; } + + sqlite3_free(pBuf1); + sqlite3_free(pBuf2); walUnlockExclusive(pWal, WAL_CKPT_LOCK, 1); } @@ -66502,28 +67236,20 @@ SQLITE_PRIVATE int sqlite3WalSnapshotRecover(Wal *pWal){ #endif /* SQLITE_ENABLE_SNAPSHOT */ /* -** Begin a read transaction on the database. -** -** This routine used to be called sqlite3OpenSnapshot() and with good reason: -** it takes a snapshot of the state of the WAL and wal-index for the current -** instant in time. The current thread will continue to use this snapshot. -** Other threads might append new content to the WAL and wal-index but -** that extra content is ignored by the current thread. -** -** If the database contents have changes since the previous read -** transaction, then *pChanged is set to 1 before returning. The -** Pager layer will use this to know that its cache is stale and -** needs to be flushed. +** This function does the work of sqlite3WalBeginReadTransaction() (see +** below). That function simply calls this one inside an SEH_TRY{...} block. */ -SQLITE_PRIVATE int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){ +static int walBeginReadTransaction(Wal *pWal, int *pChanged){ int rc; /* Return code */ int cnt = 0; /* Number of TryBeginRead attempts */ #ifdef SQLITE_ENABLE_SNAPSHOT + int ckptLock = 0; int bChanged = 0; WalIndexHdr *pSnapshot = pWal->pSnapshot; #endif assert( pWal->ckptLock==0 ); + assert( pWal->nSehTry>0 ); #ifdef SQLITE_ENABLE_SNAPSHOT if( pSnapshot ){ @@ -66546,7 +67272,7 @@ SQLITE_PRIVATE int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){ if( rc!=SQLITE_OK ){ return rc; } - pWal->ckptLock = 1; + ckptLock = 1; } #endif @@ -66610,15 +67336,37 @@ SQLITE_PRIVATE int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){ } /* Release the shared CKPT lock obtained above. */ - if( pWal->ckptLock ){ + if( ckptLock ){ assert( pSnapshot ); walUnlockShared(pWal, WAL_CKPT_LOCK); - pWal->ckptLock = 0; } #endif return rc; } +/* +** Begin a read transaction on the database. +** +** This routine used to be called sqlite3OpenSnapshot() and with good reason: +** it takes a snapshot of the state of the WAL and wal-index for the current +** instant in time. The current thread will continue to use this snapshot. +** Other threads might append new content to the WAL and wal-index but +** that extra content is ignored by the current thread. +** +** If the database contents have changes since the previous read +** transaction, then *pChanged is set to 1 before returning. The +** Pager layer will use this to know that its cache is stale and +** needs to be flushed. +*/ +SQLITE_PRIVATE int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){ + int rc; + SEH_TRY { + rc = walBeginReadTransaction(pWal, pChanged); + } + SEH_EXCEPT( rc = walHandleException(pWal); ) + return rc; +} + /* ** Finish with a read transaction. All this does is release the ** read-lock. @@ -66639,7 +67387,7 @@ SQLITE_PRIVATE void sqlite3WalEndReadTransaction(Wal *pWal){ ** Return SQLITE_OK if successful, or an error code if an error occurs. If an ** error does occur, the final value of *piRead is undefined. */ -SQLITE_PRIVATE int sqlite3WalFindFrame( +static int walFindFrame( Wal *pWal, /* WAL handle */ Pgno pgno, /* Database page number to read data for */ u32 *piRead /* OUT: Frame number (or zero) */ @@ -66702,6 +67450,7 @@ SQLITE_PRIVATE int sqlite3WalFindFrame( } nCollide = HASHTABLE_NSLOT; iKey = walHash(pgno); + SEH_INJECT_FAULT; while( (iH = AtomicLoad(&sLoc.aHash[iKey]))!=0 ){ u32 iFrame = iH + sLoc.iZero; if( iFrame<=iLast && iFrame>=pWal->minFrame && sLoc.aPgno[iH-1]==pgno ){ @@ -66738,6 +67487,30 @@ SQLITE_PRIVATE int sqlite3WalFindFrame( return SQLITE_OK; } +/* +** Search the wal file for page pgno. If found, set *piRead to the frame that +** contains the page. Otherwise, if pgno is not in the wal file, set *piRead +** to zero. +** +** Return SQLITE_OK if successful, or an error code if an error occurs. If an +** error does occur, the final value of *piRead is undefined. +** +** The difference between this function and walFindFrame() is that this +** function wraps walFindFrame() in an SEH_TRY{...} block. +*/ +SQLITE_PRIVATE int sqlite3WalFindFrame( + Wal *pWal, /* WAL handle */ + Pgno pgno, /* Database page number to read data for */ + u32 *piRead /* OUT: Frame number (or zero) */ +){ + int rc; + SEH_TRY { + rc = walFindFrame(pWal, pgno, piRead); + } + SEH_EXCEPT( rc = SQLITE_IOERR_IN_PAGE; ) + return rc; +} + /* ** Read the contents of frame iRead from the wal file into buffer pOut ** (which is nOut bytes in size). Return SQLITE_OK if successful, or an @@ -66819,12 +67592,17 @@ SQLITE_PRIVATE int sqlite3WalBeginWriteTransaction(Wal *pWal){ ** time the read transaction on this connection was started, then ** the write is disallowed. */ - if( memcmp(&pWal->hdr, (void *)walIndexHdr(pWal), sizeof(WalIndexHdr))!=0 ){ + SEH_TRY { + if( memcmp(&pWal->hdr, (void *)walIndexHdr(pWal), sizeof(WalIndexHdr))!=0 ){ + rc = SQLITE_BUSY_SNAPSHOT; + } + } + SEH_EXCEPT( rc = SQLITE_IOERR_IN_PAGE; ) + + if( rc!=SQLITE_OK ){ walUnlockExclusive(pWal, WAL_WRITE_LOCK, 1); pWal->writeLock = 0; - rc = SQLITE_BUSY_SNAPSHOT; } - return rc; } @@ -66860,30 +67638,33 @@ SQLITE_PRIVATE int sqlite3WalUndo(Wal *pWal, int (*xUndo)(void *, Pgno), void *p Pgno iMax = pWal->hdr.mxFrame; Pgno iFrame; - /* Restore the clients cache of the wal-index header to the state it - ** was in before the client began writing to the database. - */ - memcpy(&pWal->hdr, (void *)walIndexHdr(pWal), sizeof(WalIndexHdr)); - - for(iFrame=pWal->hdr.mxFrame+1; - ALWAYS(rc==SQLITE_OK) && iFrame<=iMax; - iFrame++ - ){ - /* This call cannot fail. Unless the page for which the page number - ** is passed as the second argument is (a) in the cache and - ** (b) has an outstanding reference, then xUndo is either a no-op - ** (if (a) is false) or simply expels the page from the cache (if (b) - ** is false). - ** - ** If the upper layer is doing a rollback, it is guaranteed that there - ** are no outstanding references to any page other than page 1. And - ** page 1 is never written to the log until the transaction is - ** committed. As a result, the call to xUndo may not fail. + SEH_TRY { + /* Restore the clients cache of the wal-index header to the state it + ** was in before the client began writing to the database. */ - assert( walFramePgno(pWal, iFrame)!=1 ); - rc = xUndo(pUndoCtx, walFramePgno(pWal, iFrame)); + memcpy(&pWal->hdr, (void *)walIndexHdr(pWal), sizeof(WalIndexHdr)); + + for(iFrame=pWal->hdr.mxFrame+1; + ALWAYS(rc==SQLITE_OK) && iFrame<=iMax; + iFrame++ + ){ + /* This call cannot fail. Unless the page for which the page number + ** is passed as the second argument is (a) in the cache and + ** (b) has an outstanding reference, then xUndo is either a no-op + ** (if (a) is false) or simply expels the page from the cache (if (b) + ** is false). + ** + ** If the upper layer is doing a rollback, it is guaranteed that there + ** are no outstanding references to any page other than page 1. And + ** page 1 is never written to the log until the transaction is + ** committed. As a result, the call to xUndo may not fail. + */ + assert( walFramePgno(pWal, iFrame)!=1 ); + rc = xUndo(pUndoCtx, walFramePgno(pWal, iFrame)); + } + if( iMax!=pWal->hdr.mxFrame ) walCleanupHash(pWal); } - if( iMax!=pWal->hdr.mxFrame ) walCleanupHash(pWal); + SEH_EXCEPT( rc = SQLITE_IOERR_IN_PAGE; ) } return rc; } @@ -66927,7 +67708,10 @@ SQLITE_PRIVATE int sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData){ pWal->hdr.mxFrame = aWalData[0]; pWal->hdr.aFrameCksum[0] = aWalData[1]; pWal->hdr.aFrameCksum[1] = aWalData[2]; - walCleanupHash(pWal); + SEH_TRY { + walCleanupHash(pWal); + } + SEH_EXCEPT( rc = SQLITE_IOERR_IN_PAGE; ) } return rc; @@ -67108,7 +67892,7 @@ static int walRewriteChecksums(Wal *pWal, u32 iLast){ ** Write a set of frames to the log. The caller must hold the write-lock ** on the log file (obtained using sqlite3WalBeginWriteTransaction()). */ -SQLITE_PRIVATE int sqlite3WalFrames( +static int walFrames( Wal *pWal, /* Wal handle to write to */ int szPage, /* Database page-size in bytes */ PgHdr *pList, /* List of dirty pages to write */ @@ -67219,7 +68003,7 @@ SQLITE_PRIVATE int sqlite3WalFrames( ** checksums must be recomputed when the transaction is committed. */ if( iFirst && (p->pDirty || isCommit==0) ){ u32 iWrite = 0; - VVA_ONLY(rc =) sqlite3WalFindFrame(pWal, p->pgno, &iWrite); + VVA_ONLY(rc =) walFindFrame(pWal, p->pgno, &iWrite); assert( rc==SQLITE_OK || iWrite==0 ); if( iWrite>=iFirst ){ i64 iOff = walFrameOffset(iWrite, szPage) + WAL_FRAME_HDRSIZE; @@ -67338,6 +68122,29 @@ SQLITE_PRIVATE int sqlite3WalFrames( return rc; } +/* +** Write a set of frames to the log. The caller must hold the write-lock +** on the log file (obtained using sqlite3WalBeginWriteTransaction()). +** +** The difference between this function and walFrames() is that this +** function wraps walFrames() in an SEH_TRY{...} block. +*/ +SQLITE_PRIVATE int sqlite3WalFrames( + Wal *pWal, /* Wal handle to write to */ + int szPage, /* Database page-size in bytes */ + PgHdr *pList, /* List of dirty pages to write */ + Pgno nTruncate, /* Database size after this commit */ + int isCommit, /* True if this is a commit */ + int sync_flags /* Flags to pass to OsSync() (or 0) */ +){ + int rc; + SEH_TRY { + rc = walFrames(pWal, szPage, pList, nTruncate, isCommit, sync_flags); + } + SEH_EXCEPT( rc = walHandleException(pWal); ) + return rc; +} + /* ** This routine is called to implement sqlite3_wal_checkpoint() and ** related interfaces. @@ -67417,30 +68224,33 @@ SQLITE_PRIVATE int sqlite3WalCheckpoint( /* Read the wal-index header. */ - if( rc==SQLITE_OK ){ - walDisableBlocking(pWal); - rc = walIndexReadHdr(pWal, &isChanged); - (void)walEnableBlocking(pWal); - if( isChanged && pWal->pDbFd->pMethods->iVersion>=3 ){ - sqlite3OsUnfetch(pWal->pDbFd, 0, 0); - } - } - - /* Copy data from the log to the database file. */ - if( rc==SQLITE_OK ){ - - if( pWal->hdr.mxFrame && walPagesize(pWal)!=nBuf ){ - rc = SQLITE_CORRUPT_BKPT; - }else{ - rc = walCheckpoint(pWal, db, eMode2, xBusy2, pBusyArg, sync_flags, zBuf); - } - - /* If no error occurred, set the output variables. */ - if( rc==SQLITE_OK || rc==SQLITE_BUSY ){ - if( pnLog ) *pnLog = (int)pWal->hdr.mxFrame; - if( pnCkpt ) *pnCkpt = (int)(walCkptInfo(pWal)->nBackfill); + SEH_TRY { + if( rc==SQLITE_OK ){ + walDisableBlocking(pWal); + rc = walIndexReadHdr(pWal, &isChanged); + (void)walEnableBlocking(pWal); + if( isChanged && pWal->pDbFd->pMethods->iVersion>=3 ){ + sqlite3OsUnfetch(pWal->pDbFd, 0, 0); + } + } + + /* Copy data from the log to the database file. */ + if( rc==SQLITE_OK ){ + if( pWal->hdr.mxFrame && walPagesize(pWal)!=nBuf ){ + rc = SQLITE_CORRUPT_BKPT; + }else{ + rc = walCheckpoint(pWal, db, eMode2, xBusy2, pBusyArg, sync_flags,zBuf); + } + + /* If no error occurred, set the output variables. */ + if( rc==SQLITE_OK || rc==SQLITE_BUSY ){ + if( pnLog ) *pnLog = (int)pWal->hdr.mxFrame; + SEH_INJECT_FAULT; + if( pnCkpt ) *pnCkpt = (int)(walCkptInfo(pWal)->nBackfill); + } } } + SEH_EXCEPT( rc = walHandleException(pWal); ) if( isChanged ){ /* If a new wal-index header was loaded before the checkpoint was @@ -67517,7 +68327,9 @@ SQLITE_PRIVATE int sqlite3WalExclusiveMode(Wal *pWal, int op){ ** locks are taken in this case). Nor should the pager attempt to ** upgrade to exclusive-mode following such an error. */ +#ifndef SQLITE_USE_SEH assert( pWal->readLock>=0 || pWal->lockError ); +#endif assert( pWal->readLock>=0 || (op<=0 && pWal->exclusiveMode==0) ); if( op==0 ){ @@ -67618,16 +68430,19 @@ SQLITE_API int sqlite3_snapshot_cmp(sqlite3_snapshot *p1, sqlite3_snapshot *p2){ */ SQLITE_PRIVATE int sqlite3WalSnapshotCheck(Wal *pWal, sqlite3_snapshot *pSnapshot){ int rc; - rc = walLockShared(pWal, WAL_CKPT_LOCK); - if( rc==SQLITE_OK ){ - WalIndexHdr *pNew = (WalIndexHdr*)pSnapshot; - if( memcmp(pNew->aSalt, pWal->hdr.aSalt, sizeof(pWal->hdr.aSalt)) - || pNew->mxFramenBackfillAttempted - ){ - rc = SQLITE_ERROR_SNAPSHOT; - walUnlockShared(pWal, WAL_CKPT_LOCK); + SEH_TRY { + rc = walLockShared(pWal, WAL_CKPT_LOCK); + if( rc==SQLITE_OK ){ + WalIndexHdr *pNew = (WalIndexHdr*)pSnapshot; + if( memcmp(pNew->aSalt, pWal->hdr.aSalt, sizeof(pWal->hdr.aSalt)) + || pNew->mxFramenBackfillAttempted + ){ + rc = SQLITE_ERROR_SNAPSHOT; + walUnlockShared(pWal, WAL_CKPT_LOCK); + } } } + SEH_EXCEPT( rc = walHandleException(pWal); ) return rc; } @@ -67866,7 +68681,7 @@ SQLITE_PRIVATE sqlite3_file *sqlite3WalFile(Wal *pWal){ ** 0x81 0x00 becomes 0x00000080 ** 0x82 0x00 becomes 0x00000100 ** 0x80 0x7f becomes 0x0000007f -** 0x8a 0x91 0xd1 0xac 0x78 becomes 0x12345678 +** 0x81 0x91 0xd1 0xac 0x78 becomes 0x12345678 ** 0x81 0x81 0x81 0x81 0x01 becomes 0x10204081 ** ** Variable length integers are used for rowids and to hold the number of @@ -67949,7 +68764,7 @@ typedef struct CellInfo CellInfo; ** page that has been loaded into memory. The information in this object ** is derived from the raw on-disk page content. ** -** As each database page is loaded into memory, the pager allocats an +** As each database page is loaded into memory, the pager allocates an ** instance of this object and zeros the first 8 bytes. (This is the ** "extra" information associated with each page of the pager.) ** @@ -68405,7 +69220,7 @@ struct IntegrityCk { /* ** get2byteAligned(), unlike get2byte(), requires that its argument point to a -** two-byte aligned address. get2bytea() is only used for accessing the +** two-byte aligned address. get2byteAligned() is only used for accessing the ** cell addresses in a btree header. */ #if SQLITE_BYTEORDER==4321 @@ -68582,7 +69397,7 @@ SQLITE_PRIVATE int sqlite3BtreeHoldsMutex(Btree *p){ ** ** There is a corresponding leave-all procedures. ** -** Enter the mutexes in accending order by BtShared pointer address +** Enter the mutexes in ascending order by BtShared pointer address ** to avoid the possibility of deadlock when two threads with ** two or more btrees in common both try to lock all their btrees ** at the same instant. @@ -68714,6 +69529,7 @@ SQLITE_PRIVATE void sqlite3BtreeLeaveCursor(BtCursor *pCur){ /************** End of btmutex.c *********************************************/ /************** Begin file btree.c *******************************************/ + /* ** 2004 April 6 ** @@ -70249,7 +71065,7 @@ static void ptrmapPutOvflPtr(MemPage *pPage, MemPage *pSrc, u8 *pCell,int *pRC){ pPage->xParseCell(pPage, pCell, &info); if( info.nLocalaDataEnd, pCell, pCell+info.nLocal) ){ + if( SQLITE_OVERFLOW(pSrc->aDataEnd, pCell, pCell+info.nLocal) ){ testcase( pSrc!=pPage ); *pRC = SQLITE_CORRUPT_BKPT; return; @@ -70350,7 +71166,7 @@ static int defragmentPage(MemPage *pPage, int nMaxFrag){ iCellStart = get2byte(&data[hdr+5]); if( nCell>0 ){ temp = sqlite3PagerTempSpace(pPage->pBt->pPager); - memcpy(&temp[iCellStart], &data[iCellStart], usableSize - iCellStart); + memcpy(temp, data, usableSize); src = temp; for(i=0; iiPage. -** -** The page is fetched as read-write unless pCur is not NULL and is -** a read-only cursor. -** -** If an error occurs, then *ppPage is undefined. It -** may remain unchanged, or it may be set to an invalid value. */ static int getAndInitPage( BtShared *pBt, /* The database file */ Pgno pgno, /* Number of the page to get */ MemPage **ppPage, /* Write the page pointer here */ - BtCursor *pCur, /* Cursor to receive the page, or NULL */ int bReadOnly /* True for a read-only page */ ){ int rc; DbPage *pDbPage; + MemPage *pPage; assert( sqlite3_mutex_held(pBt->mutex) ); - assert( pCur==0 || ppPage==&pCur->pPage ); - assert( pCur==0 || bReadOnly==pCur->curPagerFlags ); - assert( pCur==0 || pCur->iPage>0 ); if( pgno>btreePagecount(pBt) ){ - rc = SQLITE_CORRUPT_BKPT; - goto getAndInitPage_error1; + *ppPage = 0; + return SQLITE_CORRUPT_BKPT; } rc = sqlite3PagerGet(pBt->pPager, pgno, (DbPage**)&pDbPage, bReadOnly); if( rc ){ - goto getAndInitPage_error1; + *ppPage = 0; + return rc; } - *ppPage = (MemPage*)sqlite3PagerGetExtra(pDbPage); - if( (*ppPage)->isInit==0 ){ + pPage = (MemPage*)sqlite3PagerGetExtra(pDbPage); + if( pPage->isInit==0 ){ btreePageFromDbPage(pDbPage, pgno, pBt); - rc = btreeInitPage(*ppPage); + rc = btreeInitPage(pPage); if( rc!=SQLITE_OK ){ - goto getAndInitPage_error2; + releasePage(pPage); + *ppPage = 0; + return rc; } } - assert( (*ppPage)->pgno==pgno || CORRUPT_DB ); - assert( (*ppPage)->aData==sqlite3PagerGetData(pDbPage) ); - - /* If obtaining a child page for a cursor, we must verify that the page is - ** compatible with the root page. */ - if( pCur && ((*ppPage)->nCell<1 || (*ppPage)->intKey!=pCur->curIntKey) ){ - rc = SQLITE_CORRUPT_PGNO(pgno); - goto getAndInitPage_error2; - } + assert( pPage->pgno==pgno || CORRUPT_DB ); + assert( pPage->aData==sqlite3PagerGetData(pDbPage) ); + *ppPage = pPage; return SQLITE_OK; - -getAndInitPage_error2: - releasePage(*ppPage); -getAndInitPage_error1: - if( pCur ){ - pCur->iPage--; - pCur->pPage = pCur->apPage[pCur->iPage]; - } - testcase( pgno==0 ); - assert( pgno!=0 || rc!=SQLITE_OK ); - return rc; } /* @@ -71177,7 +71966,7 @@ static void pageReinit(DbPage *pData){ ** call to btreeInitPage() will likely return SQLITE_CORRUPT. ** But no harm is done by this. And it is very important that ** btreeInitPage() be called on every btree page so we make - ** the call for every page that comes in for re-initing. */ + ** the call for every page that comes in for re-initializing. */ btreeInitPage(pPage); } } @@ -71356,6 +72145,9 @@ SQLITE_PRIVATE int sqlite3BtreeOpen( assert( sizeof(u16)==2 ); assert( sizeof(Pgno)==4 ); + /* Suppress false-positive compiler warning from PVS-Studio */ + memset(&zDbHeader[16], 0, 8); + pBt = sqlite3MallocZero( sizeof(*pBt) ); if( pBt==0 ){ rc = SQLITE_NOMEM_BKPT; @@ -71572,7 +72364,7 @@ static SQLITE_NOINLINE int allocateTempSpace(BtShared *pBt){ ** can mean that fillInCell() only initializes the first 2 or 3 ** bytes of pTmpSpace, but that the first 4 bytes are copied from ** it into a database page. This is not actually a problem, but it - ** does cause a valgrind error when the 1 or 2 bytes of unitialized + ** does cause a valgrind error when the 1 or 2 bytes of uninitialized ** data is passed to system call write(). So to avoid this error, ** zero the first 4 bytes of temp space here. ** @@ -71807,7 +72599,7 @@ SQLITE_PRIVATE int sqlite3BtreeGetReserveNoMutex(Btree *p){ /* ** Return the number of bytes of space at the end of every page that -** are intentually left unused. This is the "reserved" space that is +** are intentionally left unused. This is the "reserved" space that is ** sometimes used by extensions. ** ** The value returned is the larger of the current reserve size and @@ -72054,7 +72846,6 @@ static int lockBtree(BtShared *pBt){ ){ goto page1_init_failed; } - pBt->btsFlags |= BTS_PAGESIZE_FIXED; assert( (pageSize & 7)==0 ); /* EVIDENCE-OF: R-59310-51205 The "reserved space" size in the 1-byte ** integer at offset 20 is the number of bytes of space at the end of @@ -72074,6 +72865,7 @@ static int lockBtree(BtShared *pBt){ releasePageOne(pPage1); pBt->usableSize = usableSize; pBt->pageSize = pageSize; + pBt->btsFlags |= BTS_PAGESIZE_FIXED; freeTempSpace(pBt); rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize, pageSize-usableSize); @@ -72093,6 +72885,7 @@ static int lockBtree(BtShared *pBt){ if( usableSize<480 ){ goto page1_init_failed; } + pBt->btsFlags |= BTS_PAGESIZE_FIXED; pBt->pageSize = pageSize; pBt->usableSize = usableSize; #ifndef SQLITE_OMIT_AUTOVACUUM @@ -72271,7 +73064,11 @@ SQLITE_PRIVATE int sqlite3BtreeNewDb(Btree *p){ ** when A already has a read lock, we encourage A to give up and let B ** proceed. */ -SQLITE_PRIVATE int sqlite3BtreeBeginTrans(Btree *p, int wrflag, int *pSchemaVersion){ +static SQLITE_NOINLINE int btreeBeginTrans( + Btree *p, /* The btree in which to start the transaction */ + int wrflag, /* True to start a write transaction */ + int *pSchemaVersion /* Put schema version number here, if not NULL */ +){ BtShared *pBt = p->pBt; Pager *pPager = pBt->pPager; int rc = SQLITE_OK; @@ -72443,6 +73240,28 @@ trans_begun: sqlite3BtreeLeave(p); return rc; } +SQLITE_PRIVATE int sqlite3BtreeBeginTrans(Btree *p, int wrflag, int *pSchemaVersion){ + BtShared *pBt; + if( p->sharable + || p->inTrans==TRANS_NONE + || (p->inTrans==TRANS_READ && wrflag!=0) + ){ + return btreeBeginTrans(p,wrflag,pSchemaVersion); + } + pBt = p->pBt; + if( pSchemaVersion ){ + *pSchemaVersion = get4byte(&pBt->pPage1->aData[40]); + } + if( wrflag ){ + /* This call makes sure that the pager has the correct number of + ** open savepoints. If the second parameter is greater than 0 and + ** the sub-journal is not already open, then it will be opened here. + */ + return sqlite3PagerOpenSavepoint(pBt->pPager, p->db->nSavepoint); + }else{ + return SQLITE_OK; + } +} #ifndef SQLITE_OMIT_AUTOVACUUM @@ -73538,7 +74357,6 @@ SQLITE_PRIVATE void sqlite3BtreeCursorUnpin(BtCursor *pCur){ pCur->curFlags &= ~BTCF_Pinned; } -#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC /* ** Return the offset into the database file for the start of the ** payload to which the cursor is pointing. @@ -73550,7 +74368,6 @@ SQLITE_PRIVATE i64 sqlite3BtreeOffset(BtCursor *pCur){ return (i64)pCur->pBt->pageSize*((i64)pCur->pPage->pgno - 1) + (i64)(pCur->info.pPayload - pCur->pPage->aData); } -#endif /* SQLITE_ENABLE_OFFSET_SQL_FUNC */ /* ** Return the number of bytes of payload for the entry that pCur is @@ -73576,7 +74393,7 @@ SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor *pCur){ ** routine always returns 2147483647 (which is the largest record ** that SQLite can handle) or more. But returning a smaller value might ** prevent large memory allocations when trying to interpret a -** corrupt datrabase. +** corrupt database. ** ** The current implementation merely returns the size of the underlying ** database file. @@ -74038,6 +74855,7 @@ SQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor *pCur, u32 *pAmt){ ** vice-versa). */ static int moveToChild(BtCursor *pCur, u32 newPgno){ + int rc; assert( cursorOwnsBtShared(pCur) ); assert( pCur->eState==CURSOR_VALID ); assert( pCur->iPageapPage[pCur->iPage] = pCur->pPage; pCur->ix = 0; pCur->iPage++; - return getAndInitPage(pCur->pBt, newPgno, &pCur->pPage, pCur, - pCur->curPagerFlags); + rc = getAndInitPage(pCur->pBt, newPgno, &pCur->pPage, pCur->curPagerFlags); + assert( pCur->pPage!=0 || rc!=SQLITE_OK ); + if( rc==SQLITE_OK + && (pCur->pPage->nCell<1 || pCur->pPage->intKey!=pCur->curIntKey) + ){ + releasePage(pCur->pPage); + rc = SQLITE_CORRUPT_PGNO(newPgno); + } + if( rc ){ + pCur->pPage = pCur->apPage[--pCur->iPage]; + } + return rc; } #ifdef SQLITE_DEBUG @@ -74159,7 +74987,7 @@ static int moveToRoot(BtCursor *pCur){ sqlite3BtreeClearCursor(pCur); } rc = getAndInitPage(pCur->pBt, pCur->pgnoRoot, &pCur->pPage, - 0, pCur->curPagerFlags); + pCur->curPagerFlags); if( rc!=SQLITE_OK ){ pCur->eState = CURSOR_INVALID; return rc; @@ -74271,7 +75099,7 @@ SQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor *pCur, int *pRes){ *pRes = 0; rc = moveToLeftmost(pCur); }else if( rc==SQLITE_EMPTY ){ - assert( pCur->pgnoRoot==0 || pCur->pPage->nCell==0 ); + assert( pCur->pgnoRoot==0 || (pCur->pPage!=0 && pCur->pPage->nCell==0) ); *pRes = 1; rc = SQLITE_OK; } @@ -74376,7 +75204,7 @@ SQLITE_PRIVATE int sqlite3BtreeTableMoveto( /* If the requested key is one more than the previous key, then ** try to get there using sqlite3BtreeNext() rather than a full ** binary search. This is an optimization only. The correct answer - ** is still obtained without this case, only a little more slowely */ + ** is still obtained without this case, only a little more slowly. */ if( pCur->info.nKey+1==intKey ){ *pRes = 0; rc = sqlite3BtreeNext(pCur, 0); @@ -74772,10 +75600,36 @@ bypass_moveto_root: }else{ chldPg = get4byte(findCell(pPage, lwr)); } - pCur->ix = (u16)lwr; - rc = moveToChild(pCur, chldPg); - if( rc ) break; - } + + /* This block is similar to an in-lined version of: + ** + ** pCur->ix = (u16)lwr; + ** rc = moveToChild(pCur, chldPg); + ** if( rc ) break; + */ + pCur->info.nSize = 0; + pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl); + if( pCur->iPage>=(BTCURSOR_MAX_DEPTH-1) ){ + return SQLITE_CORRUPT_BKPT; + } + pCur->aiIdx[pCur->iPage] = (u16)lwr; + pCur->apPage[pCur->iPage] = pCur->pPage; + pCur->ix = 0; + pCur->iPage++; + rc = getAndInitPage(pCur->pBt, chldPg, &pCur->pPage, pCur->curPagerFlags); + if( rc==SQLITE_OK + && (pCur->pPage->nCell<1 || pCur->pPage->intKey!=pCur->curIntKey) + ){ + releasePage(pCur->pPage); + rc = SQLITE_CORRUPT_PGNO(chldPg); + } + if( rc ){ + pCur->pPage = pCur->apPage[--pCur->iPage]; + break; + } + /* + ***** End of in-lined moveToChild() call */ + } moveto_index_finish: pCur->info.nSize = 0; assert( (pCur->curFlags & BTCF_ValidOvfl)==0 ); @@ -75559,7 +76413,7 @@ static SQLITE_NOINLINE int clearCellOverflow( /* Call xParseCell to compute the size of a cell. If the cell contains ** overflow, then invoke cellClearOverflow to clear out that overflow. -** STore the result code (SQLITE_OK or some error code) in rc. +** Store the result code (SQLITE_OK or some error code) in rc. ** ** Implemented as macro to force inlining for performance. */ @@ -76175,7 +77029,7 @@ static int rebuildPage( if( NEVER(j>(u32)usableSize) ){ j = 0; } memcpy(&pTmp[j], &aData[j], usableSize - j); - for(k=0; pCArray->ixNx[k]<=i && ALWAYS(kixNx[k]<=i; k++){} pSrcEnd = pCArray->apEnd[k]; pData = pEnd; @@ -76238,7 +77092,7 @@ static int rebuildPage( ** Finally, argument pBegin points to the byte immediately following the ** end of the space required by this page for the cell-pointer area (for ** all cells - not just those inserted by the current call). If the content -** area must be extended to before this point in order to accomodate all +** area must be extended to before this point in order to accommodate all ** cells in apCell[], then the cells do not fit and non-zero is returned. */ static int pageInsertArray( @@ -76258,7 +77112,7 @@ static int pageInsertArray( u8 *pEnd; /* Maximum extent of cell data */ assert( CORRUPT_DB || pPg->hdrOffset==0 ); /* Never called on page 1 */ if( iEnd<=iFirst ) return 0; - for(k=0; pCArray->ixNx[k]<=i && ALWAYS(kixNx[k]<=i ; k++){} pEnd = pCArray->apEnd[k]; while( 1 /*Exit by break*/ ){ int sz, rc; @@ -76553,7 +77407,7 @@ static int balance_quick(MemPage *pParent, MemPage *pPage, u8 *pSpace){ ** with entries for the new page, and any pointer from the ** cell on the page to an overflow page. If either of these ** operations fails, the return code is set, but the contents - ** of the parent page are still manipulated by thh code below. + ** of the parent page are still manipulated by the code below. ** That is Ok, at this point the parent page is guaranteed to ** be marked as dirty. Returning an error code will cause a ** rollback, undoing any changes made to the parent page. @@ -76829,7 +77683,7 @@ static int balance_nonroot( pgno = get4byte(pRight); while( 1 ){ if( rc==SQLITE_OK ){ - rc = getAndInitPage(pBt, pgno, &apOld[i], 0, 0); + rc = getAndInitPage(pBt, pgno, &apOld[i], 0); } if( rc ){ memset(apOld, 0, (i+1)*sizeof(MemPage*)); @@ -77143,7 +77997,7 @@ static int balance_nonroot( } } - /* Sanity check: For a non-corrupt database file one of the follwing + /* Sanity check: For a non-corrupt database file one of the following ** must be true: ** (1) We found one or more cells (cntNew[0])>0), or ** (2) pPage is a virtual root page. A virtual root page is when @@ -77368,9 +78222,9 @@ static int balance_nonroot( iOvflSpace += sz; assert( sz<=pBt->maxLocal+23 ); assert( iOvflSpace <= (int)pBt->pageSize ); - for(k=0; b.ixNx[k]<=j && ALWAYS(k=0 && iPg=1 || i>=0 ); + assert( iPg=0 /* On the upwards pass, or... */ || cntOld[iPg-1]>=cntNew[iPg-1] /* Condition (1) is true */ @@ -77760,7 +78616,7 @@ static int btreeOverwriteContent( ){ int nData = pX->nData - iOffset; if( nData<=0 ){ - /* Overwritting with zeros */ + /* Overwriting with zeros */ int i; for(i=0; ipData to write */ @@ -78543,7 +79399,7 @@ static int btreeCreateTable(Btree *p, Pgno *piTable, int createTabFlags){ MemPage *pRoot; Pgno pgnoRoot; int rc; - int ptfFlags; /* Page-type flage for the root page of new table */ + int ptfFlags; /* Page-type flags for the root page of new table */ assert( sqlite3BtreeHoldsMutex(p) ); assert( pBt->inTransaction==TRANS_WRITE ); @@ -78712,7 +79568,7 @@ static int clearDatabasePage( if( pgno>btreePagecount(pBt) ){ return SQLITE_CORRUPT_BKPT; } - rc = getAndInitPage(pBt, pgno, &pPage, 0, 0); + rc = getAndInitPage(pBt, pgno, &pPage, 0); if( rc ) return rc; if( (pBt->openFlags & BTREE_SINGLE)==0 && sqlite3PagerPageRefcount(pPage->pDbPage) != (1 + (pgno==1)) @@ -79378,7 +80234,7 @@ static int checkTreePage( if( iPage==0 ) return 0; if( checkRef(pCheck, iPage) ) return 0; pCheck->zPfx = "Tree %u page %u: "; - pCheck->v0 = pCheck->v1 = iPage; + pCheck->v1 = iPage; if( (rc = btreeGetPage(pBt, iPage, &pPage, 0))!=0 ){ checkAppendMsg(pCheck, "unable to get the page. error code=%d", rc); @@ -79715,6 +80571,7 @@ SQLITE_PRIVATE int sqlite3BtreeIntegrityCheck( checkPtrmap(&sCheck, aRoot[i], PTRMAP_ROOTPAGE, 0); } #endif + sCheck.v0 = aRoot[i]; checkTreePage(&sCheck, aRoot[i], ¬Used, LARGEST_INT64); } pBt->db->flags = savedDbFlags; @@ -81141,6 +81998,40 @@ SQLITE_PRIVATE int sqlite3VdbeMemClearAndResize(Mem *pMem, int szNew){ return SQLITE_OK; } +/* +** If pMem is already a string, detect if it is a zero-terminated +** string, or make it into one if possible, and mark it as such. +** +** This is an optimization. Correct operation continues even if +** this routine is a no-op. +*/ +SQLITE_PRIVATE void sqlite3VdbeMemZeroTerminateIfAble(Mem *pMem){ + if( (pMem->flags & (MEM_Str|MEM_Term|MEM_Ephem|MEM_Static))!=MEM_Str ){ + /* pMem must be a string, and it cannot be an ephemeral or static string */ + return; + } + if( pMem->enc!=SQLITE_UTF8 ) return; + if( NEVER(pMem->z==0) ) return; + if( pMem->flags & MEM_Dyn ){ + if( pMem->xDel==sqlite3_free + && sqlite3_msize(pMem->z) >= (u64)(pMem->n+1) + ){ + pMem->z[pMem->n] = 0; + pMem->flags |= MEM_Term; + return; + } + if( pMem->xDel==(void(*)(void*))sqlite3RCStrUnref ){ + /* Blindly assume that all RCStr objects are zero-terminated */ + pMem->flags |= MEM_Term; + return; + } + }else if( pMem->szMalloc >= pMem->n+1 ){ + pMem->z[pMem->n] = 0; + pMem->flags |= MEM_Term; + return; + } +} + /* ** It is already known that pMem contains an unterminated string. ** Add the zero terminator. @@ -81402,36 +82293,6 @@ SQLITE_PRIVATE void sqlite3VdbeMemReleaseMalloc(Mem *p){ if( p->szMalloc ) vdbeMemClear(p); } -/* -** Convert a 64-bit IEEE double into a 64-bit signed integer. -** If the double is out of range of a 64-bit signed integer then -** return the closest available 64-bit signed integer. -*/ -static SQLITE_NOINLINE i64 doubleToInt64(double r){ -#ifdef SQLITE_OMIT_FLOATING_POINT - /* When floating-point is omitted, double and int64 are the same thing */ - return r; -#else - /* - ** Many compilers we encounter do not define constants for the - ** minimum and maximum 64-bit integers, or they define them - ** inconsistently. And many do not understand the "LL" notation. - ** So we define our own static constants here using nothing - ** larger than a 32-bit integer constant. - */ - static const i64 maxInt = LARGEST_INT64; - static const i64 minInt = SMALLEST_INT64; - - if( r<=(double)minInt ){ - return minInt; - }else if( r>=(double)maxInt ){ - return maxInt; - }else{ - return (i64)r; - } -#endif -} - /* ** Return some kind of integer value which is the best we can do ** at representing the value that *pMem describes as an integer. @@ -81458,7 +82319,7 @@ SQLITE_PRIVATE i64 sqlite3VdbeIntValue(const Mem *pMem){ testcase( flags & MEM_IntReal ); return pMem->u.i; }else if( flags & MEM_Real ){ - return doubleToInt64(pMem->u.r); + return sqlite3RealToI64(pMem->u.r); }else if( (flags & (MEM_Str|MEM_Blob))!=0 && pMem->z!=0 ){ return memIntValue(pMem); }else{ @@ -81520,7 +82381,7 @@ SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem *pMem){ if( pMem->flags & MEM_IntReal ){ MemSetTypeFlag(pMem, MEM_Int); }else{ - i64 ix = doubleToInt64(pMem->u.r); + i64 ix = sqlite3RealToI64(pMem->u.r); /* Only mark the value as an integer if ** @@ -81588,8 +82449,8 @@ SQLITE_PRIVATE int sqlite3RealSameAsInt(double r1, sqlite3_int64 i){ ** from UBSAN. */ SQLITE_PRIVATE i64 sqlite3RealToI64(double r){ - if( r<=(double)SMALLEST_INT64 ) return SMALLEST_INT64; - if( r>=(double)LARGEST_INT64) return LARGEST_INT64; + if( r<-9223372036854774784.0 ) return SMALLEST_INT64; + if( r>+9223372036854774784.0 ) return LARGEST_INT64; return (i64)r; } @@ -81660,6 +82521,7 @@ SQLITE_PRIVATE int sqlite3VdbeMemCast(Mem *pMem, u8 aff, u8 encoding){ break; } default: { + int rc; assert( aff==SQLITE_AFF_TEXT ); assert( MEM_Str==(MEM_Blob>>3) ); pMem->flags |= (pMem->flags&MEM_Blob)>>3; @@ -81667,7 +82529,9 @@ SQLITE_PRIVATE int sqlite3VdbeMemCast(Mem *pMem, u8 aff, u8 encoding){ assert( pMem->flags & MEM_Str || pMem->db->mallocFailed ); pMem->flags &= ~(MEM_Int|MEM_Real|MEM_IntReal|MEM_Blob|MEM_Zero); if( encoding!=SQLITE_UTF8 ) pMem->n &= ~1; - return sqlite3VdbeChangeEncoding(pMem, encoding); + rc = sqlite3VdbeChangeEncoding(pMem, encoding); + if( rc ) return rc; + sqlite3VdbeMemZeroTerminateIfAble(pMem); } } return SQLITE_OK; @@ -82191,6 +83055,24 @@ SQLITE_PRIVATE const void *sqlite3ValueText(sqlite3_value* pVal, u8 enc){ return valueToText(pVal, enc); } +/* Return true if sqlit3_value object pVal is a string or blob value +** that uses the destructor specified in the second argument. +** +** TODO: Maybe someday promote this interface into a published API so +** that third-party extensions can get access to it? +*/ +SQLITE_PRIVATE int sqlite3ValueIsOfClass(const sqlite3_value *pVal, void(*xFree)(void*)){ + if( ALWAYS(pVal!=0) + && ALWAYS((pVal->flags & (MEM_Str|MEM_Blob))!=0) + && (pVal->flags & MEM_Dyn)!=0 + && pVal->xDel==xFree + ){ + return 1; + }else{ + return 0; + } +} + /* ** Create a new sqlite3_value object. */ @@ -82258,6 +83140,7 @@ static sqlite3_value *valueNew(sqlite3 *db, struct ValueNewStat4Ctx *p){ } pRec->nField = p->iVal+1; + sqlite3VdbeMemSetNull(&pRec->aMem[p->iVal]); return &pRec->aMem[p->iVal]; } #else @@ -83046,6 +83929,35 @@ static void test_addop_breakpoint(int pc, Op *pOp){ } #endif +/* +** Slow paths for sqlite3VdbeAddOp3() and sqlite3VdbeAddOp4Int() for the +** unusual case when we need to increase the size of the Vdbe.aOp[] array +** before adding the new opcode. +*/ +static SQLITE_NOINLINE int growOp3(Vdbe *p, int op, int p1, int p2, int p3){ + assert( p->nOpAlloc<=p->nOp ); + if( growOpArray(p, 1) ) return 1; + assert( p->nOpAlloc>p->nOp ); + return sqlite3VdbeAddOp3(p, op, p1, p2, p3); +} +static SQLITE_NOINLINE int addOp4IntSlow( + Vdbe *p, /* Add the opcode to this VM */ + int op, /* The new opcode */ + int p1, /* The P1 operand */ + int p2, /* The P2 operand */ + int p3, /* The P3 operand */ + int p4 /* The P4 operand as an integer */ +){ + int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3); + if( p->db->mallocFailed==0 ){ + VdbeOp *pOp = &p->aOp[addr]; + pOp->p4type = P4_INT32; + pOp->p4.i = p4; + } + return addr; +} + + /* ** Add a new instruction to the list of instructions current in the ** VDBE. Return the address of the new instruction. @@ -83056,17 +83968,16 @@ static void test_addop_breakpoint(int pc, Op *pOp){ ** ** op The opcode for this instruction ** -** p1, p2, p3 Operands -** -** Use the sqlite3VdbeResolveLabel() function to fix an address and -** the sqlite3VdbeChangeP4() function to change the value of the P4 -** operand. +** p1, p2, p3, p4 Operands */ -static SQLITE_NOINLINE int growOp3(Vdbe *p, int op, int p1, int p2, int p3){ - assert( p->nOpAlloc<=p->nOp ); - if( growOpArray(p, 1) ) return 1; - assert( p->nOpAlloc>p->nOp ); - return sqlite3VdbeAddOp3(p, op, p1, p2, p3); +SQLITE_PRIVATE int sqlite3VdbeAddOp0(Vdbe *p, int op){ + return sqlite3VdbeAddOp3(p, op, 0, 0, 0); +} +SQLITE_PRIVATE int sqlite3VdbeAddOp1(Vdbe *p, int op, int p1){ + return sqlite3VdbeAddOp3(p, op, p1, 0, 0); +} +SQLITE_PRIVATE int sqlite3VdbeAddOp2(Vdbe *p, int op, int p1, int p2){ + return sqlite3VdbeAddOp3(p, op, p1, p2, 0); } SQLITE_PRIVATE int sqlite3VdbeAddOp3(Vdbe *p, int op, int p1, int p2, int p3){ int i; @@ -83089,6 +84000,9 @@ SQLITE_PRIVATE int sqlite3VdbeAddOp3(Vdbe *p, int op, int p1, int p2, int p3){ pOp->p3 = p3; pOp->p4.p = 0; pOp->p4type = P4_NOTUSED; + + /* Replicate this logic in sqlite3VdbeAddOp4Int() + ** vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */ #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS pOp->zComment = 0; #endif @@ -83105,16 +84019,59 @@ SQLITE_PRIVATE int sqlite3VdbeAddOp3(Vdbe *p, int op, int p1, int p2, int p3){ #ifdef SQLITE_VDBE_COVERAGE pOp->iSrcLine = 0; #endif + /* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ** Replicate in sqlite3VdbeAddOp4Int() */ + return i; } -SQLITE_PRIVATE int sqlite3VdbeAddOp0(Vdbe *p, int op){ - return sqlite3VdbeAddOp3(p, op, 0, 0, 0); -} -SQLITE_PRIVATE int sqlite3VdbeAddOp1(Vdbe *p, int op, int p1){ - return sqlite3VdbeAddOp3(p, op, p1, 0, 0); -} -SQLITE_PRIVATE int sqlite3VdbeAddOp2(Vdbe *p, int op, int p1, int p2){ - return sqlite3VdbeAddOp3(p, op, p1, p2, 0); +SQLITE_PRIVATE int sqlite3VdbeAddOp4Int( + Vdbe *p, /* Add the opcode to this VM */ + int op, /* The new opcode */ + int p1, /* The P1 operand */ + int p2, /* The P2 operand */ + int p3, /* The P3 operand */ + int p4 /* The P4 operand as an integer */ +){ + int i; + VdbeOp *pOp; + + i = p->nOp; + if( p->nOpAlloc<=i ){ + return addOp4IntSlow(p, op, p1, p2, p3, p4); + } + p->nOp++; + pOp = &p->aOp[i]; + assert( pOp!=0 ); + pOp->opcode = (u8)op; + pOp->p5 = 0; + pOp->p1 = p1; + pOp->p2 = p2; + pOp->p3 = p3; + pOp->p4.i = p4; + pOp->p4type = P4_INT32; + + /* Replicate this logic in sqlite3VdbeAddOp3() + ** vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */ +#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS + pOp->zComment = 0; +#endif +#if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || defined(VDBE_PROFILE) + pOp->nExec = 0; + pOp->nCycle = 0; +#endif +#ifdef SQLITE_DEBUG + if( p->db->flags & SQLITE_VdbeAddopTrace ){ + sqlite3VdbePrintOp(0, i, &p->aOp[i]); + test_addop_breakpoint(i, &p->aOp[i]); + } +#endif +#ifdef SQLITE_VDBE_COVERAGE + pOp->iSrcLine = 0; +#endif + /* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ** Replicate in sqlite3VdbeAddOp3() */ + + return i; } /* Generate code for an unconditional jump to instruction iDest @@ -83292,7 +84249,7 @@ SQLITE_PRIVATE int sqlite3VdbeExplain(Parse *pParse, u8 bPush, const char *zFmt, if( bPush){ pParse->addrExplain = iThis; } - sqlite3VdbeScanStatus(v, iThis, 0, 0, 0, 0); + sqlite3VdbeScanStatus(v, iThis, -1, -1, 0, 0); } return addr; } @@ -83322,26 +84279,6 @@ SQLITE_PRIVATE void sqlite3VdbeAddParseSchemaOp(Vdbe *p, int iDb, char *zWhere, sqlite3MayAbort(p->pParse); } -/* -** Add an opcode that includes the p4 value as an integer. -*/ -SQLITE_PRIVATE int sqlite3VdbeAddOp4Int( - Vdbe *p, /* Add the opcode to this VM */ - int op, /* The new opcode */ - int p1, /* The P1 operand */ - int p2, /* The P2 operand */ - int p3, /* The P3 operand */ - int p4 /* The P4 operand as an integer */ -){ - int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3); - if( p->db->mallocFailed==0 ){ - VdbeOp *pOp = &p->aOp[addr]; - pOp->p4type = P4_INT32; - pOp->p4.i = p4; - } - return addr; -} - /* Insert the end of a co-routine */ SQLITE_PRIVATE void sqlite3VdbeEndCoroutine(Vdbe *v, int regYield){ @@ -83654,7 +84591,7 @@ static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){ p->bIsReader = 0; pOp = &p->aOp[p->nOp-1]; assert( p->aOp[0].opcode==OP_Init ); - while( 1 /* Loop termates when it reaches the OP_Init opcode */ ){ + while( 1 /* Loop terminates when it reaches the OP_Init opcode */ ){ /* Only JUMP opcodes and the short list of special opcodes in the switch ** below need to be considered. The mkopcodeh.tcl generator script groups ** all these opcodes together near the front of the opcode list. Skip @@ -84024,8 +84961,8 @@ SQLITE_PRIVATE void sqlite3VdbeScanStatusCounters( pScan = 0; } if( pScan ){ - pScan->addrLoop = addrLoop; - pScan->addrVisit = addrVisit; + if( addrLoop>0 ) pScan->addrLoop = addrLoop; + if( addrVisit>0 ) pScan->addrVisit = addrVisit; } } } @@ -84108,7 +85045,7 @@ SQLITE_PRIVATE void sqlite3VdbeJumpHereOrPopInst(Vdbe *p, int addr){ /* ** If the input FuncDef structure is ephemeral, then free it. If -** the FuncDef is not ephermal, then do nothing. +** the FuncDef is not ephemeral, then do nothing. */ static void freeEphemeralFunction(sqlite3 *db, FuncDef *pDef){ assert( db!=0 ); @@ -84272,7 +85209,6 @@ SQLITE_PRIVATE void sqlite3VdbeReleaseRegisters( } #endif /* SQLITE_DEBUG */ - /* ** Change the value of the P4 operand for a specific instruction. ** This routine is useful when a large program is loaded from a @@ -85193,7 +86129,7 @@ SQLITE_PRIVATE int sqlite3VdbeList( sqlite3VdbeMemSetInt64(pMem+1, pOp->p2); sqlite3VdbeMemSetInt64(pMem+2, pOp->p3); sqlite3VdbeMemSetStr(pMem+3, zP4, -1, SQLITE_UTF8, sqlite3_free); - p->nResColumn = 4; + assert( p->nResColumn==4 ); }else{ sqlite3VdbeMemSetInt64(pMem+0, i); sqlite3VdbeMemSetStr(pMem+1, (char*)sqlite3OpcodeName(pOp->opcode), @@ -85212,7 +86148,7 @@ SQLITE_PRIVATE int sqlite3VdbeList( sqlite3VdbeMemSetNull(pMem+7); #endif sqlite3VdbeMemSetStr(pMem+5, zP4, -1, SQLITE_UTF8, sqlite3_free); - p->nResColumn = 8; + assert( p->nResColumn==8 ); } p->pResultRow = pMem; if( db->mallocFailed ){ @@ -85426,26 +86362,9 @@ SQLITE_PRIVATE void sqlite3VdbeMakeReady( resolveP2Values(p, &nArg); p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort); if( pParse->explain ){ - static const char * const azColName[] = { - "addr", "opcode", "p1", "p2", "p3", "p4", "p5", "comment", - "id", "parent", "notused", "detail" - }; - int iFirst, mx, i; if( nMem<10 ) nMem = 10; p->explain = pParse->explain; - if( pParse->explain==2 ){ - sqlite3VdbeSetNumCols(p, 4); - iFirst = 8; - mx = 12; - }else{ - sqlite3VdbeSetNumCols(p, 8); - iFirst = 0; - mx = 8; - } - for(i=iFirst; inResColumn = 12 - 4*p->explain; } p->expired = 0; @@ -85497,7 +86416,23 @@ SQLITE_PRIVATE void sqlite3VdbeMakeReady( SQLITE_PRIVATE void sqlite3VdbeFreeCursor(Vdbe *p, VdbeCursor *pCx){ if( pCx ) sqlite3VdbeFreeCursorNN(p,pCx); } +static SQLITE_NOINLINE void freeCursorWithCache(Vdbe *p, VdbeCursor *pCx){ + VdbeTxtBlbCache *pCache = pCx->pCache; + assert( pCx->colCache ); + pCx->colCache = 0; + pCx->pCache = 0; + if( pCache->pCValue ){ + sqlite3RCStrUnref(pCache->pCValue); + pCache->pCValue = 0; + } + sqlite3DbFree(p->db, pCache); + sqlite3VdbeFreeCursorNN(p, pCx); +} SQLITE_PRIVATE void sqlite3VdbeFreeCursorNN(Vdbe *p, VdbeCursor *pCx){ + if( pCx->colCache ){ + freeCursorWithCache(p, pCx); + return; + } switch( pCx->eCurType ){ case CURTYPE_SORTER: { sqlite3VdbeSorterClose(p->db, pCx); @@ -85598,12 +86533,12 @@ SQLITE_PRIVATE void sqlite3VdbeSetNumCols(Vdbe *p, int nResColumn){ int n; sqlite3 *db = p->db; - if( p->nResColumn ){ - releaseMemArray(p->aColName, p->nResColumn*COLNAME_N); + if( p->nResAlloc ){ + releaseMemArray(p->aColName, p->nResAlloc*COLNAME_N); sqlite3DbFree(db, p->aColName); } n = nResColumn*COLNAME_N; - p->nResColumn = (u16)nResColumn; + p->nResColumn = p->nResAlloc = (u16)nResColumn; p->aColName = (Mem*)sqlite3DbMallocRawNN(db, sizeof(Mem)*n ); if( p->aColName==0 ) return; initMemArray(p->aColName, n, db, MEM_Null); @@ -85628,14 +86563,14 @@ SQLITE_PRIVATE int sqlite3VdbeSetColName( ){ int rc; Mem *pColName; - assert( idxnResColumn ); + assert( idxnResAlloc ); assert( vardb->mallocFailed ){ assert( !zName || xDel!=SQLITE_DYNAMIC ); return SQLITE_NOMEM_BKPT; } assert( p->aColName!=0 ); - pColName = &(p->aColName[idx+var*p->nResColumn]); + pColName = &(p->aColName[idx+var*p->nResAlloc]); rc = sqlite3VdbeMemSetStr(pColName, zName, -1, SQLITE_UTF8, xDel); assert( rc!=0 || !zName || (pColName->flags&MEM_Term)!=0 ); return rc; @@ -86148,6 +87083,7 @@ SQLITE_PRIVATE int sqlite3VdbeHalt(Vdbe *p){ sqlite3VdbeLeave(p); return SQLITE_BUSY; }else if( rc!=SQLITE_OK ){ + sqlite3SystemError(db, rc); p->rc = rc; sqlite3RollbackAll(db, SQLITE_OK); p->nChange = 0; @@ -86459,7 +87395,7 @@ static void sqlite3VdbeClearObject(sqlite3 *db, Vdbe *p){ assert( db!=0 ); assert( p->db==0 || p->db==db ); if( p->aColName ){ - releaseMemArray(p->aColName, p->nResColumn*COLNAME_N); + releaseMemArray(p->aColName, p->nResAlloc*COLNAME_N); sqlite3DbNNFreeNN(db, p->aColName); } for(pSub=p->pProgram; pSub; pSub=pNext){ @@ -87059,6 +87995,15 @@ static int vdbeRecordCompareDebug( if( d1+(u64)serial_type1+2>(u64)nKey1 && d1+(u64)sqlite3VdbeSerialTypeLen(serial_type1)>(u64)nKey1 ){ + if( serial_type1>=1 + && serial_type1<=7 + && d1+(u64)sqlite3VdbeSerialTypeLen(serial_type1)<=(u64)nKey1+8 + && CORRUPT_DB + ){ + return 1; /* corrupt record not detected by + ** sqlite3VdbeRecordCompareWithSkip(). Return true + ** to avoid firing the assert() */ + } break; } @@ -87502,7 +88447,7 @@ SQLITE_PRIVATE int sqlite3VdbeRecordCompareWithSkip( /* Serial types 12 or greater are strings and blobs (greater than ** numbers). Types 10 and 11 are currently "reserved for future ** use", so it doesn't really matter what the results of comparing - ** them to numberic values are. */ + ** them to numeric values are. */ rc = serial_type==10 ? -1 : +1; }else if( serial_type==0 ){ rc = -1; @@ -88759,6 +89704,7 @@ SQLITE_API void sqlite3_result_text64( (void)invokeValueDestructor(z, xDel, pCtx); }else{ setResultStrOrError(pCtx, z, (int)n, enc, xDel); + sqlite3VdbeMemZeroTerminateIfAble(pCtx->pOut); } } #ifndef SQLITE_OMIT_UTF16 @@ -89131,7 +90077,7 @@ SQLITE_API int sqlite3_vtab_nochange(sqlite3_context *p){ ** The destructor function for a ValueList object. This needs to be ** a separate function, unknowable to the application, to ensure that ** calls to sqlite3_vtab_in_first()/sqlite3_vtab_in_next() that are not -** preceeded by activation of IN processing via sqlite3_vtab_int() do not +** preceded by activation of IN processing via sqlite3_vtab_int() do not ** try to access a fake ValueList object inserted by a hostile extension. */ SQLITE_PRIVATE void sqlite3VdbeValueListFree(void *pToDelete){ @@ -89371,7 +90317,8 @@ SQLITE_API int sqlite3_aggregate_count(sqlite3_context *p){ */ SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt){ Vdbe *pVm = (Vdbe *)pStmt; - return pVm ? pVm->nResColumn : 0; + if( pVm==0 ) return 0; + return pVm->nResColumn; } /* @@ -89460,7 +90407,7 @@ static Mem *columnMem(sqlite3_stmt *pStmt, int i){ ** sqlite3_column_real() ** sqlite3_column_bytes() ** sqlite3_column_bytes16() -** sqiite3_column_blob() +** sqlite3_column_blob() */ static void columnMallocFailure(sqlite3_stmt *pStmt) { @@ -89544,6 +90491,32 @@ SQLITE_API int sqlite3_column_type(sqlite3_stmt *pStmt, int i){ return iType; } +/* +** Column names appropriate for EXPLAIN or EXPLAIN QUERY PLAN. +*/ +static const char * const azExplainColNames8[] = { + "addr", "opcode", "p1", "p2", "p3", "p4", "p5", "comment", /* EXPLAIN */ + "id", "parent", "notused", "detail" /* EQP */ +}; +static const u16 azExplainColNames16data[] = { + /* 0 */ 'a', 'd', 'd', 'r', 0, + /* 5 */ 'o', 'p', 'c', 'o', 'd', 'e', 0, + /* 12 */ 'p', '1', 0, + /* 15 */ 'p', '2', 0, + /* 18 */ 'p', '3', 0, + /* 21 */ 'p', '4', 0, + /* 24 */ 'p', '5', 0, + /* 27 */ 'c', 'o', 'm', 'm', 'e', 'n', 't', 0, + /* 35 */ 'i', 'd', 0, + /* 38 */ 'p', 'a', 'r', 'e', 'n', 't', 0, + /* 45 */ 'n', 'o', 't', 'u', 's', 'e', 'd', 0, + /* 53 */ 'd', 'e', 't', 'a', 'i', 'l', 0 +}; +static const u8 iExplainColNames16[] = { + 0, 5, 12, 15, 18, 21, 24, 27, + 35, 38, 45, 53 +}; + /* ** Convert the N-th element of pStmt->pColName[] into a string using ** xFunc() then return that string. If N is out of range, return 0. @@ -89576,15 +90549,29 @@ static const void *columnName( return 0; } #endif + if( N<0 ) return 0; ret = 0; p = (Vdbe *)pStmt; db = p->db; assert( db!=0 ); - n = sqlite3_column_count(pStmt); - if( N=0 ){ + sqlite3_mutex_enter(db->mutex); + + if( p->explain ){ + if( useType>0 ) goto columnName_end; + n = p->explain==1 ? 8 : 4; + if( N>=n ) goto columnName_end; + if( useUtf16 ){ + int i = iExplainColNames16[N + 8*p->explain - 8]; + ret = (void*)&azExplainColNames16data[i]; + }else{ + ret = (void*)azExplainColNames8[N + 8*p->explain - 8]; + } + goto columnName_end; + } + n = p->nResColumn; + if( NmallocFailed; N += useType*n; - sqlite3_mutex_enter(db->mutex); #ifndef SQLITE_OMIT_UTF16 if( useUtf16 ){ ret = sqlite3_value_text16((sqlite3_value*)&p->aColName[N]); @@ -89601,8 +90588,9 @@ static const void *columnName( sqlite3OomClear(db); ret = 0; } - sqlite3_mutex_leave(db->mutex); } +columnName_end: + sqlite3_mutex_leave(db->mutex); return ret; } @@ -89695,7 +90683,7 @@ SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt *pStmt, int N){ /* ** Unbind the value bound to variable i in virtual machine p. This is the ** the same as binding a NULL value to the column. If the "i" parameter is -** out of range, then SQLITE_RANGE is returned. Othewise SQLITE_OK. +** out of range, then SQLITE_RANGE is returned. Otherwise SQLITE_OK. ** ** A successful evaluation of this routine acquires the mutex on p. ** the mutex is released if any kind of error occurs. @@ -90059,6 +91047,39 @@ SQLITE_API int sqlite3_stmt_isexplain(sqlite3_stmt *pStmt){ return pStmt ? ((Vdbe*)pStmt)->explain : 0; } +/* +** Set the explain mode for a statement. +*/ +SQLITE_API int sqlite3_stmt_explain(sqlite3_stmt *pStmt, int eMode){ + Vdbe *v = (Vdbe*)pStmt; + int rc; + sqlite3_mutex_enter(v->db->mutex); + if( ((int)v->explain)==eMode ){ + rc = SQLITE_OK; + }else if( eMode<0 || eMode>2 ){ + rc = SQLITE_ERROR; + }else if( (v->prepFlags & SQLITE_PREPARE_SAVESQL)==0 ){ + rc = SQLITE_ERROR; + }else if( v->eVdbeState!=VDBE_READY_STATE ){ + rc = SQLITE_BUSY; + }else if( v->nMem>=10 && (eMode!=2 || v->haveEqpOps) ){ + /* No reprepare necessary */ + v->explain = eMode; + rc = SQLITE_OK; + }else{ + v->explain = eMode; + rc = sqlite3Reprepare(v); + v->haveEqpOps = eMode==2; + } + if( v->explain ){ + v->nResColumn = 12 - 4*v->explain; + }else{ + v->nResColumn = v->nResAlloc; + } + sqlite3_mutex_leave(v->db->mutex); + return rc; +} + /* ** Return true if the prepared statement is in need of being reset. */ @@ -91298,6 +92319,9 @@ SQLITE_PRIVATE void sqlite3VdbeMemPrettyPrint(Mem *pMem, StrAccum *pStr){ sqlite3_str_appendchar(pStr, 1, (c>=0x20&&c<=0x7f) ? c : '.'); } sqlite3_str_appendf(pStr, "]%s", encnames[pMem->enc]); + if( f & MEM_Term ){ + sqlite3_str_appendf(pStr, "(0-term)"); + } } } #endif @@ -91434,6 +92458,93 @@ static u64 filterHash(const Mem *aMem, const Op *pOp){ return h; } + +/* +** For OP_Column, factor out the case where content is loaded from +** overflow pages, so that the code to implement this case is separate +** the common case where all content fits on the page. Factoring out +** the code reduces register pressure and helps the common case +** to run faster. +*/ +static SQLITE_NOINLINE int vdbeColumnFromOverflow( + VdbeCursor *pC, /* The BTree cursor from which we are reading */ + int iCol, /* The column to read */ + int t, /* The serial-type code for the column value */ + i64 iOffset, /* Offset to the start of the content value */ + u32 cacheStatus, /* Current Vdbe.cacheCtr value */ + u32 colCacheCtr, /* Current value of the column cache counter */ + Mem *pDest /* Store the value into this register. */ +){ + int rc; + sqlite3 *db = pDest->db; + int encoding = pDest->enc; + int len = sqlite3VdbeSerialTypeLen(t); + assert( pC->eCurType==CURTYPE_BTREE ); + if( len>db->aLimit[SQLITE_LIMIT_LENGTH] ) return SQLITE_TOOBIG; + if( len > 4000 && pC->pKeyInfo==0 ){ + /* Cache large column values that are on overflow pages using + ** an RCStr (reference counted string) so that if they are reloaded, + ** that do not have to be copied a second time. The overhead of + ** creating and managing the cache is such that this is only + ** profitable for larger TEXT and BLOB values. + ** + ** Only do this on table-btrees so that writes to index-btrees do not + ** need to clear the cache. This buys performance in the common case + ** in exchange for generality. + */ + VdbeTxtBlbCache *pCache; + char *pBuf; + if( pC->colCache==0 ){ + pC->pCache = sqlite3DbMallocZero(db, sizeof(VdbeTxtBlbCache) ); + if( pC->pCache==0 ) return SQLITE_NOMEM; + pC->colCache = 1; + } + pCache = pC->pCache; + if( pCache->pCValue==0 + || pCache->iCol!=iCol + || pCache->cacheStatus!=cacheStatus + || pCache->colCacheCtr!=colCacheCtr + || pCache->iOffset!=sqlite3BtreeOffset(pC->uc.pCursor) + ){ + if( pCache->pCValue ) sqlite3RCStrUnref(pCache->pCValue); + pBuf = pCache->pCValue = sqlite3RCStrNew( len+3 ); + if( pBuf==0 ) return SQLITE_NOMEM; + rc = sqlite3BtreePayload(pC->uc.pCursor, iOffset, len, pBuf); + if( rc ) return rc; + pBuf[len] = 0; + pBuf[len+1] = 0; + pBuf[len+2] = 0; + pCache->iCol = iCol; + pCache->cacheStatus = cacheStatus; + pCache->colCacheCtr = colCacheCtr; + pCache->iOffset = sqlite3BtreeOffset(pC->uc.pCursor); + }else{ + pBuf = pCache->pCValue; + } + assert( t>=12 ); + sqlite3RCStrRef(pBuf); + if( t&1 ){ + rc = sqlite3VdbeMemSetStr(pDest, pBuf, len, encoding, + (void(*)(void*))sqlite3RCStrUnref); + pDest->flags |= MEM_Term; + }else{ + rc = sqlite3VdbeMemSetStr(pDest, pBuf, len, 0, + (void(*)(void*))sqlite3RCStrUnref); + } + }else{ + rc = sqlite3VdbeMemFromBtree(pC->uc.pCursor, iOffset, len, pDest); + if( rc ) return rc; + sqlite3VdbeSerialGet((const u8*)pDest->z, t, pDest); + if( (t&1)!=0 && encoding==SQLITE_UTF8 ){ + pDest->z[len] = 0; + pDest->flags |= MEM_Term; + } + } + pDest->flags &= ~MEM_Ephem; + return rc; +} + + /* ** Return the symbolic name for the data type of a pMem */ @@ -91476,6 +92587,7 @@ SQLITE_PRIVATE int sqlite3VdbeExec( Mem *pIn2 = 0; /* 2nd input operand */ Mem *pIn3 = 0; /* 3rd input operand */ Mem *pOut = 0; /* Output operand */ + u32 colCacheCtr = 0; /* Column cache counter */ #if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || defined(VDBE_PROFILE) u64 *pnCycle = 0; int bStmtScanStatus = IS_STMT_SCANSTATUS(db)!=0; @@ -91671,8 +92783,8 @@ SQLITE_PRIVATE int sqlite3VdbeExec( case OP_Goto: { /* jump */ #ifdef SQLITE_DEBUG - /* In debuggging mode, when the p5 flags is set on an OP_Goto, that - ** means we should really jump back to the preceeding OP_ReleaseReg + /* In debugging mode, when the p5 flags is set on an OP_Goto, that + ** means we should really jump back to the preceding OP_ReleaseReg ** instruction. */ if( pOp->p5 ){ assert( pOp->p2 < (int)(pOp - aOp) ); @@ -91880,7 +92992,7 @@ case OP_HaltIfNull: { /* in3 */ ** P5 is a value between 0 and 4, inclusive, that modifies the P4 string. ** ** 0: (no change) -** 1: NOT NULL contraint failed: P4 +** 1: NOT NULL constraint failed: P4 ** 2: UNIQUE constraint failed: P4 ** 3: CHECK constraint failed: P4 ** 4: FOREIGN KEY constraint failed: P4 @@ -93011,10 +94123,10 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */ ** opcodes are allowed to occur between this instruction and the previous ** OP_Lt or OP_Gt. ** -** If result of an OP_Eq comparison on the same two operands as the -** prior OP_Lt or OP_Gt would have been true, then jump to P2. -** If the result of an OP_Eq comparison on the two previous -** operands would have been false or NULL, then fall through. +** If the result of an OP_Eq comparison on the same two operands as +** the prior OP_Lt or OP_Gt would have been true, then jump to P2. If +** the result of an OP_Eq comparison on the two previous operands +** would have been false or NULL, then fall through. */ case OP_ElseEq: { /* same as TK_ESCAPE, jump */ @@ -93444,7 +94556,7 @@ case OP_IsType: { /* jump */ /* Opcode: ZeroOrNull P1 P2 P3 * * ** Synopsis: r[P2] = 0 OR NULL ** -** If all both registers P1 and P3 are NOT NULL, then store a zero in +** If both registers P1 and P3 are NOT NULL, then store a zero in ** register P2. If either registers P1 or P3 are NULL then put ** a NULL in register P2. */ @@ -93798,11 +94910,16 @@ op_column_restart: pDest->flags = aFlag[t&1]; } }else{ + u8 p5; pDest->enc = encoding; + assert( pDest->db==db ); /* This branch happens only when content is on overflow pages */ - if( ((pOp->p5 & (OPFLAG_LENGTHARG|OPFLAG_TYPEOFARG))!=0 - && ((t>=12 && (t&1)==0) || (pOp->p5 & OPFLAG_TYPEOFARG)!=0)) - || (len = sqlite3VdbeSerialTypeLen(t))==0 + if( ((p5 = (pOp->p5 & OPFLAG_BYTELENARG))!=0 + && (p5==OPFLAG_TYPEOFARG + || (t>=12 && ((t&1)==0 || p5==OPFLAG_BYTELENARG)) + ) + ) + || sqlite3VdbeSerialTypeLen(t)==0 ){ /* Content is irrelevant for ** 1. the typeof() function, @@ -93819,11 +94936,13 @@ op_column_restart: */ sqlite3VdbeSerialGet((u8*)sqlite3CtypeMap, t, pDest); }else{ - if( len>db->aLimit[SQLITE_LIMIT_LENGTH] ) goto too_big; - rc = sqlite3VdbeMemFromBtree(pC->uc.pCursor, aOffset[p2], len, pDest); - if( rc!=SQLITE_OK ) goto abort_due_to_error; - sqlite3VdbeSerialGet((const u8*)pDest->z, t, pDest); - pDest->flags &= ~MEM_Ephem; + rc = vdbeColumnFromOverflow(pC, p2, t, aOffset[p2], + p->cacheCtr, colCacheCtr, pDest); + if( rc ){ + if( rc==SQLITE_NOMEM ) goto no_mem; + if( rc==SQLITE_TOOBIG ) goto too_big; + goto abort_due_to_error; + } } } @@ -95107,7 +96226,7 @@ case OP_OpenEphemeral: { /* ncycle */ } pCx = p->apCsr[pOp->p1]; if( pCx && !pCx->noReuse && ALWAYS(pOp->p2<=pCx->nField) ){ - /* If the ephermeral table is already open and has no duplicates from + /* If the ephemeral table is already open and has no duplicates from ** OP_OpenDup, then erase all existing content so that the table is ** empty again, rather than creating a new table. */ assert( pCx->isEphemeral ); @@ -95598,7 +96717,7 @@ seek_not_found: ** row. If This.P5 is false (0) then a jump is made to SeekGE.P2. If ** This.P5 is true (non-zero) then a jump is made to This.P2. The P5==0 ** case occurs when there are no inequality constraints to the right of -** the IN constraing. The jump to SeekGE.P2 ends the loop. The P5!=0 case +** the IN constraint. The jump to SeekGE.P2 ends the loop. The P5!=0 case ** occurs when there are inequality constraints to the right of the IN ** operator. In that case, the This.P2 will point either directly to or ** to setup code prior to the OP_IdxGT or OP_IdxGE opcode that checks for @@ -95606,7 +96725,7 @@ seek_not_found: ** ** Possible outcomes from this opcode:
      ** -**
    1. If the cursor is initally not pointed to any valid row, then +**
    2. If the cursor is initially not pointed to any valid row, then ** fall through into the subsequent OP_SeekGE opcode. ** **
    3. If the cursor is left pointing to a row that is before the target @@ -95838,13 +96957,13 @@ case OP_IfNotOpen: { /* jump */ ** operands to OP_NotFound and OP_IdxGT. ** ** This opcode is an optimization attempt only. If this opcode always -** falls through, the correct answer is still obtained, but extra works +** falls through, the correct answer is still obtained, but extra work ** is performed. ** ** A value of N in the seekHit flag of cursor P1 means that there exists ** a key P3:N that will match some record in the index. We want to know ** if it is possible for a record P3:P4 to match some record in the -** index. If it is not possible, we can skips some work. So if seekHit +** index. If it is not possible, we can skip some work. So if seekHit ** is less than P4, attempt to find out if a match is possible by running ** OP_NotFound. ** @@ -96356,6 +97475,7 @@ case OP_Insert: { ); pC->deferredMoveto = 0; pC->cacheStatus = CACHE_STALE; + colCacheCtr++; /* Invoke the update-hook if required. */ if( rc ) goto abort_due_to_error; @@ -96409,10 +97529,10 @@ case OP_RowCell: { ** left in an undefined state. ** ** If the OPFLAG_AUXDELETE bit is set on P5, that indicates that this -** delete one of several associated with deleting a table row and all its -** associated index entries. Exactly one of those deletes is the "primary" -** delete. The others are all on OPFLAG_FORDELETE cursors or else are -** marked with the AUXDELETE flag. +** delete is one of several associated with deleting a table row and +** all its associated index entries. Exactly one of those deletes is +** the "primary" delete. The others are all on OPFLAG_FORDELETE +** cursors or else are marked with the AUXDELETE flag. ** ** If the OPFLAG_NCHANGE flag of P2 (NB: P2 not P5) is set, then the row ** change count is incremented (otherwise not). @@ -96516,6 +97636,7 @@ case OP_Delete: { rc = sqlite3BtreeDelete(pC->uc.pCursor, pOp->p5); pC->cacheStatus = CACHE_STALE; + colCacheCtr++; pC->seekResult = 0; if( rc ) goto abort_due_to_error; @@ -96583,13 +97704,13 @@ case OP_SorterCompare: { ** Write into register P2 the current sorter data for sorter cursor P1. ** Then clear the column header cache on cursor P3. ** -** This opcode is normally use to move a record out of the sorter and into +** This opcode is normally used to move a record out of the sorter and into ** a register that is the source for a pseudo-table cursor created using ** OpenPseudo. That pseudo-table cursor is the one that is identified by ** parameter P3. Clearing the P3 column cache as part of this opcode saves ** us from having to issue a separate NullRow instruction to clear that cache. */ -case OP_SorterData: { +case OP_SorterData: { /* ncycle */ VdbeCursor *pC; pOut = &aMem[pOp->p2]; @@ -96864,8 +97985,8 @@ case OP_IfSmaller: { /* jump */ ** regression tests can determine whether or not the optimizer is ** correctly optimizing out sorts. */ -case OP_SorterSort: /* jump */ -case OP_Sort: { /* jump */ +case OP_SorterSort: /* jump ncycle */ +case OP_Sort: { /* jump ncycle */ #ifdef SQLITE_TEST sqlite3_sort_count++; sqlite3_search_count--; @@ -97392,7 +98513,7 @@ case OP_IdxGE: { /* jump, ncycle */ ** file is given by P1. ** ** The table being destroyed is in the main database file if P3==0. If -** P3==1 then the table to be clear is in the auxiliary database file +** P3==1 then the table to be destroyed is in the auxiliary database file ** that is used to store tables create using CREATE TEMPORARY TABLE. ** ** If AUTOVACUUM is enabled then it is possible that another root page @@ -97452,8 +98573,8 @@ case OP_Destroy: { /* out2 */ ** in the database file is given by P1. But, unlike Destroy, do not ** remove the table or index from the database file. ** -** The table being clear is in the main database file if P2==0. If -** P2==1 then the table to be clear is in the auxiliary database file +** The table being cleared is in the main database file if P2==0. If +** P2==1 then the table to be cleared is in the auxiliary database file ** that is used to store tables create using CREATE TEMPORARY TABLE. ** ** If the P3 value is non-zero, then the row change count is incremented @@ -98279,7 +99400,7 @@ case OP_AggStep1: { /* If this function is inside of a trigger, the register array in aMem[] ** might change from one evaluation to the next. The next block of code ** checks to see if the register array has changed, and if so it - ** reinitializes the relavant parts of the sqlite3_context object */ + ** reinitializes the relevant parts of the sqlite3_context object */ if( pCtx->pMem != pMem ){ pCtx->pMem = pMem; for(i=pCtx->argc-1; i>=0; i--) pCtx->argv[i] = &aMem[pOp->p2+i]; @@ -99157,7 +100278,7 @@ case OP_MaxPgcnt: { /* out2 */ ** This opcode works exactly like OP_Function. The only difference is in ** its name. This opcode is used in places where the function must be ** purely non-deterministic. Some built-in date/time functions can be -** either determinitic of non-deterministic, depending on their arguments. +** either deterministic of non-deterministic, depending on their arguments. ** When those function are used in a non-deterministic way, they will check ** to see if they were called using OP_PureFunc instead of OP_Function, and ** if they were, they throw an error. @@ -99175,7 +100296,7 @@ case OP_Function: { /* group */ /* If this function is inside of a trigger, the register array in aMem[] ** might change from one evaluation to the next. The next block of code ** checks to see if the register array has changed, and if so it - ** reinitializes the relavant parts of the sqlite3_context object */ + ** reinitializes the relevant parts of the sqlite3_context object */ pOut = &aMem[pOp->p3]; if( pCtx->pOut != pOut ){ pCtx->pVdbe = p; @@ -99251,7 +100372,7 @@ case OP_FilterAdd: { printf("hash: %llu modulo %d -> %u\n", h, pIn1->n, (int)(h%pIn1->n)); } #endif - h %= pIn1->n; + h %= (pIn1->n*8); pIn1->z[h/8] |= 1<<(h&7); break; } @@ -99287,7 +100408,7 @@ case OP_Filter: { /* jump */ printf("hash: %llu modulo %d -> %u\n", h, pIn1->n, (int)(h%pIn1->n)); } #endif - h %= pIn1->n; + h %= (pIn1->n*8); if( (pIn1->z[h/8] & (1<<(h&7)))==0 ){ VdbeBranchTaken(1, 2); p->aCounter[SQLITE_STMTSTATUS_FILTER_HIT]++; @@ -99539,7 +100660,7 @@ default: { /* This is really OP_Noop, OP_Explain */ } if( opProperty==0xff ){ /* Never happens. This code exists to avoid a harmless linkage - ** warning aboud sqlite3VdbeRegisterDump() being defined but not + ** warning about sqlite3VdbeRegisterDump() being defined but not ** used. */ sqlite3VdbeRegisterDump(p); } @@ -100257,7 +101378,7 @@ SQLITE_API int sqlite3_blob_reopen(sqlite3_blob *pBlob, sqlite3_int64 iRow){ ** The threshold for the amount of main memory to use before flushing ** records to a PMA is roughly the same as the limit configured for the ** page-cache of the main database. Specifically, the threshold is set to -** the value returned by "PRAGMA main.page_size" multipled by +** the value returned by "PRAGMA main.page_size" multiplied by ** that returned by "PRAGMA main.cache_size", in bytes. ** ** If the sorter is running in single-threaded mode, then all PMAs generated @@ -100280,7 +101401,7 @@ SQLITE_API int sqlite3_blob_reopen(sqlite3_blob *pBlob, sqlite3_int64 iRow){ ** ** If there are fewer than SORTER_MAX_MERGE_COUNT PMAs in total and the ** sorter is running in single-threaded mode, then these PMAs are merged -** incrementally as keys are retreived from the sorter by the VDBE. The +** incrementally as keys are retrieved from the sorter by the VDBE. The ** MergeEngine object, described in further detail below, performs this ** merge. ** @@ -100443,7 +101564,7 @@ struct MergeEngine { ** ** Essentially, this structure contains all those fields of the VdbeSorter ** structure for which each thread requires a separate instance. For example, -** each thread requries its own UnpackedRecord object to unpack records in +** each thread requeries its own UnpackedRecord object to unpack records in ** as part of comparison operations. ** ** Before a background thread is launched, variable bDone is set to 0. Then, @@ -100515,7 +101636,7 @@ struct VdbeSorter { ** PMA, in sorted order. The next key to be read is cached in nKey/aKey. ** aKey might point into aMap or into aBuffer. If neither of those locations ** contain a contiguous representation of the key, then aAlloc is allocated -** and the key is copied into aAlloc and aKey is made to poitn to aAlloc. +** and the key is copied into aAlloc and aKey is made to point to aAlloc. ** ** pFd==0 at EOF. */ @@ -101886,7 +103007,7 @@ static int vdbeSorterFlushPMA(VdbeSorter *pSorter){ ** the background thread from a sub-tasks previous turn is still running, ** skip it. If the first (pSorter->nTask-1) sub-tasks are all still busy, ** fall back to using the final sub-task. The first (pSorter->nTask-1) - ** sub-tasks are prefered as they use background threads - the final + ** sub-tasks are preferred as they use background threads - the final ** sub-task uses the main thread. */ for(i=0; iiPrev + i + 1) % nWorker; @@ -102370,7 +103491,7 @@ static int vdbePmaReaderIncrMergeInit(PmaReader *pReadr, int eMode){ rc = vdbeMergeEngineInit(pTask, pIncr->pMerger, eMode); - /* Set up the required files for pIncr. A multi-theaded IncrMerge object + /* Set up the required files for pIncr. A multi-threaded IncrMerge object ** requires two temp files to itself, whereas a single-threaded object ** only requires a region of pTask->file2. */ if( rc==SQLITE_OK ){ @@ -103010,6 +104131,8 @@ static int bytecodevtabConnect( "p5 INT," "comment TEXT," "subprog TEXT," + "nexec INT," + "ncycle INT," "stmt HIDDEN" ");", @@ -103172,7 +104295,7 @@ static int bytecodevtabColumn( } } } - i += 10; + i += 20; } } switch( i ){ @@ -103222,16 +104345,31 @@ static int bytecodevtabColumn( } break; } - case 10: /* tables_used.type */ + +#ifdef SQLITE_ENABLE_STMT_SCANSTATUS + case 9: /* nexec */ + sqlite3_result_int(ctx, pOp->nExec); + break; + case 10: /* ncycle */ + sqlite3_result_int(ctx, pOp->nCycle); + break; +#else + case 9: /* nexec */ + case 10: /* ncycle */ + sqlite3_result_int(ctx, 0); + break; +#endif + + case 20: /* tables_used.type */ sqlite3_result_text(ctx, pCur->zType, -1, SQLITE_STATIC); break; - case 11: /* tables_used.schema */ + case 21: /* tables_used.schema */ sqlite3_result_text(ctx, pCur->zSchema, -1, SQLITE_STATIC); break; - case 12: /* tables_used.name */ + case 22: /* tables_used.name */ sqlite3_result_text(ctx, pCur->zName, -1, SQLITE_STATIC); break; - case 13: /* tables_used.wr */ + case 23: /* tables_used.wr */ sqlite3_result_int(ctx, pOp->opcode==OP_OpenWrite); break; } @@ -103305,7 +104443,7 @@ static int bytecodevtabBestIndex( int rc = SQLITE_CONSTRAINT; struct sqlite3_index_constraint *p; bytecodevtab *pVTab = (bytecodevtab*)tab; - int iBaseCol = pVTab->bTablesUsed ? 4 : 8; + int iBaseCol = pVTab->bTablesUsed ? 4 : 10; pIdxInfo->estimatedCost = (double)100; pIdxInfo->estimatedRows = 100; pIdxInfo->idxNum = 0; @@ -103876,7 +105014,7 @@ static int walkWindowList(Walker *pWalker, Window *pList, int bOneOnly){ ** The return value from this routine is WRC_Abort to abandon the tree walk ** and WRC_Continue to continue. */ -static SQLITE_NOINLINE int walkExpr(Walker *pWalker, Expr *pExpr){ +SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3WalkExprNN(Walker *pWalker, Expr *pExpr){ int rc; testcase( ExprHasProperty(pExpr, EP_TokenOnly) ); testcase( ExprHasProperty(pExpr, EP_Reduced) ); @@ -103885,7 +105023,9 @@ static SQLITE_NOINLINE int walkExpr(Walker *pWalker, Expr *pExpr){ if( rc ) return rc & WRC_Abort; if( !ExprHasProperty(pExpr,(EP_TokenOnly|EP_Leaf)) ){ assert( pExpr->x.pList==0 || pExpr->pRight==0 ); - if( pExpr->pLeft && walkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort; + if( pExpr->pLeft && sqlite3WalkExprNN(pWalker, pExpr->pLeft) ){ + return WRC_Abort; + } if( pExpr->pRight ){ assert( !ExprHasProperty(pExpr, EP_WinFunc) ); pExpr = pExpr->pRight; @@ -103909,7 +105049,7 @@ static SQLITE_NOINLINE int walkExpr(Walker *pWalker, Expr *pExpr){ return WRC_Continue; } SQLITE_PRIVATE int sqlite3WalkExpr(Walker *pWalker, Expr *pExpr){ - return pExpr ? walkExpr(pWalker,pExpr) : WRC_Continue; + return pExpr ? sqlite3WalkExprNN(pWalker,pExpr) : WRC_Continue; } /* @@ -104035,7 +105175,7 @@ SQLITE_PRIVATE int sqlite3WalkSelect(Walker *pWalker, Select *p){ } /* Increase the walkerDepth when entering a subquery, and -** descrease when leaving the subquery. +** decrease when leaving the subquery. */ SQLITE_PRIVATE int sqlite3WalkerDepthIncrease(Walker *pWalker, Select *pSelect){ UNUSED_PARAMETER(pSelect); @@ -105769,7 +106909,7 @@ static int resolveOrderGroupBy( } for(j=0; jpEList->nExpr; j++){ if( sqlite3ExprCompare(0, pE, pSelect->pEList->a[j].pExpr, -1)==0 ){ - /* Since this expresion is being changed into a reference + /* Since this expression is being changed into a reference ** to an identical expression in the result set, remove all Window ** objects belonging to the expression from the Select.pWin list. */ windowRemoveExprFromSelect(pSelect, pE); @@ -106092,7 +107232,8 @@ SQLITE_PRIVATE int sqlite3ResolveExprNames( return SQLITE_ERROR; } #endif - sqlite3WalkExpr(&w, pExpr); + assert( pExpr!=0 ); + sqlite3WalkExprNN(&w, pExpr); #if SQLITE_MAX_EXPR_DEPTH>0 w.pParse->nHeight -= pExpr->nHeight; #endif @@ -106134,7 +107275,7 @@ SQLITE_PRIVATE int sqlite3ResolveExprListNames( return WRC_Abort; } #endif - sqlite3WalkExpr(&w, pExpr); + sqlite3WalkExprNN(&w, pExpr); #if SQLITE_MAX_EXPR_DEPTH>0 w.pParse->nHeight -= pExpr->nHeight; #endif @@ -106156,7 +107297,7 @@ SQLITE_PRIVATE int sqlite3ResolveExprListNames( /* ** Resolve all names in all expressions of a SELECT and in all -** decendents of the SELECT, including compounds off of p->pPrior, +** descendants of the SELECT, including compounds off of p->pPrior, ** subqueries in expressions, and subqueries used as FROM clause ** terms. ** @@ -106306,6 +107447,7 @@ SQLITE_PRIVATE char sqlite3ExprAffinity(const Expr *pExpr){ if( op==TK_SELECT_COLUMN ){ assert( pExpr->pLeft!=0 && ExprUseXSelect(pExpr->pLeft) ); assert( pExpr->iColumn < pExpr->iTable ); + assert( pExpr->iColumn >= 0 ); assert( pExpr->iTable==pExpr->pLeft->x.pSelect->pEList->nExpr ); return sqlite3ExprAffinity( pExpr->pLeft->x.pSelect->pEList->a[pExpr->iColumn].pExpr @@ -106542,7 +107684,7 @@ SQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, const Expr *pExpr){ /* ** Return the collation sequence for the expression pExpr. If ** there is no defined collating sequence, return a pointer to the -** defautl collation sequence. +** default collation sequence. ** ** See also: sqlite3ExprCollSeq() ** @@ -106672,7 +107814,7 @@ SQLITE_PRIVATE CollSeq *sqlite3BinaryCompareCollSeq( return pColl; } -/* Expresssion p is a comparison operator. Return a collation sequence +/* Expression p is a comparison operator. Return a collation sequence ** appropriate for the comparison operator. ** ** This is normally just a wrapper around sqlite3BinaryCompareCollSeq(). @@ -107128,6 +108270,15 @@ SQLITE_PRIVATE void sqlite3ExprSetHeightAndFlags(Parse *pParse, Expr *p){ #define exprSetHeight(y) #endif /* SQLITE_MAX_EXPR_DEPTH>0 */ +/* +** Set the error offset for an Expr node, if possible. +*/ +SQLITE_PRIVATE void sqlite3ExprSetErrorOffset(Expr *pExpr, int iOfst){ + if( pExpr==0 ) return; + if( NEVER(ExprUseWJoin(pExpr)) ) return; + pExpr->w.iOfst = iOfst; +} + /* ** This routine is the core allocator for Expr nodes. ** @@ -107588,7 +108739,7 @@ SQLITE_PRIVATE void sqlite3ClearOnOrUsing(sqlite3 *db, OnOrUsing *p){ /* ** Arrange to cause pExpr to be deleted when the pParse is deleted. ** This is similar to sqlite3ExprDelete() except that the delete is -** deferred untilthe pParse is deleted. +** deferred until the pParse is deleted. ** ** The pExpr might be deleted immediately on an OOM error. ** @@ -108430,7 +109581,7 @@ SQLITE_PRIVATE int sqlite3ExprIdToTrueFalse(Expr *pExpr){ ** and 0 if it is FALSE. */ SQLITE_PRIVATE int sqlite3ExprTruthValue(const Expr *pExpr){ - pExpr = sqlite3ExprSkipCollate((Expr*)pExpr); + pExpr = sqlite3ExprSkipCollateAndLikely((Expr*)pExpr); assert( pExpr->op==TK_TRUEFALSE ); assert( !ExprHasProperty(pExpr, EP_IntValue) ); assert( sqlite3StrICmp(pExpr->u.zToken,"true")==0 @@ -109023,7 +110174,7 @@ static int sqlite3InRhsIsConstant(Expr *pIn){ ** IN_INDEX_INDEX_ASC - The cursor was opened on an ascending index. ** IN_INDEX_INDEX_DESC - The cursor was opened on a descending index. ** IN_INDEX_EPH - The cursor was opened on a specially created and -** populated epheremal table. +** populated ephemeral table. ** IN_INDEX_NOOP - No cursor was allocated. The IN operator must be ** implemented as a sequence of comparisons. ** @@ -109036,7 +110187,7 @@ static int sqlite3InRhsIsConstant(Expr *pIn){ ** an ephemeral table might need to be generated from the RHS and then ** pX->iTable made to point to the ephemeral table instead of an ** existing table. In this case, the creation and initialization of the -** ephmeral table might be put inside of a subroutine, the EP_Subrtn flag +** ephemeral table might be put inside of a subroutine, the EP_Subrtn flag ** will be set on pX and the pX->y.sub fields will be set to show where ** the subroutine is coded. ** @@ -109048,12 +110199,12 @@ static int sqlite3InRhsIsConstant(Expr *pIn){ ** ** When IN_INDEX_LOOP is used (and the b-tree will be used to iterate ** through the set members) then the b-tree must not contain duplicates. -** An epheremal table will be created unless the selected columns are guaranteed +** An ephemeral table will be created unless the selected columns are guaranteed ** to be unique - either because it is an INTEGER PRIMARY KEY or due to ** a UNIQUE constraint or index. ** ** When IN_INDEX_MEMBERSHIP is used (and the b-tree will be used -** for fast set membership tests) then an epheremal table must +** for fast set membership tests) then an ephemeral table must ** be used unless is a single INTEGER PRIMARY KEY column or an ** index can be found with the specified as its left-most. ** @@ -109386,7 +110537,7 @@ SQLITE_PRIVATE void sqlite3VectorErrorMsg(Parse *pParse, Expr *pExpr){ ** x IN (SELECT a FROM b) -- IN operator with subquery on the right ** ** The pExpr parameter is the IN operator. The cursor number for the -** constructed ephermeral table is returned. The first time the ephemeral +** constructed ephemeral table is returned. The first time the ephemeral ** table is computed, the cursor number is also stored in pExpr->iTable, ** however the cursor number returned might not be the same, as it might ** have been duplicated using OP_OpenDup. @@ -110201,10 +111352,13 @@ SQLITE_PRIVATE int sqlite3ExprCodeGetColumn( u8 p5 /* P5 value for OP_Column + FLAGS */ ){ assert( pParse->pVdbe!=0 ); + assert( (p5 & (OPFLAG_NOCHNG|OPFLAG_TYPEOFARG|OPFLAG_LENGTHARG))==p5 ); + assert( IsVirtual(pTab) || (p5 & OPFLAG_NOCHNG)==0 ); sqlite3ExprCodeGetColumnOfTable(pParse->pVdbe, pTab, iTable, iColumn, iReg); if( p5 ){ VdbeOp *pOp = sqlite3VdbeGetLastOp(pParse->pVdbe); if( pOp->opcode==OP_Column ) pOp->p5 = p5; + if( pOp->opcode==OP_VColumn ) pOp->p5 = (p5 & OPFLAG_NOCHNG); } return iReg; } @@ -110233,7 +111387,7 @@ static void exprToRegister(Expr *pExpr, int iReg){ /* ** Evaluate an expression (either a vector or a scalar expression) and store -** the result in continguous temporary registers. Return the index of +** the result in contiguous temporary registers. Return the index of ** the first register used to store the result. ** ** If the returned result register is a temporary scalar, then also write @@ -110273,7 +111427,7 @@ static int exprCodeVector(Parse *pParse, Expr *p, int *piFreeable){ */ static void setDoNotMergeFlagOnCopy(Vdbe *v){ if( sqlite3VdbeGetLastOp(v)->opcode==OP_Copy ){ - sqlite3VdbeChangeP5(v, 1); /* Tag trailing OP_Copy as not mergable */ + sqlite3VdbeChangeP5(v, 1); /* Tag trailing OP_Copy as not mergeable */ } } @@ -110363,13 +111517,13 @@ static int exprCodeInlineFunction( } case INLINEFUNC_implies_nonnull_row: { - /* REsult of sqlite3ExprImpliesNonNullRow() */ + /* Result of sqlite3ExprImpliesNonNullRow() */ Expr *pA1; assert( nFarg==2 ); pA1 = pFarg->a[1].pExpr; if( pA1->op==TK_COLUMN ){ sqlite3VdbeAddOp2(v, OP_Integer, - sqlite3ExprImpliesNonNullRow(pFarg->a[0].pExpr,pA1->iTable), + sqlite3ExprImpliesNonNullRow(pFarg->a[0].pExpr,pA1->iTable,1), target); }else{ sqlite3VdbeAddOp2(v, OP_Null, 0, target); @@ -110545,7 +111699,7 @@ expr_code_doover: if( ExprHasProperty(pExpr, EP_FixedCol) ){ /* This COLUMN expression is really a constant due to WHERE clause ** constraints, and that constant is coded by the pExpr->pLeft - ** expresssion. However, make sure the constant has the correct + ** expression. However, make sure the constant has the correct ** datatype by applying the Affinity of the table column to the ** constant. */ @@ -110871,7 +112025,7 @@ expr_code_doover: sqlite3ErrorMsg(pParse, "unknown function: %#T()", pExpr); break; } - if( pDef->funcFlags & SQLITE_FUNC_INLINE ){ + if( (pDef->funcFlags & SQLITE_FUNC_INLINE)!=0 && ALWAYS(pFarg!=0) ){ assert( (pDef->funcFlags & SQLITE_FUNC_UNSAFE)==0 ); assert( (pDef->funcFlags & SQLITE_FUNC_DIRECT)==0 ); return exprCodeInlineFunction(pParse, pFarg, @@ -110897,10 +112051,10 @@ expr_code_doover: r1 = sqlite3GetTempRange(pParse, nFarg); } - /* For length() and typeof() functions with a column argument, + /* For length() and typeof() and octet_length() functions, ** set the P5 parameter to the OP_Column opcode to OPFLAG_LENGTHARG - ** or OPFLAG_TYPEOFARG respectively, to avoid unnecessary data - ** loading. + ** or OPFLAG_TYPEOFARG or OPFLAG_BYTELENARG respectively, to avoid + ** unnecessary data loading. */ if( (pDef->funcFlags & (SQLITE_FUNC_LENGTH|SQLITE_FUNC_TYPEOF))!=0 ){ u8 exprOp; @@ -110910,14 +112064,16 @@ expr_code_doover: if( exprOp==TK_COLUMN || exprOp==TK_AGG_COLUMN ){ assert( SQLITE_FUNC_LENGTH==OPFLAG_LENGTHARG ); assert( SQLITE_FUNC_TYPEOF==OPFLAG_TYPEOFARG ); - testcase( pDef->funcFlags & OPFLAG_LENGTHARG ); - pFarg->a[0].pExpr->op2 = - pDef->funcFlags & (OPFLAG_LENGTHARG|OPFLAG_TYPEOFARG); + assert( SQLITE_FUNC_BYTELEN==OPFLAG_BYTELENARG ); + assert( (OPFLAG_LENGTHARG|OPFLAG_TYPEOFARG)==OPFLAG_BYTELENARG ); + testcase( (pDef->funcFlags & OPFLAG_BYTELENARG)==OPFLAG_LENGTHARG ); + testcase( (pDef->funcFlags & OPFLAG_BYTELENARG)==OPFLAG_TYPEOFARG ); + testcase( (pDef->funcFlags & OPFLAG_BYTELENARG)==OPFLAG_BYTELENARG); + pFarg->a[0].pExpr->op2 = pDef->funcFlags & OPFLAG_BYTELENARG; } } - sqlite3ExprCodeExprList(pParse, pFarg, r1, 0, - SQLITE_ECEL_DUP|SQLITE_ECEL_FACTOR); + sqlite3ExprCodeExprList(pParse, pFarg, r1, 0, SQLITE_ECEL_FACTOR); }else{ r1 = 0; } @@ -111274,7 +112430,7 @@ expr_code_doover: ** ** If regDest>=0 then the result is always stored in that register and the ** result is not reusable. If regDest<0 then this routine is free to -** store the value whereever it wants. The register where the expression +** store the value wherever it wants. The register where the expression ** is stored is returned. When regDest<0, two identical expressions might ** code to the same register, if they do not contain function calls and hence ** are factored out into the initialization section at the end of the @@ -112192,7 +113348,7 @@ static int exprImpliesNotNull( ** pE1: x!=123 pE2: x IS NOT NULL Result: true ** pE1: x!=?1 pE2: x IS NOT NULL Result: true ** pE1: x IS NULL pE2: x IS NOT NULL Result: false -** pE1: x IS ?2 pE2: x IS NOT NULL Reuslt: false +** pE1: x IS ?2 pE2: x IS NOT NULL Result: false ** ** When comparing TK_COLUMN nodes between pE1 and pE2, if pE2 has ** Expr.iTable<0 then assume a table number given by iTab. @@ -112229,11 +113385,29 @@ SQLITE_PRIVATE int sqlite3ExprImpliesExpr( return 0; } +/* This is a helper function to impliesNotNullRow(). In this routine, +** set pWalker->eCode to one only if *both* of the input expressions +** separately have the implies-not-null-row property. +*/ +static void bothImplyNotNullRow(Walker *pWalker, Expr *pE1, Expr *pE2){ + if( pWalker->eCode==0 ){ + sqlite3WalkExpr(pWalker, pE1); + if( pWalker->eCode ){ + pWalker->eCode = 0; + sqlite3WalkExpr(pWalker, pE2); + } + } +} + /* ** This is the Expr node callback for sqlite3ExprImpliesNonNullRow(). ** If the expression node requires that the table at pWalker->iCur ** have one or more non-NULL column, then set pWalker->eCode to 1 and abort. ** +** pWalker->mWFlags is non-zero if this inquiry is being undertaking on +** behalf of a RIGHT JOIN (or FULL JOIN). That makes a difference when +** evaluating terms in the ON clause of an inner join. +** ** This routine controls an optimization. False positives (setting ** pWalker->eCode to 1 when it should not be) are deadly, but false-negatives ** (never setting pWalker->eCode) is a harmless missed optimization. @@ -112242,28 +113416,33 @@ static int impliesNotNullRow(Walker *pWalker, Expr *pExpr){ testcase( pExpr->op==TK_AGG_COLUMN ); testcase( pExpr->op==TK_AGG_FUNCTION ); if( ExprHasProperty(pExpr, EP_OuterON) ) return WRC_Prune; + if( ExprHasProperty(pExpr, EP_InnerON) && pWalker->mWFlags ){ + /* If iCur is used in an inner-join ON clause to the left of a + ** RIGHT JOIN, that does *not* mean that the table must be non-null. + ** But it is difficult to check for that condition precisely. + ** To keep things simple, any use of iCur from any inner-join is + ** ignored while attempting to simplify a RIGHT JOIN. */ + return WRC_Prune; + } switch( pExpr->op ){ case TK_ISNOT: case TK_ISNULL: case TK_NOTNULL: case TK_IS: - case TK_OR: case TK_VECTOR: - case TK_CASE: - case TK_IN: case TK_FUNCTION: case TK_TRUTH: + case TK_CASE: testcase( pExpr->op==TK_ISNOT ); testcase( pExpr->op==TK_ISNULL ); testcase( pExpr->op==TK_NOTNULL ); testcase( pExpr->op==TK_IS ); - testcase( pExpr->op==TK_OR ); testcase( pExpr->op==TK_VECTOR ); - testcase( pExpr->op==TK_CASE ); - testcase( pExpr->op==TK_IN ); testcase( pExpr->op==TK_FUNCTION ); testcase( pExpr->op==TK_TRUTH ); + testcase( pExpr->op==TK_CASE ); return WRC_Prune; + case TK_COLUMN: if( pWalker->u.iCur==pExpr->iTable ){ pWalker->eCode = 1; @@ -112271,21 +113450,38 @@ static int impliesNotNullRow(Walker *pWalker, Expr *pExpr){ } return WRC_Prune; + case TK_OR: case TK_AND: - if( pWalker->eCode==0 ){ + /* Both sides of an AND or OR must separately imply non-null-row. + ** Consider these cases: + ** 1. NOT (x AND y) + ** 2. x OR y + ** If only one of x or y is non-null-row, then the overall expression + ** can be true if the other arm is false (case 1) or true (case 2). + */ + testcase( pExpr->op==TK_OR ); + testcase( pExpr->op==TK_AND ); + bothImplyNotNullRow(pWalker, pExpr->pLeft, pExpr->pRight); + return WRC_Prune; + + case TK_IN: + /* Beware of "x NOT IN ()" and "x NOT IN (SELECT 1 WHERE false)", + ** both of which can be true. But apart from these cases, if + ** the left-hand side of the IN is NULL then the IN itself will be + ** NULL. */ + if( ExprUseXList(pExpr) && ALWAYS(pExpr->x.pList->nExpr>0) ){ sqlite3WalkExpr(pWalker, pExpr->pLeft); - if( pWalker->eCode ){ - pWalker->eCode = 0; - sqlite3WalkExpr(pWalker, pExpr->pRight); - } } return WRC_Prune; case TK_BETWEEN: - if( sqlite3WalkExpr(pWalker, pExpr->pLeft)==WRC_Abort ){ - assert( pWalker->eCode ); - return WRC_Abort; - } + /* In "x NOT BETWEEN y AND z" either x must be non-null-row or else + ** both y and z must be non-null row */ + assert( ExprUseXList(pExpr) ); + assert( pExpr->x.pList->nExpr==2 ); + sqlite3WalkExpr(pWalker, pExpr->pLeft); + bothImplyNotNullRow(pWalker, pExpr->x.pList->a[0].pExpr, + pExpr->x.pList->a[1].pExpr); return WRC_Prune; /* Virtual tables are allowed to use constraints like x=NULL. So @@ -112347,7 +113543,7 @@ static int impliesNotNullRow(Walker *pWalker, Expr *pExpr){ ** be non-NULL, then the LEFT JOIN can be safely converted into an ** ordinary join. */ -SQLITE_PRIVATE int sqlite3ExprImpliesNonNullRow(Expr *p, int iTab){ +SQLITE_PRIVATE int sqlite3ExprImpliesNonNullRow(Expr *p, int iTab, int isRJ){ Walker w; p = sqlite3ExprSkipCollateAndLikely(p); if( p==0 ) return 0; @@ -112355,7 +113551,7 @@ SQLITE_PRIVATE int sqlite3ExprImpliesNonNullRow(Expr *p, int iTab){ p = p->pLeft; }else{ while( p->op==TK_AND ){ - if( sqlite3ExprImpliesNonNullRow(p->pLeft, iTab) ) return 1; + if( sqlite3ExprImpliesNonNullRow(p->pLeft, iTab, isRJ) ) return 1; p = p->pRight; } } @@ -112363,6 +113559,7 @@ SQLITE_PRIVATE int sqlite3ExprImpliesNonNullRow(Expr *p, int iTab){ w.xSelectCallback = 0; w.xSelectCallback2 = 0; w.eCode = 0; + w.mWFlags = isRJ!=0; w.u.iCur = iTab; sqlite3WalkExpr(&w, p); return w.eCode; @@ -112423,7 +113620,7 @@ SQLITE_PRIVATE int sqlite3ExprCoveredByIndex( } -/* Structure used to pass information throught the Walker in order to +/* Structure used to pass information throughout the Walker in order to ** implement sqlite3ReferencesSrcList(). */ struct RefSrcList { @@ -112639,7 +113836,7 @@ static int addAggInfoFunc(sqlite3 *db, AggInfo *pInfo){ ** Return the index in aCol[] of the entry that describes that column. ** ** If no prior entry is found, create a new one and return -1. The -** new column will have an idex of pAggInfo->nColumn-1. +** new column will have an index of pAggInfo->nColumn-1. */ static void findOrCreateAggInfoColumn( Parse *pParse, /* Parsing context */ @@ -112652,6 +113849,7 @@ static void findOrCreateAggInfoColumn( assert( pAggInfo->iFirstReg==0 ); pCol = pAggInfo->aCol; for(k=0; knColumn; k++, pCol++){ + if( pCol->pCExpr==pExpr ) return; if( pCol->iTable==pExpr->iTable && pCol->iColumn==pExpr->iColumn && pExpr->op!=TK_IF_NULL_ROW @@ -113532,7 +114730,7 @@ SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){ pNew->u.tab.pDfltList = sqlite3ExprListDup(db, pTab->u.tab.pDfltList, 0); pNew->pSchema = db->aDb[iDb].pSchema; pNew->u.tab.addColOffset = pTab->u.tab.addColOffset; - pNew->nTabRef = 1; + assert( pNew->nTabRef==1 ); exit_begin_add_column: sqlite3SrcListDelete(db, pSrc); @@ -114037,7 +115235,7 @@ static RenameToken *renameColumnTokenNext(RenameCtx *pCtx){ } /* -** An error occured while parsing or otherwise processing a database +** An error occurred while parsing or otherwise processing a database ** object (either pParse->pNewTable, pNewIndex or pNewTrigger) as part of an ** ALTER TABLE RENAME COLUMN program. The error message emitted by the ** sub-routine is currently stored in pParse->zErrMsg. This function @@ -117143,14 +118341,15 @@ static int loadStatTbl( decodeIntArray((char*)sqlite3_column_text(pStmt,2),nCol,pSample->anLt,0,0); decodeIntArray((char*)sqlite3_column_text(pStmt,3),nCol,pSample->anDLt,0,0); - /* Take a copy of the sample. Add two 0x00 bytes the end of the buffer. + /* Take a copy of the sample. Add 8 extra 0x00 bytes the end of the buffer. ** This is in case the sample record is corrupted. In that case, the ** sqlite3VdbeRecordCompare() may read up to two varints past the ** end of the allocated buffer before it realizes it is dealing with - ** a corrupt record. Adding the two 0x00 bytes prevents this from causing + ** a corrupt record. Or it might try to read a large integer from the + ** buffer. In any case, eight 0x00 bytes prevents this from causing ** a buffer overread. */ pSample->n = sqlite3_column_bytes(pStmt, 4); - pSample->p = sqlite3DbMallocZero(db, pSample->n + 2); + pSample->p = sqlite3DbMallocZero(db, pSample->n + 8); if( pSample->p==0 ){ sqlite3_finalize(pStmt); return SQLITE_NOMEM_BKPT; @@ -118108,7 +119307,7 @@ SQLITE_PRIVATE int sqlite3AuthCheck( sqlite3 *db = pParse->db; int rc; - /* Don't do any authorization checks if the database is initialising + /* Don't do any authorization checks if the database is initializing ** or if the parser is being invoked from within sqlite3_declare_vtab. */ assert( !IN_RENAME_OBJECT || db->xAuth==0 ); @@ -118409,15 +119608,17 @@ SQLITE_PRIVATE void sqlite3FinishCoding(Parse *pParse){ pParse->nVtabLock = 0; #endif +#ifndef SQLITE_OMIT_SHARED_CACHE /* Once all the cookies have been verified and transactions opened, ** obtain the required table-locks. This is a no-op unless the ** shared-cache feature is enabled. */ - codeTableLocks(pParse); + if( pParse->nTableLock ) codeTableLocks(pParse); +#endif /* Initialize any AUTOINCREMENT data structures required. */ - sqlite3AutoincrementBegin(pParse); + if( pParse->pAinc ) sqlite3AutoincrementBegin(pParse); /* Code constant expressions that where factored out of inner loops. ** @@ -118930,7 +120131,7 @@ SQLITE_PRIVATE void sqlite3ColumnSetColl( } /* -** Return the collating squence name for a column +** Return the collating sequence name for a column */ SQLITE_PRIVATE const char *sqlite3ColumnColl(Column *pCol){ const char *z; @@ -119688,7 +120889,7 @@ SQLITE_PRIVATE void sqlite3AddColumn(Parse *pParse, Token sName, Token sType){ } if( !IN_RENAME_OBJECT ) sqlite3DequoteToken(&sName); - /* Because keywords GENERATE ALWAYS can be converted into indentifiers + /* Because keywords GENERATE ALWAYS can be converted into identifiers ** by the parser, we can sometimes end up with a typename that ends ** with "generated always". Check for this case and omit the surplus ** text. */ @@ -119909,7 +121110,7 @@ SQLITE_PRIVATE void sqlite3AddDefaultValue( Parse *pParse, /* Parsing context */ Expr *pExpr, /* The parsed expression of the default value */ const char *zStart, /* Start of the default value text */ - const char *zEnd /* First character past end of defaut value text */ + const char *zEnd /* First character past end of default value text */ ){ Table *p; Column *pCol; @@ -120257,7 +121458,7 @@ static int identLength(const char *z){ ** to the specified offset in the buffer and updates *pIdx to refer ** to the first byte after the last byte written before returning. ** -** If the string zSignedIdent consists entirely of alpha-numeric +** If the string zSignedIdent consists entirely of alphanumeric ** characters, does not begin with a digit and is not an SQL keyword, ** then it is copied to the output buffer exactly as it is. Otherwise, ** it is quoted using double-quotes. @@ -120409,7 +121610,7 @@ static void estimateIndexWidth(Index *pIdx){ for(i=0; inColumn; i++){ i16 x = pIdx->aiColumn[i]; assert( xpTable->nCol ); - wIndex += x<0 ? 1 : aCol[pIdx->aiColumn[i]].szEst; + wIndex += x<0 ? 1 : aCol[x].szEst; } pIdx->szIdxRow = sqlite3LogEst(wIndex*4); } @@ -122147,7 +123348,7 @@ SQLITE_PRIVATE void sqlite3CreateIndex( #ifndef SQLITE_OMIT_TEMPDB /* If the index name was unqualified, check if the table ** is a temp table. If so, set the database to 1. Do not do this - ** if initialising a database schema. + ** if initializing a database schema. */ if( !db->init.busy ){ pTab = sqlite3SrcListLookup(pParse, pTblName); @@ -123804,7 +125005,7 @@ SQLITE_PRIVATE void sqlite3CteDelete(sqlite3 *db, Cte *pCte){ /* ** This routine is invoked once per CTE by the parser while parsing a -** WITH clause. The CTE described by teh third argument is added to +** WITH clause. The CTE described by the third argument is added to ** the WITH clause of the second argument. If the second argument is ** NULL, then a new WITH argument is created. */ @@ -124446,8 +125647,9 @@ SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse *pParse, SrcList *pSrc){ Table *pTab; assert( pItem && pSrc->nSrc>=1 ); pTab = sqlite3LocateTableItem(pParse, 0, pItem); - sqlite3DeleteTable(pParse->db, pItem->pTab); + if( pItem->pTab ) sqlite3DeleteTable(pParse->db, pItem->pTab); pItem->pTab = pTab; + pItem->fg.notCte = 1; if( pTab ){ pTab->nTabRef++; if( pItem->fg.isIndexedBy && sqlite3IndexedByLookup(pParse, pItem) ){ @@ -124600,7 +125802,7 @@ SQLITE_PRIVATE Expr *sqlite3LimitWhere( sqlite3 *db = pParse->db; Expr *pLhs = NULL; /* LHS of IN(SELECT...) operator */ Expr *pInClause = NULL; /* WHERE rowid IN ( select ) */ - ExprList *pEList = NULL; /* Expression list contaning only pSelectRowid */ + ExprList *pEList = NULL; /* Expression list containing only pSelectRowid*/ SrcList *pSelectSrc = NULL; /* SELECT rowid FROM x ... (dup of pSrc) */ Select *pSelect = NULL; /* Complete SELECT tree */ Table *pTab; @@ -124638,14 +125840,20 @@ SQLITE_PRIVATE Expr *sqlite3LimitWhere( ); }else{ Index *pPk = sqlite3PrimaryKeyIndex(pTab); + assert( pPk!=0 ); + assert( pPk->nKeyCol>=1 ); if( pPk->nKeyCol==1 ){ - const char *zName = pTab->aCol[pPk->aiColumn[0]].zCnName; + const char *zName; + assert( pPk->aiColumn[0]>=0 && pPk->aiColumn[0]nCol ); + zName = pTab->aCol[pPk->aiColumn[0]].zCnName; pLhs = sqlite3Expr(db, TK_ID, zName); pEList = sqlite3ExprListAppend(pParse, 0, sqlite3Expr(db, TK_ID, zName)); }else{ int i; for(i=0; inKeyCol; i++){ - Expr *p = sqlite3Expr(db, TK_ID, pTab->aCol[pPk->aiColumn[i]].zCnName); + Expr *p; + assert( pPk->aiColumn[i]>=0 && pPk->aiColumn[i]nCol ); + p = sqlite3Expr(db, TK_ID, pTab->aCol[pPk->aiColumn[i]].zCnName); pEList = sqlite3ExprListAppend(pParse, pEList, p); } pLhs = sqlite3PExpr(pParse, TK_VECTOR, 0, 0); @@ -124674,7 +125882,7 @@ SQLITE_PRIVATE Expr *sqlite3LimitWhere( pOrderBy,0,pLimit ); - /* now generate the new WHERE rowid IN clause for the DELETE/UDPATE */ + /* now generate the new WHERE rowid IN clause for the DELETE/UPDATE */ pInClause = sqlite3PExpr(pParse, TK_IN, pLhs, 0); sqlite3PExprAddSelect(pParse, pInClause, pSelect); return pInClause; @@ -124903,7 +126111,7 @@ SQLITE_PRIVATE void sqlite3DeleteFrom( if( HasRowid(pTab) ){ /* For a rowid table, initialize the RowSet to an empty set */ pPk = 0; - nPk = 1; + assert( nPk==1 ); iRowSet = ++pParse->nMem; sqlite3VdbeAddOp2(v, OP_Null, 0, iRowSet); }else{ @@ -124931,7 +126139,8 @@ SQLITE_PRIVATE void sqlite3DeleteFrom( if( pWInfo==0 ) goto delete_from_cleanup; eOnePass = sqlite3WhereOkOnePass(pWInfo, aiCurOnePass); assert( IsVirtual(pTab)==0 || eOnePass!=ONEPASS_MULTI ); - assert( IsVirtual(pTab) || bComplex || eOnePass!=ONEPASS_OFF ); + assert( IsVirtual(pTab) || bComplex || eOnePass!=ONEPASS_OFF + || OptimizationDisabled(db, SQLITE_OnePass) ); if( eOnePass!=ONEPASS_SINGLE ) sqlite3MultiWrite(pParse); if( sqlite3WhereUsesDeferredSeek(pWInfo) ){ sqlite3VdbeAddOp1(v, OP_FinishSeek, iTabCur); @@ -125268,9 +126477,11 @@ SQLITE_PRIVATE void sqlite3GenerateRowDelete( sqlite3FkActions(pParse, pTab, 0, iOld, 0, 0); /* Invoke AFTER DELETE trigger programs. */ - sqlite3CodeRowTrigger(pParse, pTrigger, - TK_DELETE, 0, TRIGGER_AFTER, pTab, iOld, onconf, iLabel - ); + if( pTrigger ){ + sqlite3CodeRowTrigger(pParse, pTrigger, + TK_DELETE, 0, TRIGGER_AFTER, pTab, iOld, onconf, iLabel + ); + } /* Jump here if the row had already been deleted before any BEFORE ** trigger programs were invoked. Or if a trigger program throws a @@ -125583,6 +126794,42 @@ static void lengthFunc( } } +/* +** Implementation of the octet_length() function +*/ +static void bytelengthFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + assert( argc==1 ); + UNUSED_PARAMETER(argc); + switch( sqlite3_value_type(argv[0]) ){ + case SQLITE_BLOB: { + sqlite3_result_int(context, sqlite3_value_bytes(argv[0])); + break; + } + case SQLITE_INTEGER: + case SQLITE_FLOAT: { + i64 m = sqlite3_context_db_handle(context)->enc<=SQLITE_UTF8 ? 1 : 2; + sqlite3_result_int64(context, sqlite3_value_bytes(argv[0])*m); + break; + } + case SQLITE_TEXT: { + if( sqlite3_value_encoding(argv[0])<=SQLITE_UTF8 ){ + sqlite3_result_int(context, sqlite3_value_bytes(argv[0])); + }else{ + sqlite3_result_int(context, sqlite3_value_bytes16(argv[0])); + } + break; + } + default: { + sqlite3_result_null(context); + break; + } + } +} + /* ** Implementation of the abs() function. ** @@ -125859,7 +127106,7 @@ static void roundFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ }else if( n==0 ){ r = (double)((sqlite_int64)(r+(r<0?-0.5:+0.5))); }else{ - zBuf = sqlite3_mprintf("%.*f",n,r); + zBuf = sqlite3_mprintf("%!.*f",n,r); if( zBuf==0 ){ sqlite3_result_error_nomem(context); return; @@ -126059,7 +127306,7 @@ struct compareInfo { /* ** For LIKE and GLOB matching on EBCDIC machines, assume that every -** character is exactly one byte in size. Also, provde the Utf8Read() +** character is exactly one byte in size. Also, provide the Utf8Read() ** macro for fast reading of the next character in the common case where ** the next character is ASCII. */ @@ -126292,7 +127539,7 @@ SQLITE_API int sqlite3_like_count = 0; /* ** Implementation of the like() SQL function. This function implements -** the build-in LIKE operator. The first argument to the function is the +** the built-in LIKE operator. The first argument to the function is the ** pattern and the second argument is the string. So, the SQL statements: ** ** A LIKE B @@ -126625,6 +127872,7 @@ static void charFunc( *zOut++ = 0x80 + (u8)(c & 0x3F); } \ } + *zOut = 0; sqlite3_result_text64(context, (char*)z, zOut-z, sqlite3_free, SQLITE_UTF8); } @@ -126678,7 +127926,7 @@ static int strContainsChar(const u8 *zStr, int nStr, u32 ch){ ** decoded and returned as a blob. ** ** If there is only a single argument, then it must consist only of an -** even number of hexadeximal digits. Otherwise, return NULL. +** even number of hexadecimal digits. Otherwise, return NULL. ** ** Or, if there is a second argument, then any character that appears in ** the second argument is also allowed to appear between pairs of hexadecimal @@ -127068,13 +128316,68 @@ static void loadExt(sqlite3_context *context, int argc, sqlite3_value **argv){ */ typedef struct SumCtx SumCtx; struct SumCtx { - double rSum; /* Floating point sum */ - i64 iSum; /* Integer sum */ + double rSum; /* Running sum as as a double */ + double rErr; /* Error term for Kahan-Babushka-Neumaier summation */ + i64 iSum; /* Running sum as a signed integer */ i64 cnt; /* Number of elements summed */ - u8 overflow; /* True if integer overflow seen */ - u8 approx; /* True if non-integer value was input to the sum */ + u8 approx; /* True if any non-integer value was input to the sum */ + u8 ovrfl; /* Integer overflow seen */ }; +/* +** Do one step of the Kahan-Babushka-Neumaier summation. +** +** https://en.wikipedia.org/wiki/Kahan_summation_algorithm +** +** Variables are marked "volatile" to defeat c89 x86 floating point +** optimizations can mess up this algorithm. +*/ +static void kahanBabuskaNeumaierStep( + volatile SumCtx *pSum, + volatile double r +){ + volatile double s = pSum->rSum; + volatile double t = s + r; + if( fabs(s) > fabs(r) ){ + pSum->rErr += (s - t) + r; + }else{ + pSum->rErr += (r - t) + s; + } + pSum->rSum = t; +} + +/* +** Add a (possibly large) integer to the running sum. +*/ +static void kahanBabuskaNeumaierStepInt64(volatile SumCtx *pSum, i64 iVal){ + if( iVal<=-4503599627370496LL || iVal>=+4503599627370496LL ){ + i64 iBig, iSm; + iSm = iVal % 16384; + iBig = iVal - iSm; + kahanBabuskaNeumaierStep(pSum, iBig); + kahanBabuskaNeumaierStep(pSum, iSm); + }else{ + kahanBabuskaNeumaierStep(pSum, (double)iVal); + } +} + +/* +** Initialize the Kahan-Babaska-Neumaier sum from a 64-bit integer +*/ +static void kahanBabuskaNeumaierInit( + volatile SumCtx *p, + i64 iVal +){ + if( iVal<=-4503599627370496LL || iVal>=+4503599627370496LL ){ + i64 iSm = iVal % 16384; + p->rSum = (double)(iVal - iSm); + p->rErr = (double)iSm; + }else{ + p->rSum = (double)iVal; + p->rErr = 0.0; + } +} + /* ** Routines used to compute the sum, average, and total. ** @@ -127094,15 +128397,29 @@ static void sumStep(sqlite3_context *context, int argc, sqlite3_value **argv){ type = sqlite3_value_numeric_type(argv[0]); if( p && type!=SQLITE_NULL ){ p->cnt++; - if( type==SQLITE_INTEGER ){ - i64 v = sqlite3_value_int64(argv[0]); - p->rSum += v; - if( (p->approx|p->overflow)==0 && sqlite3AddInt64(&p->iSum, v) ){ - p->approx = p->overflow = 1; + if( p->approx==0 ){ + if( type!=SQLITE_INTEGER ){ + kahanBabuskaNeumaierInit(p, p->iSum); + p->approx = 1; + kahanBabuskaNeumaierStep(p, sqlite3_value_double(argv[0])); + }else{ + i64 x = p->iSum; + if( sqlite3AddInt64(&x, sqlite3_value_int64(argv[0]))==0 ){ + p->iSum = x; + }else{ + p->ovrfl = 1; + kahanBabuskaNeumaierInit(p, p->iSum); + p->approx = 1; + kahanBabuskaNeumaierStepInt64(p, sqlite3_value_int64(argv[0])); + } } }else{ - p->rSum += sqlite3_value_double(argv[0]); - p->approx = 1; + if( type==SQLITE_INTEGER ){ + kahanBabuskaNeumaierStepInt64(p, sqlite3_value_int64(argv[0])); + }else{ + p->ovrfl = 0; + kahanBabuskaNeumaierStep(p, sqlite3_value_double(argv[0])); + } } } } @@ -127119,13 +128436,18 @@ static void sumInverse(sqlite3_context *context, int argc, sqlite3_value**argv){ if( ALWAYS(p) && type!=SQLITE_NULL ){ assert( p->cnt>0 ); p->cnt--; - assert( type==SQLITE_INTEGER || p->approx ); - if( type==SQLITE_INTEGER && p->approx==0 ){ - i64 v = sqlite3_value_int64(argv[0]); - p->rSum -= v; - p->iSum -= v; + if( !p->approx ){ + p->iSum -= sqlite3_value_int64(argv[0]); + }else if( type==SQLITE_INTEGER ){ + i64 iVal = sqlite3_value_int64(argv[0]); + if( iVal!=SMALLEST_INT64 ){ + kahanBabuskaNeumaierStepInt64(p, -iVal); + }else{ + kahanBabuskaNeumaierStepInt64(p, LARGEST_INT64); + kahanBabuskaNeumaierStepInt64(p, 1); + } }else{ - p->rSum -= sqlite3_value_double(argv[0]); + kahanBabuskaNeumaierStep(p, -sqlite3_value_double(argv[0])); } } } @@ -127136,10 +128458,12 @@ static void sumFinalize(sqlite3_context *context){ SumCtx *p; p = sqlite3_aggregate_context(context, 0); if( p && p->cnt>0 ){ - if( p->overflow ){ - sqlite3_result_error(context,"integer overflow",-1); - }else if( p->approx ){ - sqlite3_result_double(context, p->rSum); + if( p->approx ){ + if( p->ovrfl ){ + sqlite3_result_error(context,"integer overflow",-1); + }else{ + sqlite3_result_double(context, p->rSum+p->rErr); + } }else{ sqlite3_result_int64(context, p->iSum); } @@ -127149,14 +128473,27 @@ static void avgFinalize(sqlite3_context *context){ SumCtx *p; p = sqlite3_aggregate_context(context, 0); if( p && p->cnt>0 ){ - sqlite3_result_double(context, p->rSum/(double)p->cnt); + double r; + if( p->approx ){ + r = p->rSum+p->rErr; + }else{ + r = (double)(p->iSum); + } + sqlite3_result_double(context, r/(double)p->cnt); } } static void totalFinalize(sqlite3_context *context){ SumCtx *p; + double r = 0.0; p = sqlite3_aggregate_context(context, 0); - /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ - sqlite3_result_double(context, p ? p->rSum : (double)0); + if( p ){ + if( p->approx ){ + r = p->rSum+p->rErr; + }else{ + r = (double)(p->iSum); + } + } + sqlite3_result_double(context, r); } /* @@ -127378,7 +128715,7 @@ static void groupConcatInverse( if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return; pGCC = (GroupConcatCtx*)sqlite3_aggregate_context(context, sizeof(*pGCC)); /* pGCC is always non-NULL since groupConcatStep() will have always - ** run frist to initialize it */ + ** run first to initialize it */ if( ALWAYS(pGCC) ){ int nVS; /* Must call sqlite3_value_text() to convert the argument into text prior @@ -127462,8 +128799,10 @@ SQLITE_PRIVATE void sqlite3RegisterPerConnectionBuiltinFunctions(sqlite3 *db){ ** sensitive. */ SQLITE_PRIVATE void sqlite3RegisterLikeFunctions(sqlite3 *db, int caseSensitive){ + FuncDef *pDef; struct compareInfo *pInfo; int flags; + int nArg; if( caseSensitive ){ pInfo = (struct compareInfo*)&likeInfoAlt; flags = SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE; @@ -127471,10 +128810,13 @@ SQLITE_PRIVATE void sqlite3RegisterLikeFunctions(sqlite3 *db, int caseSensitive) pInfo = (struct compareInfo*)&likeInfoNorm; flags = SQLITE_FUNC_LIKE; } - sqlite3CreateFunc(db, "like", 2, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0, 0, 0); - sqlite3CreateFunc(db, "like", 3, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0, 0, 0); - sqlite3FindFunction(db, "like", 2, SQLITE_UTF8, 0)->funcFlags |= flags; - sqlite3FindFunction(db, "like", 3, SQLITE_UTF8, 0)->funcFlags |= flags; + for(nArg=2; nArg<=3; nArg++){ + sqlite3CreateFunc(db, "like", nArg, SQLITE_UTF8, pInfo, likeFunc, + 0, 0, 0, 0, 0); + pDef = sqlite3FindFunction(db, "like", nArg, SQLITE_UTF8, 0); + pDef->funcFlags |= flags; + pDef->funcFlags &= ~SQLITE_FUNC_UNSAFE; + } } /* @@ -127746,6 +129088,37 @@ static void signFunc( sqlite3_result_int(context, x<0.0 ? -1 : x>0.0 ? +1 : 0); } +#ifdef SQLITE_DEBUG +/* +** Implementation of fpdecode(x,y,z) function. +** +** x is a real number that is to be decoded. y is the precision. +** z is the maximum real precision. +*/ +static void fpdecodeFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + FpDecode s; + double x; + int y, z; + char zBuf[100]; + UNUSED_PARAMETER(argc); + assert( argc==3 ); + x = sqlite3_value_double(argv[0]); + y = sqlite3_value_int(argv[1]); + z = sqlite3_value_int(argv[2]); + sqlite3FpDecode(&s, x, y, z); + if( s.isSpecial==2 ){ + sqlite3_snprintf(sizeof(zBuf), zBuf, "NaN"); + }else{ + sqlite3_snprintf(sizeof(zBuf), zBuf, "%c%.*s/%d", s.sign, s.n, s.z, s.iDP); + } + sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT); +} +#endif /* SQLITE_DEBUG */ + /* ** All of the FuncDef structures in the aBuiltinFunc[] array above ** to the global function hash table. This occurs at start-time (as @@ -127810,12 +129183,16 @@ SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void){ FUNCTION2(typeof, 1, 0, 0, typeofFunc, SQLITE_FUNC_TYPEOF), FUNCTION2(subtype, 1, 0, 0, subtypeFunc, SQLITE_FUNC_TYPEOF), FUNCTION2(length, 1, 0, 0, lengthFunc, SQLITE_FUNC_LENGTH), + FUNCTION2(octet_length, 1, 0, 0, bytelengthFunc,SQLITE_FUNC_BYTELEN), FUNCTION(instr, 2, 0, 0, instrFunc ), FUNCTION(printf, -1, 0, 0, printfFunc ), FUNCTION(format, -1, 0, 0, printfFunc ), FUNCTION(unicode, 1, 0, 0, unicodeFunc ), FUNCTION(char, -1, 0, 0, charFunc ), FUNCTION(abs, 1, 0, 0, absFunc ), +#ifdef SQLITE_DEBUG + FUNCTION(fpdecode, 3, 0, 0, fpdecodeFunc ), +#endif #ifndef SQLITE_OMIT_FLOATING_POINT FUNCTION(round, 1, 0, 0, roundFunc ), FUNCTION(round, 2, 0, 0, roundFunc ), @@ -129386,9 +130763,8 @@ SQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *db, Table *pTab){ if( pFKey->pPrevTo ){ pFKey->pPrevTo->pNextTo = pFKey->pNextTo; }else{ - void *p = (void *)pFKey->pNextTo; - const char *z = (p ? pFKey->pNextTo->zTo : pFKey->zTo); - sqlite3HashInsert(&pTab->pSchema->fkeyHash, z, p); + const char *z = (pFKey->pNextTo ? pFKey->pNextTo->zTo : pFKey->zTo); + sqlite3HashInsert(&pTab->pSchema->fkeyHash, z, pFKey->pNextTo); } if( pFKey->pNextTo ){ pFKey->pNextTo->pPrevTo = pFKey->pPrevTo; @@ -129451,8 +130827,10 @@ SQLITE_PRIVATE void sqlite3OpenTable( assert( pParse->pVdbe!=0 ); v = pParse->pVdbe; assert( opcode==OP_OpenWrite || opcode==OP_OpenRead ); - sqlite3TableLock(pParse, iDb, pTab->tnum, - (opcode==OP_OpenWrite)?1:0, pTab->zName); + if( !pParse->db->noSharedCache ){ + sqlite3TableLock(pParse, iDb, pTab->tnum, + (opcode==OP_OpenWrite)?1:0, pTab->zName); + } if( HasRowid(pTab) ){ sqlite3VdbeAddOp4Int(v, opcode, iCur, pTab->tnum, iDb, pTab->nNVCol); VdbeComment((v, "%s", pTab->zName)); @@ -129581,7 +130959,7 @@ SQLITE_PRIVATE char *sqlite3TableAffinityStr(sqlite3 *db, const Table *pTab){ ** For STRICT tables: ** ------------------ ** -** Generate an appropropriate OP_TypeCheck opcode that will verify the +** Generate an appropriate OP_TypeCheck opcode that will verify the ** datatypes against the column definitions in pTab. If iReg==0, that ** means an OP_MakeRecord opcode has already been generated and should be ** the last opcode generated. The new OP_TypeCheck needs to be inserted @@ -130873,7 +132251,7 @@ insert_cleanup: /* This is the Walker callback from sqlite3ExprReferencesUpdatedColumn(). * Set bit 0x01 of pWalker->eCode if pWalker->eCode to 0 and if this ** expression node references any of the -** columns that are being modifed by an UPDATE statement. +** columns that are being modified by an UPDATE statement. */ static int checkConstraintExprNode(Walker *pWalker, Expr *pExpr){ if( pExpr->op==TK_COLUMN ){ @@ -131096,7 +132474,7 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( int *aiChng, /* column i is unchanged if aiChng[i]<0 */ Upsert *pUpsert /* ON CONFLICT clauses, if any. NULL otherwise */ ){ - Vdbe *v; /* VDBE under constrution */ + Vdbe *v; /* VDBE under construction */ Index *pIdx; /* Pointer to one of the indices */ Index *pPk = 0; /* The PRIMARY KEY index for WITHOUT ROWID tables */ sqlite3 *db; /* Database connection */ @@ -131579,7 +132957,7 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( pIdx; pIdx = indexIteratorNext(&sIdxIter, &ix) ){ - int regIdx; /* Range of registers hold conent for pIdx */ + int regIdx; /* Range of registers holding content for pIdx */ int regR; /* Range of registers holding conflicting PK */ int iThisCur; /* Cursor for this UNIQUE index */ int addrUniqueOk; /* Jump here if the UNIQUE constraint is satisfied */ @@ -132074,6 +133452,8 @@ SQLITE_PRIVATE int sqlite3OpenTableAndIndices( assert( op==OP_OpenRead || op==OP_OpenWrite ); assert( op==OP_OpenWrite || p5==0 ); + assert( piDataCur!=0 ); + assert( piIdxCur!=0 ); if( IsVirtual(pTab) ){ /* This routine is a no-op for virtual tables. Leave the output ** variables *piDataCur and *piIdxCur set to illegal cursor numbers @@ -132086,18 +133466,18 @@ SQLITE_PRIVATE int sqlite3OpenTableAndIndices( assert( v!=0 ); if( iBase<0 ) iBase = pParse->nTab; iDataCur = iBase++; - if( piDataCur ) *piDataCur = iDataCur; + *piDataCur = iDataCur; if( HasRowid(pTab) && (aToOpen==0 || aToOpen[0]) ){ sqlite3OpenTable(pParse, iDataCur, iDb, pTab, op); - }else{ + }else if( pParse->db->noSharedCache==0 ){ sqlite3TableLock(pParse, iDb, pTab->tnum, op==OP_OpenWrite, pTab->zName); } - if( piIdxCur ) *piIdxCur = iBase; + *piIdxCur = iBase; for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){ int iIdxCur = iBase++; assert( pIdx->pSchema==pTab->pSchema ); if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){ - if( piDataCur ) *piDataCur = iIdxCur; + *piDataCur = iIdxCur; p5 = 0; } if( aToOpen==0 || aToOpen[i+1] ){ @@ -132395,7 +133775,7 @@ static int xferOptimization( } #endif #ifndef SQLITE_OMIT_FOREIGN_KEY - /* Disallow the transfer optimization if the destination table constains + /* Disallow the transfer optimization if the destination table contains ** any foreign key constraints. This is more restrictive than necessary. ** But the main beneficiary of the transfer optimization is the VACUUM ** command, and the VACUUM command disables foreign key constraints. So @@ -133105,6 +134485,8 @@ struct sqlite3_api_routines { int (*value_encoding)(sqlite3_value*); /* Version 3.41.0 and later */ int (*is_interrupted)(sqlite3*); + /* Version 3.43.0 and later */ + int (*stmt_explain)(sqlite3_stmt*,int); }; /* @@ -133433,6 +134815,8 @@ typedef int (*sqlite3_loadext_entry)( #define sqlite3_value_encoding sqlite3_api->value_encoding /* Version 3.41.0 and later */ #define sqlite3_is_interrupted sqlite3_api->is_interrupted +/* Version 3.43.0 and later */ +#define sqlite3_stmt_explain sqlite3_api->stmt_explain #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) @@ -133949,7 +135333,9 @@ static const sqlite3_api_routines sqlite3Apis = { /* Version 3.40.0 and later */ sqlite3_value_encoding, /* Version 3.41.0 and later */ - sqlite3_is_interrupted + sqlite3_is_interrupted, + /* Version 3.43.0 and later */ + sqlite3_stmt_explain }; /* True if x is the directory separator character @@ -134029,6 +135415,10 @@ static int sqlite3LoadExtension( */ if( nMsg>SQLITE_MAX_PATHLEN ) goto extension_not_found; + /* Do not allow sqlite3_load_extension() to link to a copy of the + ** running application, by passing in an empty filename. */ + if( nMsg==0 ) goto extension_not_found; + handle = sqlite3OsDlOpen(pVfs, zFile); #if SQLITE_OS_UNIX || SQLITE_OS_WIN for(ii=0; iipParse; db->pParse = &sParse; sParse.db = db; - sParse.pReprepare = pReprepare; + if( pReprepare ){ + sParse.pReprepare = pReprepare; + sParse.explain = sqlite3_stmt_isexplain((sqlite3_stmt*)pReprepare); + }else{ + assert( sParse.pReprepare==0 ); + } assert( ppStmt && *ppStmt==0 ); if( db->mallocFailed ){ sqlite3ErrorMsg(&sParse, "out of memory"); @@ -139227,7 +140622,7 @@ static Select *findRightmost(Select *p){ ** NATURAL FULL OUTER JT_NATRUAL|JT_LEFT|JT_RIGHT ** ** To preserve historical compatibly, SQLite also accepts a variety -** of other non-standard and in many cases non-sensical join types. +** of other non-standard and in many cases nonsensical join types. ** This routine makes as much sense at it can from the nonsense join ** type and returns a result. Examples of accepted nonsense join types ** include but are not limited to: @@ -139498,7 +140893,7 @@ static int sqlite3ProcessJoin(Parse *pParse, Select *p){ if( NEVER(pLeft->pTab==0 || pRightTab==0) ) continue; joinType = (pRight->fg.jointype & JT_OUTER)!=0 ? EP_OuterON : EP_InnerON; - /* If this is a NATURAL join, synthesize an approprate USING clause + /* If this is a NATURAL join, synthesize an appropriate USING clause ** to specify which columns should be joined. */ if( pRight->fg.jointype & JT_NATURAL ){ @@ -139714,7 +141109,7 @@ static void pushOntoSorter( ** (3) Some output columns are omitted from the sort record due to ** the SQLITE_ENABLE_SORTER_REFERENCES optimization, or due to the ** SQLITE_ECEL_OMITREF optimization, or due to the - ** SortCtx.pDeferredRowLoad optimiation. In any of these cases + ** SortCtx.pDeferredRowLoad optimization. In any of these cases ** regOrigData is 0 to prevent this routine from trying to copy ** values that might not yet exist. */ @@ -139770,7 +141165,7 @@ static void pushOntoSorter( testcase( pKI->nAllField > pKI->nKeyField+2 ); pOp->p4.pKeyInfo = sqlite3KeyInfoFromExprList(pParse,pSort->pOrderBy,nOBSat, pKI->nAllField-pKI->nKeyField-1); - pOp = 0; /* Ensure pOp not used after sqltie3VdbeAddOp3() */ + pOp = 0; /* Ensure pOp not used after sqlite3VdbeAddOp3() */ addrJmp = sqlite3VdbeCurrentAddr(v); sqlite3VdbeAddOp3(v, OP_Jump, addrJmp+1, 0, addrJmp+1); VdbeCoverage(v); pSort->labelBkOut = sqlite3VdbeMakeLabel(pParse); @@ -139864,7 +141259,7 @@ static void codeOffset( ** The returned value in this case is a copy of parameter iTab. ** ** WHERE_DISTINCT_ORDERED: -** In this case rows are being delivered sorted order. The ephermal +** In this case rows are being delivered sorted order. The ephemeral ** table is not required. Instead, the current set of values ** is compared against previous row. If they match, the new row ** is not distinct and control jumps to VM address addrRepeat. Otherwise, @@ -140293,6 +141688,16 @@ static void selectInnerLoop( testcase( eDest==SRT_Fifo ); testcase( eDest==SRT_DistFifo ); sqlite3VdbeAddOp3(v, OP_MakeRecord, regResult, nResultCol, r1+nPrefixReg); +#if !defined(SQLITE_ENABLE_NULL_TRIM) && defined(SQLITE_DEBUG) + /* A destination of SRT_Table and a non-zero iSDParm2 parameter means + ** that this is an "UPDATE ... FROM" on a virtual table or view. In this + ** case set the p5 parameter of the OP_MakeRecord to OPFLAG_NOCHNG_MAGIC. + ** This does not affect operation in any way - it just allows MakeRecord + ** to process OPFLAG_NOCHANGE values without an assert() failing. */ + if( eDest==SRT_Table && pDest->iSDParm2 ){ + sqlite3VdbeChangeP5(v, OPFLAG_NOCHNG_MAGIC); + } +#endif #ifndef SQLITE_OMIT_CTE if( eDest==SRT_DistFifo ){ /* If the destination is DistFifo, then cursor (iParm+1) is open @@ -141096,13 +142501,6 @@ SQLITE_PRIVATE void sqlite3GenerateColumnNames( int fullName; /* TABLE.COLUMN if no AS clause and is a direct table ref */ int srcName; /* COLUMN or TABLE.COLUMN if no AS clause and is direct */ -#ifndef SQLITE_OMIT_EXPLAIN - /* If this is an EXPLAIN, skip this step */ - if( pParse->explain ){ - return; - } -#endif - if( pParse->colNamesSet ) return; /* Column names are determined by the left-most term of a compound select */ while( pSelect->pPrior ) pSelect = pSelect->pPrior; @@ -141289,7 +142687,7 @@ SQLITE_PRIVATE int sqlite3ColumnsFromExprList( ** kind (maybe a parenthesized subquery in the FROM clause of a larger ** query, or a VIEW, or a CTE). This routine computes type information ** for that Table object based on the Select object that implements the -** subquery. For the purposes of this routine, "type infomation" means: +** subquery. For the purposes of this routine, "type information" means: ** ** * The datatype name, as it might appear in a CREATE TABLE statement ** * Which collating sequence to use for the column @@ -141618,7 +143016,7 @@ static void generateWithRecursiveQuery( int iQueue; /* The Queue table */ int iDistinct = 0; /* To ensure unique results if UNION */ int eDest = SRT_Fifo; /* How to write to Queue */ - SelectDest destQueue; /* SelectDest targetting the Queue table */ + SelectDest destQueue; /* SelectDest targeting the Queue table */ int i; /* Loop counter */ int rc; /* Result code */ ExprList *pOrderBy; /* The ORDER BY clause */ @@ -142218,7 +143616,7 @@ SQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p){ /* ** Code an output subroutine for a coroutine implementation of a -** SELECT statment. +** SELECT statement. ** ** The data to be output is contained in pIn->iSdst. There are ** pIn->nSdst columns to be output. pDest is where the output should @@ -142440,7 +143838,7 @@ static int generateOutputSubroutine( ** ** We call AltB, AeqB, AgtB, EofA, and EofB "subroutines" but they are not ** actually called using Gosub and they do not Return. EofA and EofB loop -** until all data is exhausted then jump to the "end" labe. AltB, AeqB, +** until all data is exhausted then jump to the "end" label. AltB, AeqB, ** and AgtB jump to either L2 or to one of EofA or EofB. */ #ifndef SQLITE_OMIT_COMPOUND_SELECT @@ -142477,7 +143875,7 @@ static int multiSelectOrderBy( int savedOffset; /* Saved value of p->iOffset */ int labelCmpr; /* Label for the start of the merge algorithm */ int labelEnd; /* Label for the end of the overall SELECT stmt */ - int addr1; /* Jump instructions that get retargetted */ + int addr1; /* Jump instructions that get retargeted */ int op; /* One of TK_ALL, TK_UNION, TK_EXCEPT, TK_INTERSECT */ KeyInfo *pKeyDup = 0; /* Comparison information for duplicate removal */ KeyInfo *pKeyMerge; /* Comparison information for merging rows */ @@ -142846,11 +144244,14 @@ static Expr *substExpr( #endif { Expr *pNew; - int iColumn = pExpr->iColumn; - Expr *pCopy = pSubst->pEList->a[iColumn].pExpr; + int iColumn; + Expr *pCopy; Expr ifNullRow; + iColumn = pExpr->iColumn; + assert( iColumn>=0 ); assert( pSubst->pEList!=0 && iColumnpEList->nExpr ); assert( pExpr->pRight==0 ); + pCopy = pSubst->pEList->a[iColumn].pExpr; if( sqlite3ExprIsVector(pCopy) ){ sqlite3VectorErrorMsg(pSubst->pParse, pCopy); }else{ @@ -143199,7 +144600,7 @@ static int compoundHasDifferentAffinities(Select *p){ ** (9) If the subquery uses LIMIT then the outer query may not be aggregate. ** ** (**) Restriction (10) was removed from the code on 2005-02-05 but we -** accidently carried the comment forward until 2014-09-15. Original +** accidentally carried the comment forward until 2014-09-15. Original ** constraint: "If the subquery is aggregate then the outer query ** may not use LIMIT." ** @@ -143291,7 +144692,8 @@ static int compoundHasDifferentAffinities(Select *p){ ** (27b) the subquery is a compound query and the RIGHT JOIN occurs ** in any arm of the compound query. (See also (17g).) ** -** (28) The subquery is not a MATERIALIZED CTE. +** (28) The subquery is not a MATERIALIZED CTE. (This is handled +** in the caller before ever reaching this routine.) ** ** ** In this routine, the "p" parameter is a pointer to the outer query. @@ -143401,9 +144803,9 @@ static int flattenSubquery( if( iFrom>0 && (pSubSrc->a[0].fg.jointype & JT_LTORJ)!=0 ){ return 0; /* Restriction (27a) */ } - if( pSubitem->fg.isCte && pSubitem->u2.pCteUse->eM10d==M10d_Yes ){ - return 0; /* (28) */ - } + + /* Condition (28) is blocked by the caller */ + assert( !pSubitem->fg.isCte || pSubitem->u2.pCteUse->eM10d!=M10d_Yes ); /* Restriction (17): If the sub-query is a compound SELECT, then it must ** use only the UNION ALL operator. And none of the simple select queries @@ -143473,7 +144875,7 @@ static int flattenSubquery( testcase( i==SQLITE_DENY ); pParse->zAuthContext = zSavedAuthContext; - /* Delete the transient structures associated with thesubquery */ + /* Delete the transient structures associated with the subquery */ pSub1 = pSubitem->pSelect; sqlite3DbFree(db, pSubitem->zDatabase); sqlite3DbFree(db, pSubitem->zName); @@ -143655,7 +145057,7 @@ static int flattenSubquery( ** ORDER BY column expression is identical to the iOrderByCol'th ** expression returned by SELECT statement pSub. Since these values ** do not necessarily correspond to columns in SELECT statement pParent, - ** zero them before transfering the ORDER BY clause. + ** zero them before transferring the ORDER BY clause. ** ** Not doing this may cause an error if a subsequent call to this ** function attempts to flatten a compound sub-query into pParent @@ -143715,8 +145117,7 @@ static int flattenSubquery( } } - /* Finially, delete what is left of the subquery and return - ** success. + /* Finally, delete what is left of the subquery and return success. */ sqlite3AggInfoPersistWalkerInit(&w, pParse); sqlite3WalkSelect(&w,pSub1); @@ -143751,7 +145152,7 @@ struct WhereConst { /* ** Add a new entry to the pConst object. Except, do not add duplicate -** pColumn entires. Also, do not add if doing so would not be appropriate. +** pColumn entries. Also, do not add if doing so would not be appropriate. ** ** The caller guarantees the pColumn is a column and pValue is a constant. ** This routine has to do some additional checks before completing the @@ -143937,7 +145338,7 @@ static int propagateConstantExprRewrite(Walker *pWalker, Expr *pExpr){ ** SELECT * FROM t1 WHERE a=123 AND b=123; ** ** The two SELECT statements above should return different answers. b=a -** is alway true because the comparison uses numeric affinity, but b=123 +** is always true because the comparison uses numeric affinity, but b=123 ** is false because it uses text affinity and '0123' is not the same as '123'. ** To work around this, the expression tree is not actually changed from ** "b=a" to "b=123" but rather the "a" in "b=a" is tagged with EP_FixedCol @@ -144021,7 +145422,7 @@ static int propagateConstants( ** At the time this function is called it is guaranteed that ** ** * the sub-query uses only one distinct window frame, and -** * that the window frame has a PARTITION BY clase. +** * that the window frame has a PARTITION BY clause. */ static int pushDownWindowCheck(Parse *pParse, Select *pSubq, Expr *pExpr){ assert( pSubq->pWin->pPartition ); @@ -145101,10 +146502,16 @@ static int selectExpander(Walker *pWalker, Select *p){ ** expanded. */ int tableSeen = 0; /* Set to 1 when TABLE matches */ char *zTName = 0; /* text of name of TABLE */ + int iErrOfst; if( pE->op==TK_DOT ){ assert( pE->pLeft!=0 ); assert( !ExprHasProperty(pE->pLeft, EP_IntValue) ); zTName = pE->pLeft->u.zToken; + assert( ExprUseWOfst(pE->pLeft) ); + iErrOfst = pE->pRight->w.iOfst; + }else{ + assert( ExprUseWOfst(pE) ); + iErrOfst = pE->w.iOfst; } for(i=0, pFrom=pTabList->a; inSrc; i++, pFrom++){ Table *pTab = pFrom->pTab; /* Table for this data source */ @@ -145141,6 +146548,7 @@ static int selectExpander(Walker *pWalker, Select *p){ for(ii=0; iinId; ii++){ const char *zUName = pUsing->a[ii].zName; pRight = sqlite3Expr(db, TK_ID, zUName); + sqlite3ExprSetErrorOffset(pRight, iErrOfst); pNew = sqlite3ExprListAppend(pParse, pNew, pRight); if( pNew ){ struct ExprList_item *pX = &pNew->a[pNew->nExpr-1]; @@ -145213,6 +146621,7 @@ static int selectExpander(Walker *pWalker, Select *p){ }else{ pExpr = pRight; } + sqlite3ExprSetErrorOffset(pExpr, iErrOfst); pNew = sqlite3ExprListAppend(pParse, pNew, pExpr); if( pNew==0 ){ break; /* OOM */ @@ -145529,7 +146938,7 @@ static int aggregateIdxEprRefToColCallback(Walker *pWalker, Expr *pExpr){ pExpr->op = TK_AGG_COLUMN; pExpr->iTable = pCol->iTable; pExpr->iColumn = pCol->iColumn; - ExprClearProperty(pExpr, EP_Skip|EP_Collate); + ExprClearProperty(pExpr, EP_Skip|EP_Collate|EP_Unlikely); return WRC_Prune; } @@ -145560,7 +146969,7 @@ static void aggregateConvertIndexedExprRefToColumn(AggInfo *pAggInfo){ ** * The aCol[] and aFunc[] arrays may be modified ** * The AggInfoColumnReg() and AggInfoFuncReg() macros may not be used ** -** After clling this routine: +** After calling this routine: ** ** * The aCol[] and aFunc[] arrays are fixed ** * The AggInfoColumnReg() and AggInfoFuncReg() macros may be used @@ -146214,22 +147623,59 @@ SQLITE_PRIVATE int sqlite3Select( ** to a real table */ assert( pTab!=0 ); - /* Convert LEFT JOIN into JOIN if there are terms of the right table - ** of the LEFT JOIN used in the WHERE clause. + /* Try to simplify joins: + ** + ** LEFT JOIN -> JOIN + ** RIGHT JOIN -> JOIN + ** FULL JOIN -> RIGHT JOIN + ** + ** If terms of the i-th table are used in the WHERE clause in such a + ** way that the i-th table cannot be the NULL row of a join, then + ** perform the appropriate simplification. This is called + ** "OUTER JOIN strength reduction" in the SQLite documentation. */ - if( (pItem->fg.jointype & (JT_LEFT|JT_RIGHT))==JT_LEFT - && sqlite3ExprImpliesNonNullRow(p->pWhere, pItem->iCursor) + if( (pItem->fg.jointype & (JT_LEFT|JT_LTORJ))!=0 + && sqlite3ExprImpliesNonNullRow(p->pWhere, pItem->iCursor, + pItem->fg.jointype & JT_LTORJ) && OptimizationEnabled(db, SQLITE_SimplifyJoin) ){ - TREETRACE(0x1000,pParse,p, - ("LEFT-JOIN simplifies to JOIN on term %d\n",i)); - pItem->fg.jointype &= ~(JT_LEFT|JT_OUTER); + if( pItem->fg.jointype & JT_LEFT ){ + if( pItem->fg.jointype & JT_RIGHT ){ + TREETRACE(0x1000,pParse,p, + ("FULL-JOIN simplifies to RIGHT-JOIN on term %d\n",i)); + pItem->fg.jointype &= ~JT_LEFT; + }else{ + TREETRACE(0x1000,pParse,p, + ("LEFT-JOIN simplifies to JOIN on term %d\n",i)); + pItem->fg.jointype &= ~(JT_LEFT|JT_OUTER); + } + } + if( pItem->fg.jointype & JT_LTORJ ){ + for(j=i+1; jnSrc; j++){ + SrcItem *pI2 = &pTabList->a[j]; + if( pI2->fg.jointype & JT_RIGHT ){ + if( pI2->fg.jointype & JT_LEFT ){ + TREETRACE(0x1000,pParse,p, + ("FULL-JOIN simplifies to LEFT-JOIN on term %d\n",j)); + pI2->fg.jointype &= ~JT_RIGHT; + }else{ + TREETRACE(0x1000,pParse,p, + ("RIGHT-JOIN simplifies to JOIN on term %d\n",j)); + pI2->fg.jointype &= ~(JT_RIGHT|JT_OUTER); + } + } + } + for(j=pTabList->nSrc-1; j>=i; j--){ + pTabList->a[j].fg.jointype &= ~JT_LTORJ; + if( pTabList->a[j].fg.jointype & JT_RIGHT ) break; + } + } assert( pItem->iCursor>=0 ); unsetJoinExpr(p->pWhere, pItem->iCursor, pTabList->a[0].fg.jointype & JT_LTORJ); } - /* No futher action if this term of the FROM clause is not a subquery */ + /* No further action if this term of the FROM clause is not a subquery */ if( pSub==0 ) continue; /* Catch mismatch in the declared columns of a view and the number of @@ -146240,6 +147686,14 @@ SQLITE_PRIVATE int sqlite3Select( goto select_end; } + /* Do not attempt the usual optimizations (flattening and ORDER BY + ** elimination) on a MATERIALIZED common table expression because + ** a MATERIALIZED common table expression is an optimization fence. + */ + if( pItem->fg.isCte && pItem->u2.pCteUse->eM10d==M10d_Yes ){ + continue; + } + /* Do not try to flatten an aggregate subquery. ** ** Flattening an aggregate subquery is only possible if the outer query @@ -146269,6 +147723,8 @@ SQLITE_PRIVATE int sqlite3Select( ** (a) The outer query has a different ORDER BY clause ** (b) The subquery is part of a join ** See forum post 062d576715d277c8 + ** + ** Also retain the ORDER BY if the OmitOrderBy optimization is disabled. */ if( pSub->pOrderBy!=0 && (p->pOrderBy!=0 || pTabList->nSrc>1) /* Condition (5) */ @@ -146483,7 +147939,7 @@ SQLITE_PRIVATE int sqlite3Select( }else if( pItem->fg.isCte && pItem->u2.pCteUse->addrM9e>0 ){ /* This is a CTE for which materialization code has already been ** generated. Invoke the subroutine to compute the materialization, - ** the make the pItem->iCursor be a copy of the ephemerial table that + ** the make the pItem->iCursor be a copy of the ephemeral table that ** holds the result of the materialization. */ CteUse *pCteUse = pItem->u2.pCteUse; sqlite3VdbeAddOp2(v, OP_Gosub, pCteUse->regRtn, pCteUse->addrM9e); @@ -146866,7 +148322,7 @@ SQLITE_PRIVATE int sqlite3Select( */ if( pGroupBy ){ KeyInfo *pKeyInfo; /* Keying information for the group by clause */ - int addr1; /* A-vs-B comparision jump */ + int addr1; /* A-vs-B comparison jump */ int addrOutputRow; /* Start of subroutine that outputs a result row */ int regOutputRow; /* Return address register for output subroutine */ int addrSetAbort; /* Set the abort flag and return */ @@ -146957,9 +148413,13 @@ SQLITE_PRIVATE int sqlite3Select( int nCol; int nGroupBy; - explainTempTable(pParse, +#ifdef SQLITE_ENABLE_STMT_SCANSTATUS + int addrExp; /* Address of OP_Explain instruction */ +#endif + ExplainQueryPlan2(addrExp, (pParse, 0, "USE TEMP B-TREE FOR %s", (sDistinct.isTnct && (p->selFlags&SF_Distinct)==0) ? - "DISTINCT" : "GROUP BY"); + "DISTINCT" : "GROUP BY" + )); groupBySort = 1; nGroupBy = pGroupBy->nExpr; @@ -146984,18 +148444,23 @@ SQLITE_PRIVATE int sqlite3Select( } pAggInfo->directMode = 0; regRecord = sqlite3GetTempReg(pParse); + sqlite3VdbeScanStatusCounters(v, addrExp, 0, sqlite3VdbeCurrentAddr(v)); sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol, regRecord); sqlite3VdbeAddOp2(v, OP_SorterInsert, pAggInfo->sortingIdx, regRecord); + sqlite3VdbeScanStatusRange(v, addrExp, sqlite3VdbeCurrentAddr(v)-2, -1); sqlite3ReleaseTempReg(pParse, regRecord); sqlite3ReleaseTempRange(pParse, regBase, nCol); TREETRACE(0x2,pParse,p,("WhereEnd\n")); sqlite3WhereEnd(pWInfo); pAggInfo->sortingIdxPTab = sortPTab = pParse->nTab++; sortOut = sqlite3GetTempReg(pParse); + sqlite3VdbeScanStatusCounters(v, addrExp, sqlite3VdbeCurrentAddr(v), 0); sqlite3VdbeAddOp3(v, OP_OpenPseudo, sortPTab, sortOut, nCol); sqlite3VdbeAddOp2(v, OP_SorterSort, pAggInfo->sortingIdx, addrEnd); VdbeComment((v, "GROUP BY sort")); VdbeCoverage(v); pAggInfo->useSortingIdx = 1; + sqlite3VdbeScanStatusRange(v, addrExp, -1, sortPTab); + sqlite3VdbeScanStatusRange(v, addrExp, -1, pAggInfo->sortingIdx); } /* If there are entries in pAgggInfo->aFunc[] that contain subexpressions @@ -149246,7 +150711,7 @@ static void updateFromSelect( assert( pTabList->nSrc>1 ); if( pSrc ){ - pSrc->a[0].fg.notCte = 1; + assert( pSrc->a[0].fg.notCte ); pSrc->a[0].iCursor = -1; pSrc->a[0].pTab->nTabRef--; pSrc->a[0].pTab = 0; @@ -149763,7 +151228,7 @@ SQLITE_PRIVATE void sqlite3Update( && !hasFK && !chngKey && !bReplace - && (sNC.ncFlags & NC_Subquery)==0 + && (pWhere==0 || !ExprHasProperty(pWhere, EP_Subquery)) ){ flags |= WHERE_ONEPASS_MULTIROW; } @@ -149835,6 +151300,8 @@ SQLITE_PRIVATE void sqlite3Update( if( !isView ){ int addrOnce = 0; + int iNotUsed1 = 0; + int iNotUsed2 = 0; /* Open every index that needs updating. */ if( eOnePass!=ONEPASS_OFF ){ @@ -149846,7 +151313,7 @@ SQLITE_PRIVATE void sqlite3Update( addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v); } sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenWrite, 0, iBaseCur, - aToOpen, 0, 0); + aToOpen, &iNotUsed1, &iNotUsed2); if( addrOnce ){ sqlite3VdbeJumpHereOrPopInst(v, addrOnce); } @@ -150137,8 +151604,10 @@ SQLITE_PRIVATE void sqlite3Update( sqlite3VdbeAddOp2(v, OP_AddImm, regRowCount, 1); } - sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges, - TRIGGER_AFTER, pTab, regOldRowid, onError, labelContinue); + if( pTrigger ){ + sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges, + TRIGGER_AFTER, pTab, regOldRowid, onError, labelContinue); + } /* Repeat the above with the next record to be updated, until ** all record selected by the WHERE clause have been updated. @@ -150233,7 +151702,7 @@ static void updateVirtualTable( int nArg = 2 + pTab->nCol; /* Number of arguments to VUpdate */ int regArg; /* First register in VUpdate arg array */ int regRec; /* Register in which to assemble record */ - int regRowid; /* Register for ephem table rowid */ + int regRowid; /* Register for ephemeral table rowid */ int iCsr = pSrc->a[0].iCursor; /* Cursor used for virtual table scan */ int aDummy[2]; /* Unused arg for sqlite3WhereOkOnePass() */ int eOnePass; /* True to use onepass strategy */ @@ -150277,7 +151746,9 @@ static void updateVirtualTable( sqlite3ExprDup(db, pChanges->a[aXRef[i]].pExpr, 0) ); }else{ - pList = sqlite3ExprListAppend(pParse, pList, exprRowColumn(pParse, i)); + Expr *pRowExpr = exprRowColumn(pParse, i); + if( pRowExpr ) pRowExpr->op2 = OPFLAG_NOCHNG; + pList = sqlite3ExprListAppend(pParse, pList, pRowExpr); } } @@ -150354,7 +151825,7 @@ static void updateVirtualTable( sqlite3WhereEnd(pWInfo); } - /* Begin scannning through the ephemeral table. */ + /* Begin scanning through the ephemeral table. */ addr = sqlite3VdbeAddOp1(v, OP_Rewind, ephemTab); VdbeCoverage(v); /* Extract arguments from the current row of the ephemeral table and @@ -150562,7 +152033,7 @@ SQLITE_PRIVATE int sqlite3UpsertAnalyzeTarget( pExpr = &sCol[0]; } for(jj=0; jja[jj].pExpr,pExpr,iCursor)<2 ){ + if( sqlite3ExprCompare(0,pTarget->a[jj].pExpr,pExpr,iCursor)<2 ){ break; /* Column ii of the index matches column jj of target */ } } @@ -150911,7 +152382,7 @@ SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3RunVacuum( ** (possibly synchronous) transaction opened on the main database before ** sqlite3BtreeCopyFile() is called. ** - ** An optimisation would be to use a non-journaled pager. + ** An optimization would be to use a non-journaled pager. ** (Later:) I tried setting "PRAGMA vacuum_db.journal_mode=OFF" but ** that actually made the VACUUM run slower. Very little journalling ** actually occurs when doing a vacuum since the vacuum_db is initially @@ -151600,7 +153071,7 @@ SQLITE_PRIVATE void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){ ** the information we've collected. ** ** The VM register number pParse->regRowid holds the rowid of an - ** entry in the sqlite_schema table tht was created for this vtab + ** entry in the sqlite_schema table that was created for this vtab ** by sqlite3StartTable(). */ iDb = sqlite3SchemaToIndex(db, pTab->pSchema); @@ -152344,7 +153815,7 @@ SQLITE_PRIVATE void sqlite3VtabMakeWritable(Parse *pParse, Table *pTab){ ** ** An eponymous virtual table instance is one that is named after its ** module, and more importantly, does not require a CREATE VIRTUAL TABLE -** statement in order to come into existance. Eponymous virtual table +** statement in order to come into existence. Eponymous virtual table ** instances always exist. They cannot be DROP-ed. ** ** Any virtual table module for which xConnect and xCreate are the same @@ -152535,7 +154006,7 @@ typedef struct WhereRightJoin WhereRightJoin; /* ** This object is a header on a block of allocated memory that will be -** automatically freed when its WInfo oject is destructed. +** automatically freed when its WInfo object is destructed. */ struct WhereMemBlock { WhereMemBlock *pNext; /* Next block in the chain */ @@ -152596,7 +154067,7 @@ struct WhereLevel { int iCur; /* The VDBE cursor used by this IN operator */ int addrInTop; /* Top of the IN loop */ int iBase; /* Base register of multi-key index record */ - int nPrefix; /* Number of prior entires in the key */ + int nPrefix; /* Number of prior entries in the key */ u8 eEndLoopOp; /* IN Loop terminator. OP_Next or OP_Prev */ } *aInLoop; /* Information about each nested IN operator */ } in; /* Used when pWLoop->wsFlags&WHERE_IN_ABLE */ @@ -152846,7 +154317,7 @@ struct WhereClause { int nTerm; /* Number of terms */ int nSlot; /* Number of entries in a[] */ int nBase; /* Number of terms through the last non-Virtual */ - WhereTerm *a; /* Each a[] describes a term of the WHERE cluase */ + WhereTerm *a; /* Each a[] describes a term of the WHERE clause */ #if defined(SQLITE_SMALL_STACK) WhereTerm aStatic[1]; /* Initial static space for a[] */ #else @@ -153434,6 +154905,12 @@ SQLITE_PRIVATE void sqlite3WhereAddScanStatus( if( wsFlags & WHERE_INDEXED ){ sqlite3VdbeScanStatusRange(v, addrExplain, -1, pLvl->iIdxCur); } + }else{ + int addr = pSrclist->a[pLvl->iFrom].addrFillSub; + VdbeOp *pOp = sqlite3VdbeGetOp(v, addr-1); + assert( sqlite3VdbeDb(v)->mallocFailed || pOp->opcode==OP_InitCoroutine ); + assert( sqlite3VdbeDb(v)->mallocFailed || pOp->p2>addr ); + sqlite3VdbeScanStatusRange(v, addrExplain, addr, pOp->p2-1); } } } @@ -153931,7 +155408,7 @@ static int codeAllEqualityTerms( /* Figure out how many memory cells we will need then allocate them. */ regBase = pParse->nMem + 1; - nReg = pLoop->u.btree.nEq + nExtraReg; + nReg = nEq + nExtraReg; pParse->nMem += nReg; zAff = sqlite3DbStrDup(pParse->db,sqlite3IndexAffinityStr(pParse->db,pIdx)); @@ -153978,9 +155455,6 @@ static int codeAllEqualityTerms( sqlite3VdbeAddOp2(v, OP_Copy, r1, regBase+j); } } - } - for(j=nSkip; jaLTerm[j]; if( pTerm->eOperator & WO_IN ){ if( pTerm->pExpr->flags & EP_xIsSelect ){ /* No affinity ever needs to be (or should be) applied to a value @@ -154123,7 +155597,7 @@ static int codeCursorHintIsOrFunction(Walker *pWalker, Expr *pExpr){ ** 2) transform the expression node to a TK_REGISTER node that reads ** from the newly populated register. ** -** Also, if the node is a TK_COLUMN that does access the table idenified +** Also, if the node is a TK_COLUMN that does access the table identified ** by pCCurHint.iTabCur, and an index is being used (which we will ** know because CCurHint.pIdx!=0) then transform the TK_COLUMN into ** an access of the index rather than the original table. @@ -154741,7 +156215,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart( }; assert( TK_LE==TK_GT+1 ); /* Make sure the ordering.. */ assert( TK_LT==TK_GT+2 ); /* ... of the TK_xx values... */ - assert( TK_GE==TK_GT+3 ); /* ... is correcct. */ + assert( TK_GE==TK_GT+3 ); /* ... is correct. */ assert( (pStart->wtFlags & TERM_VNULL)==0 ); testcase( pStart->wtFlags & TERM_VIRTUAL ); @@ -155921,7 +157395,7 @@ SQLITE_PRIVATE SQLITE_NOINLINE void sqlite3WhereRightJoinLoop( ** the WHERE clause of SQL statements. ** ** This file was originally part of where.c but was split out to improve -** readability and editabiliity. This file contains utility routines for +** readability and editability. This file contains utility routines for ** analyzing Expr objects in the WHERE clause. */ /* #include "sqliteInt.h" */ @@ -156137,7 +157611,7 @@ static int isLikeOrGlob( ** range search. The third is because the caller assumes that the pattern ** consists of at least one character after all escapes have been ** removed. */ - if( cnt!=0 && 255!=(u8)z[cnt-1] && (cnt>1 || z[0]!=wc[3]) ){ + if( (cnt>1 || (cnt>0 && z[0]!=wc[3])) && 255!=(u8)z[cnt-1] ){ Expr *pPrefix; /* A "complete" match if the pattern ends with "*" or "%" */ @@ -156710,7 +158184,7 @@ static void exprAnalyzeOrTerm( pOrTerm->leftCursor))==0 ){ /* This term must be of the form t1.a==t2.b where t2 is in the ** chngToIN set but t1 is not. This term will be either preceded - ** or follwed by an inverted copy (t2.b==t1.a). Skip this term + ** or followed by an inverted copy (t2.b==t1.a). Skip this term ** and use its inversion. */ testcase( pOrTerm->wtFlags & TERM_COPIED ); testcase( pOrTerm->wtFlags & TERM_VIRTUAL ); @@ -156972,8 +158446,8 @@ static void exprAnalyze( WhereTerm *pTerm; /* The term to be analyzed */ WhereMaskSet *pMaskSet; /* Set of table index masks */ Expr *pExpr; /* The expression to be analyzed */ - Bitmask prereqLeft; /* Prerequesites of the pExpr->pLeft */ - Bitmask prereqAll; /* Prerequesites of pExpr */ + Bitmask prereqLeft; /* Prerequisites of the pExpr->pLeft */ + Bitmask prereqAll; /* Prerequisites of pExpr */ Bitmask extraRight = 0; /* Extra dependencies on LEFT JOIN */ Expr *pStr1 = 0; /* RHS of LIKE/GLOB operator */ int isComplete = 0; /* RHS of LIKE/GLOB ends with wildcard */ @@ -159534,7 +161008,7 @@ SQLITE_PRIVATE char sqlite3IndexColumnAffinity(sqlite3 *db, Index *pIdx, int iCo ** Value pLoop->nOut is currently set to the estimated number of rows ** visited for scanning (a=? AND b=?). This function reduces that estimate ** by some factor to account for the (c BETWEEN ? AND ?) expression based -** on the stat4 data for the index. this scan will be peformed multiple +** on the stat4 data for the index. this scan will be performed multiple ** times (once for each (a,b) combination that matches a=?) is dealt with ** by the caller. ** @@ -160289,7 +161763,7 @@ static WhereLoop **whereLoopFindLesser( ** rSetup. Call this SETUP-INVARIANT */ assert( p->rSetup>=pTemplate->rSetup ); - /* Any loop using an appliation-defined index (or PRIMARY KEY or + /* Any loop using an application-defined index (or PRIMARY KEY or ** UNIQUE constraint) with one or more == constraints is better ** than an automatic index. Unless it is a skip-scan. */ if( (p->wsFlags & WHERE_AUTO_INDEX)!=0 @@ -160316,7 +161790,7 @@ static WhereLoop **whereLoopFindLesser( /* If pTemplate is always better than p, then cause p to be overwritten ** with pTemplate. pTemplate is better than p if: - ** (1) pTemplate has no more dependences than p, and + ** (1) pTemplate has no more dependencies than p, and ** (2) pTemplate has an equal or lower cost than p. */ if( (p->prereq & pTemplate->prereq)==pTemplate->prereq /* (1) */ @@ -160434,7 +161908,7 @@ static int whereLoopInsert(WhereLoopBuilder *pBuilder, WhereLoop *pTemplate){ }else{ /* We will be overwriting WhereLoop p[]. But before we do, first ** go through the rest of the list and delete any other entries besides - ** p[] that are also supplated by pTemplate */ + ** p[] that are also supplanted by pTemplate */ WhereLoop **ppTail = &p->pNextLoop; WhereLoop *pToDel; while( *ppTail ){ @@ -160634,7 +162108,7 @@ static int whereRangeVectorLen( } /* -** Adjust the cost C by the costMult facter T. This only occurs if +** Adjust the cost C by the costMult factor T. This only occurs if ** compiled with -DSQLITE_ENABLE_COSTMULT */ #ifdef SQLITE_ENABLE_COSTMULT @@ -160661,7 +162135,7 @@ static int whereLoopAddBtreeIndex( Index *pProbe, /* An index on pSrc */ LogEst nInMul /* log(Number of iterations due to IN) */ ){ - WhereInfo *pWInfo = pBuilder->pWInfo; /* WHERE analyse context */ + WhereInfo *pWInfo = pBuilder->pWInfo; /* WHERE analyze context */ Parse *pParse = pWInfo->pParse; /* Parsing context */ sqlite3 *db = pParse->db; /* Database connection malloc context */ WhereLoop *pNew; /* Template WhereLoop under construction */ @@ -160971,7 +162445,7 @@ static int whereLoopAddBtreeIndex( assert( pSrc->pTab->szTabRow>0 ); if( pProbe->idxType==SQLITE_IDXTYPE_IPK ){ /* The pProbe->szIdxRow is low for an IPK table since the interior - ** pages are small. Thuse szIdxRow gives a good estimate of seek cost. + ** pages are small. Thus szIdxRow gives a good estimate of seek cost. ** But the leaf pages are full-size, so pProbe->szIdxRow would badly ** under-estimate the scanning cost. */ rCostIdx = pNew->nOut + 16; @@ -161316,7 +162790,7 @@ static SQLITE_NOINLINE u32 whereIsCoveringIndex( */ static int whereLoopAddBtree( WhereLoopBuilder *pBuilder, /* WHERE clause information */ - Bitmask mPrereq /* Extra prerequesites for using this table */ + Bitmask mPrereq /* Extra prerequisites for using this table */ ){ WhereInfo *pWInfo; /* WHERE analysis context */ Index *pProbe; /* An index we are evaluating */ @@ -161823,7 +163297,7 @@ static int whereLoopAddVirtualOne( ** ** Return a pointer to the collation name: ** -** 1. If there is an explicit COLLATE operator on the constaint, return it. +** 1. If there is an explicit COLLATE operator on the constraint, return it. ** ** 2. Else, if the column has an alternative collation, return that. ** @@ -162784,7 +164258,8 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ ** For joins of 3 or more tables, track the 10 best paths */ mxChoice = (nLoop<=1) ? 1 : (nLoop==2 ? 5 : 10); assert( nLoop<=pWInfo->pTabList->nSrc ); - WHERETRACE(0x002, ("---- begin solver. (nRowEst=%d)\n", nRowEst)); + WHERETRACE(0x002, ("---- begin solver. (nRowEst=%d, nQueryLoop=%d)\n", + nRowEst, pParse->nQueryLoop)); /* If nRowEst is zero and there is an ORDER BY clause, ignore it. In this ** case the purpose of this call is to estimate the number of rows returned @@ -162887,7 +164362,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ ); } /* TUNING: Add a small extra penalty (3) to sorting as an - ** extra encouragment to the query planner to select a plan + ** extra encouragement to the query planner to select a plan ** where the rows emerge in the correct order without any sorting ** required. */ rCost = sqlite3LogEstAdd(rUnsorted, aSortCost[isOrdered]) + 3; @@ -162903,9 +164378,10 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ /* TUNING: A full-scan of a VIEW or subquery in the outer loop ** is not so bad. */ - if( iLoop==0 && (pWLoop->wsFlags & WHERE_VIEWSCAN)!=0 ){ + if( iLoop==0 && (pWLoop->wsFlags & WHERE_VIEWSCAN)!=0 && nLoop>1 ){ rCost += -10; nOut += -30; + WHERETRACE(0x80,("VIEWSCAN cost reduction for %c\n",pWLoop->cId)); } /* Check to see if pWLoop should be added to the set of @@ -163537,6 +165013,28 @@ static SQLITE_NOINLINE void whereAddIndexedExpr( } } +/* +** Set the reverse-scan order mask to one for all tables in the query +** with the exception of MATERIALIZED common table expressions that have +** their own internal ORDER BY clauses. +** +** This implements the PRAGMA reverse_unordered_selects=ON setting. +** (Also SQLITE_DBCONFIG_REVERSE_SCANORDER). +*/ +static SQLITE_NOINLINE void whereReverseScanOrder(WhereInfo *pWInfo){ + int ii; + for(ii=0; iipTabList->nSrc; ii++){ + SrcItem *pItem = &pWInfo->pTabList->a[ii]; + if( !pItem->fg.isCte + || pItem->u2.pCteUse->eM10d!=M10d_Yes + || NEVER(pItem->pSelect==0) + || pItem->pSelect->pOrderBy==0 + ){ + pWInfo->revMask |= MASKBIT(ii); + } + } +} + /* ** Generate the beginning of the loop used for WHERE clause processing. ** The return value is a pointer to an opaque structure that contains @@ -163595,7 +165093,7 @@ static SQLITE_NOINLINE void whereAddIndexedExpr( ** ** OUTER JOINS ** -** An outer join of tables t1 and t2 is conceptally coded as follows: +** An outer join of tables t1 and t2 is conceptually coded as follows: ** ** foreach row1 in t1 do ** flag = 0 @@ -163750,7 +165248,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin( ** ** The N-th term of the FROM clause is assigned a bitmask of 1<mallocFailed ) goto whereBeginError; } } + assert( pWInfo->pTabList!=0 ); if( pWInfo->pOrderBy==0 && (db->flags & SQLITE_ReverseOrder)!=0 ){ - pWInfo->revMask = ALLBITS; + whereReverseScanOrder(pWInfo); } if( pParse->nErr ){ goto whereBeginError; @@ -164002,6 +165501,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin( 0!=(wctrlFlags & WHERE_ONEPASS_MULTIROW) && !IsVirtual(pTabList->a[0].pTab) && (0==(wsFlags & WHERE_MULTI_OR) || (wctrlFlags & WHERE_DUPLICATES_OK)) + && OptimizationEnabled(db, SQLITE_OnePass) )){ pWInfo->eOnePass = bOnerow ? ONEPASS_SINGLE : ONEPASS_MULTI; if( HasRowid(pTabList->a[0].pTab) && (wsFlags & WHERE_IDX_ONLY) ){ @@ -164731,7 +166231,7 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){ ** ** These are the same built-in window functions supported by Postgres. ** Although the behaviour of aggregate window functions (functions that -** can be used as either aggregates or window funtions) allows them to +** can be used as either aggregates or window functions) allows them to ** be implemented using an API, built-in window functions are much more ** esoteric. Additionally, some window functions (e.g. nth_value()) ** may only be implemented by caching the entire partition in memory. @@ -165261,7 +166761,7 @@ static Window *windowFind(Parse *pParse, Window *pList, const char *zName){ ** is the Window object representing the associated OVER clause. This ** function updates the contents of pWin as follows: ** -** * If the OVER clause refered to a named window (as in "max(x) OVER win"), +** * If the OVER clause referred to a named window (as in "max(x) OVER win"), ** search list pList for a matching WINDOW definition, and update pWin ** accordingly. If no such WINDOW clause can be found, leave an error ** in pParse. @@ -165882,7 +167382,7 @@ SQLITE_PRIVATE Window *sqlite3WindowAssemble( } /* -** Window *pWin has just been created from a WINDOW clause. Tokne pBase +** Window *pWin has just been created from a WINDOW clause. Token pBase ** is the base window. Earlier windows from the same WINDOW clause are ** stored in the linked list starting at pWin->pNextWin. This function ** either updates *pWin according to the base specification, or else @@ -166188,7 +167688,7 @@ struct WindowCsrAndReg { ** ** (ORDER BY a, b GROUPS BETWEEN 2 PRECEDING AND 2 FOLLOWING) ** -** The windows functions implmentation caches the input rows in a temp +** The windows functions implementation caches the input rows in a temp ** table, sorted by "a, b" (it actually populates the cache lazily, and ** aggressively removes rows once they are no longer required, but that's ** a mere detail). It keeps three cursors open on the temp table. One @@ -167197,7 +168697,7 @@ static int windowExprGtZero(Parse *pParse, Expr *pExpr){ ** ** For the most part, the patterns above are adapted to support UNBOUNDED by ** assuming that it is equivalent to "infinity PRECEDING/FOLLOWING" and -** CURRENT ROW by assuming that it is equivilent to "0 PRECEDING/FOLLOWING". +** CURRENT ROW by assuming that it is equivalent to "0 PRECEDING/FOLLOWING". ** This is optimized of course - branches that will never be taken and ** conditions that are always true are omitted from the VM code. The only ** exceptional case is: @@ -167476,7 +168976,7 @@ SQLITE_PRIVATE void sqlite3WindowCodeStep( } /* Allocate registers for the array of values from the sub-query, the - ** samve values in record form, and the rowid used to insert said record + ** same values in record form, and the rowid used to insert said record ** into the ephemeral table. */ regNew = pParse->nMem+1; pParse->nMem += nInput; @@ -167717,7 +169217,8 @@ SQLITE_PRIVATE void sqlite3WindowCodeStep( /************** End of window.c **********************************************/ /************** Begin file parse.c *******************************************/ /* This file is automatically generated by Lemon from input grammar -** source file "parse.y". */ +** source file "parse.y". +*/ /* ** 2001-09-15 ** @@ -167734,7 +169235,7 @@ SQLITE_PRIVATE void sqlite3WindowCodeStep( ** The canonical source code to this file ("parse.y") is a Lemon grammar ** file that specifies the input grammar and actions to take while parsing. ** That input file is processed by Lemon to generate a C-language -** implementation of a parser for the given grammer. You might be reading +** implementation of a parser for the given grammar. You might be reading ** this comment as part of the translated C-code. Edits should be made ** to the original parse.y sources. */ @@ -168230,7 +169731,7 @@ typedef union { #define YYFALLBACK 1 #define YYNSTATE 575 #define YYNRULE 403 -#define YYNRULE_WITH_ACTION 340 +#define YYNRULE_WITH_ACTION 338 #define YYNTOKEN 185 #define YY_MAX_SHIFT 574 #define YY_MIN_SHIFTREDUCE 833 @@ -168312,106 +169813,106 @@ static const YYACTIONTYPE yy_action[] = { /* 10 */ 568, 1310, 377, 1289, 408, 562, 562, 562, 568, 409, /* 20 */ 378, 1310, 1272, 41, 41, 41, 41, 208, 1520, 71, /* 30 */ 71, 969, 419, 41, 41, 491, 303, 279, 303, 970, - /* 40 */ 397, 71, 71, 125, 126, 80, 1212, 1212, 1047, 1050, + /* 40 */ 397, 71, 71, 125, 126, 80, 1210, 1210, 1047, 1050, /* 50 */ 1037, 1037, 123, 123, 124, 124, 124, 124, 476, 409, /* 60 */ 1237, 1, 1, 574, 2, 1241, 550, 118, 115, 229, /* 70 */ 317, 480, 146, 480, 524, 118, 115, 229, 529, 1323, - /* 80 */ 417, 523, 142, 125, 126, 80, 1212, 1212, 1047, 1050, + /* 80 */ 417, 523, 142, 125, 126, 80, 1210, 1210, 1047, 1050, /* 90 */ 1037, 1037, 123, 123, 124, 124, 124, 124, 118, 115, /* 100 */ 229, 327, 122, 122, 122, 122, 121, 121, 120, 120, /* 110 */ 120, 119, 116, 444, 284, 284, 284, 284, 442, 442, - /* 120 */ 442, 1561, 376, 1563, 1188, 375, 1159, 565, 1159, 565, - /* 130 */ 409, 1561, 537, 259, 226, 444, 101, 145, 449, 316, + /* 120 */ 442, 1559, 376, 1561, 1186, 375, 1157, 565, 1157, 565, + /* 130 */ 409, 1559, 537, 259, 226, 444, 101, 145, 449, 316, /* 140 */ 559, 240, 122, 122, 122, 122, 121, 121, 120, 120, - /* 150 */ 120, 119, 116, 444, 125, 126, 80, 1212, 1212, 1047, + /* 150 */ 120, 119, 116, 444, 125, 126, 80, 1210, 1210, 1047, /* 160 */ 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, 142, - /* 170 */ 294, 1188, 339, 448, 120, 120, 120, 119, 116, 444, - /* 180 */ 127, 1188, 1189, 1188, 148, 441, 440, 568, 119, 116, + /* 170 */ 294, 1186, 339, 448, 120, 120, 120, 119, 116, 444, + /* 180 */ 127, 1186, 1187, 1186, 148, 441, 440, 568, 119, 116, /* 190 */ 444, 124, 124, 124, 124, 117, 122, 122, 122, 122, /* 200 */ 121, 121, 120, 120, 120, 119, 116, 444, 454, 113, /* 210 */ 13, 13, 546, 122, 122, 122, 122, 121, 121, 120, - /* 220 */ 120, 120, 119, 116, 444, 422, 316, 559, 1188, 1189, - /* 230 */ 1188, 149, 1220, 409, 1220, 124, 124, 124, 124, 122, + /* 220 */ 120, 120, 119, 116, 444, 422, 316, 559, 1186, 1187, + /* 230 */ 1186, 149, 1218, 409, 1218, 124, 124, 124, 124, 122, /* 240 */ 122, 122, 122, 121, 121, 120, 120, 120, 119, 116, /* 250 */ 444, 465, 342, 1034, 1034, 1048, 1051, 125, 126, 80, - /* 260 */ 1212, 1212, 1047, 1050, 1037, 1037, 123, 123, 124, 124, - /* 270 */ 124, 124, 1275, 522, 222, 1188, 568, 409, 224, 514, + /* 260 */ 1210, 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, + /* 270 */ 124, 124, 1275, 522, 222, 1186, 568, 409, 224, 514, /* 280 */ 175, 82, 83, 122, 122, 122, 122, 121, 121, 120, - /* 290 */ 120, 120, 119, 116, 444, 1005, 16, 16, 1188, 133, - /* 300 */ 133, 125, 126, 80, 1212, 1212, 1047, 1050, 1037, 1037, + /* 290 */ 120, 120, 119, 116, 444, 1005, 16, 16, 1186, 133, + /* 300 */ 133, 125, 126, 80, 1210, 1210, 1047, 1050, 1037, 1037, /* 310 */ 123, 123, 124, 124, 124, 124, 122, 122, 122, 122, /* 320 */ 121, 121, 120, 120, 120, 119, 116, 444, 1038, 546, - /* 330 */ 1188, 373, 1188, 1189, 1188, 252, 1429, 399, 504, 501, + /* 330 */ 1186, 373, 1186, 1187, 1186, 252, 1429, 399, 504, 501, /* 340 */ 500, 111, 560, 566, 4, 924, 924, 433, 499, 340, - /* 350 */ 460, 328, 360, 394, 1233, 1188, 1189, 1188, 563, 568, + /* 350 */ 460, 328, 360, 394, 1231, 1186, 1187, 1186, 563, 568, /* 360 */ 122, 122, 122, 122, 121, 121, 120, 120, 120, 119, - /* 370 */ 116, 444, 284, 284, 369, 1574, 1600, 441, 440, 154, - /* 380 */ 409, 445, 71, 71, 1282, 565, 1217, 1188, 1189, 1188, - /* 390 */ 85, 1219, 271, 557, 543, 515, 1555, 568, 98, 1218, - /* 400 */ 6, 1274, 472, 142, 125, 126, 80, 1212, 1212, 1047, + /* 370 */ 116, 444, 284, 284, 369, 1572, 1598, 441, 440, 154, + /* 380 */ 409, 445, 71, 71, 1282, 565, 1215, 1186, 1187, 1186, + /* 390 */ 85, 1217, 271, 557, 543, 515, 515, 568, 98, 1216, + /* 400 */ 6, 1274, 472, 142, 125, 126, 80, 1210, 1210, 1047, /* 410 */ 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, 550, - /* 420 */ 13, 13, 1024, 507, 1220, 1188, 1220, 549, 109, 109, - /* 430 */ 222, 568, 1234, 175, 568, 427, 110, 197, 445, 569, - /* 440 */ 445, 430, 1546, 1014, 325, 551, 1188, 270, 287, 368, + /* 420 */ 13, 13, 1024, 507, 1218, 1186, 1218, 549, 109, 109, + /* 430 */ 222, 568, 1232, 175, 568, 427, 110, 197, 445, 569, + /* 440 */ 445, 430, 1546, 1014, 325, 551, 1186, 270, 287, 368, /* 450 */ 510, 363, 509, 257, 71, 71, 543, 71, 71, 359, - /* 460 */ 316, 559, 1606, 122, 122, 122, 122, 121, 121, 120, + /* 460 */ 316, 559, 1604, 122, 122, 122, 122, 121, 121, 120, /* 470 */ 120, 120, 119, 116, 444, 1014, 1014, 1016, 1017, 27, - /* 480 */ 284, 284, 1188, 1189, 1188, 1154, 568, 1605, 409, 899, - /* 490 */ 190, 550, 356, 565, 550, 935, 533, 517, 1154, 516, - /* 500 */ 413, 1154, 552, 1188, 1189, 1188, 568, 544, 1548, 51, - /* 510 */ 51, 214, 125, 126, 80, 1212, 1212, 1047, 1050, 1037, - /* 520 */ 1037, 123, 123, 124, 124, 124, 124, 1188, 474, 135, + /* 480 */ 284, 284, 1186, 1187, 1186, 1152, 568, 1603, 409, 899, + /* 490 */ 190, 550, 356, 565, 550, 935, 533, 517, 1152, 516, + /* 500 */ 413, 1152, 552, 1186, 1187, 1186, 568, 544, 544, 51, + /* 510 */ 51, 214, 125, 126, 80, 1210, 1210, 1047, 1050, 1037, + /* 520 */ 1037, 123, 123, 124, 124, 124, 124, 1186, 474, 135, /* 530 */ 135, 409, 284, 284, 1484, 505, 121, 121, 120, 120, - /* 540 */ 120, 119, 116, 444, 1005, 565, 518, 217, 541, 1555, - /* 550 */ 316, 559, 142, 6, 532, 125, 126, 80, 1212, 1212, + /* 540 */ 120, 119, 116, 444, 1005, 565, 518, 217, 541, 541, + /* 550 */ 316, 559, 142, 6, 532, 125, 126, 80, 1210, 1210, /* 560 */ 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, - /* 570 */ 1549, 122, 122, 122, 122, 121, 121, 120, 120, 120, - /* 580 */ 119, 116, 444, 485, 1188, 1189, 1188, 482, 281, 1263, - /* 590 */ 955, 252, 1188, 373, 504, 501, 500, 1188, 340, 570, - /* 600 */ 1188, 570, 409, 292, 499, 955, 874, 191, 480, 316, + /* 570 */ 1548, 122, 122, 122, 122, 121, 121, 120, 120, 120, + /* 580 */ 119, 116, 444, 485, 1186, 1187, 1186, 482, 281, 1263, + /* 590 */ 955, 252, 1186, 373, 504, 501, 500, 1186, 340, 570, + /* 600 */ 1186, 570, 409, 292, 499, 955, 874, 191, 480, 316, /* 610 */ 559, 384, 290, 380, 122, 122, 122, 122, 121, 121, - /* 620 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1212, - /* 630 */ 1212, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, - /* 640 */ 124, 409, 394, 1132, 1188, 867, 100, 284, 284, 1188, - /* 650 */ 1189, 1188, 373, 1089, 1188, 1189, 1188, 1188, 1189, 1188, - /* 660 */ 565, 455, 32, 373, 233, 125, 126, 80, 1212, 1212, + /* 620 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1210, + /* 630 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, + /* 640 */ 124, 409, 394, 1132, 1186, 867, 100, 284, 284, 1186, + /* 650 */ 1187, 1186, 373, 1089, 1186, 1187, 1186, 1186, 1187, 1186, + /* 660 */ 565, 455, 32, 373, 233, 125, 126, 80, 1210, 1210, /* 670 */ 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, /* 680 */ 1428, 957, 568, 228, 956, 122, 122, 122, 122, 121, - /* 690 */ 121, 120, 120, 120, 119, 116, 444, 1154, 228, 1188, - /* 700 */ 157, 1188, 1189, 1188, 1547, 13, 13, 301, 955, 1228, - /* 710 */ 1154, 153, 409, 1154, 373, 1577, 1172, 5, 369, 1574, - /* 720 */ 429, 1234, 3, 955, 122, 122, 122, 122, 121, 121, - /* 730 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1212, - /* 740 */ 1212, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, - /* 750 */ 124, 409, 208, 567, 1188, 1025, 1188, 1189, 1188, 1188, + /* 690 */ 121, 120, 120, 120, 119, 116, 444, 1152, 228, 1186, + /* 700 */ 157, 1186, 1187, 1186, 1547, 13, 13, 301, 955, 1226, + /* 710 */ 1152, 153, 409, 1152, 373, 1575, 1170, 5, 369, 1572, + /* 720 */ 429, 1232, 3, 955, 122, 122, 122, 122, 121, 121, + /* 730 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1210, + /* 740 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, + /* 750 */ 124, 409, 208, 567, 1186, 1025, 1186, 1187, 1186, 1186, /* 760 */ 388, 850, 155, 1546, 286, 402, 1094, 1094, 488, 568, - /* 770 */ 465, 342, 1315, 1315, 1546, 125, 126, 80, 1212, 1212, + /* 770 */ 465, 342, 1315, 1315, 1546, 125, 126, 80, 1210, 1210, /* 780 */ 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, /* 790 */ 129, 568, 13, 13, 374, 122, 122, 122, 122, 121, /* 800 */ 121, 120, 120, 120, 119, 116, 444, 302, 568, 453, - /* 810 */ 528, 1188, 1189, 1188, 13, 13, 1188, 1189, 1188, 1293, + /* 810 */ 528, 1186, 1187, 1186, 13, 13, 1186, 1187, 1186, 1293, /* 820 */ 463, 1263, 409, 1313, 1313, 1546, 1010, 453, 452, 200, /* 830 */ 299, 71, 71, 1261, 122, 122, 122, 122, 121, 121, - /* 840 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1212, - /* 850 */ 1212, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, - /* 860 */ 124, 409, 227, 1069, 1154, 284, 284, 419, 312, 278, - /* 870 */ 278, 285, 285, 1415, 406, 405, 382, 1154, 565, 568, - /* 880 */ 1154, 1191, 565, 1594, 565, 125, 126, 80, 1212, 1212, + /* 840 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1210, + /* 850 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, + /* 860 */ 124, 409, 227, 1069, 1152, 284, 284, 419, 312, 278, + /* 870 */ 278, 285, 285, 1415, 406, 405, 382, 1152, 565, 568, + /* 880 */ 1152, 1189, 565, 1592, 565, 125, 126, 80, 1210, 1210, /* 890 */ 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, /* 900 */ 453, 1476, 13, 13, 1530, 122, 122, 122, 122, 121, /* 910 */ 121, 120, 120, 120, 119, 116, 444, 201, 568, 354, - /* 920 */ 1580, 574, 2, 1241, 838, 839, 840, 1556, 317, 1207, - /* 930 */ 146, 6, 409, 255, 254, 253, 206, 1323, 9, 1191, + /* 920 */ 1578, 574, 2, 1241, 838, 839, 840, 1554, 317, 1205, + /* 930 */ 146, 6, 409, 255, 254, 253, 206, 1323, 9, 1189, /* 940 */ 262, 71, 71, 424, 122, 122, 122, 122, 121, 121, - /* 950 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1212, - /* 960 */ 1212, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, - /* 970 */ 124, 568, 284, 284, 568, 1208, 409, 573, 313, 1241, - /* 980 */ 349, 1292, 352, 419, 317, 565, 146, 491, 525, 1637, + /* 950 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1210, + /* 960 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, + /* 970 */ 124, 568, 284, 284, 568, 1206, 409, 573, 313, 1241, + /* 980 */ 349, 1292, 352, 419, 317, 565, 146, 491, 525, 1635, /* 990 */ 395, 371, 491, 1323, 70, 70, 1291, 71, 71, 240, - /* 1000 */ 1321, 104, 80, 1212, 1212, 1047, 1050, 1037, 1037, 123, + /* 1000 */ 1321, 104, 80, 1210, 1210, 1047, 1050, 1037, 1037, 123, /* 1010 */ 123, 124, 124, 124, 124, 122, 122, 122, 122, 121, /* 1020 */ 121, 120, 120, 120, 119, 116, 444, 1110, 284, 284, - /* 1030 */ 428, 448, 1519, 1208, 439, 284, 284, 1483, 1348, 311, + /* 1030 */ 428, 448, 1519, 1206, 439, 284, 284, 1483, 1348, 311, /* 1040 */ 474, 565, 1111, 969, 491, 491, 217, 1259, 565, 1532, /* 1050 */ 568, 970, 207, 568, 1024, 240, 383, 1112, 519, 122, /* 1060 */ 122, 122, 122, 121, 121, 120, 120, 120, 119, 116, @@ -168419,29 +169920,29 @@ static const YYACTIONTYPE yy_action[] = { /* 1080 */ 1489, 568, 284, 284, 97, 526, 491, 448, 911, 1322, /* 1090 */ 1318, 545, 409, 284, 284, 565, 151, 209, 1489, 1491, /* 1100 */ 262, 450, 55, 55, 56, 56, 565, 1014, 1014, 1016, - /* 1110 */ 443, 332, 409, 527, 12, 295, 125, 126, 80, 1212, - /* 1120 */ 1212, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, - /* 1130 */ 124, 347, 409, 862, 1528, 1208, 125, 126, 80, 1212, - /* 1140 */ 1212, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, - /* 1150 */ 124, 1133, 1635, 474, 1635, 371, 125, 114, 80, 1212, - /* 1160 */ 1212, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, + /* 1110 */ 443, 332, 409, 527, 12, 295, 125, 126, 80, 1210, + /* 1120 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, + /* 1130 */ 124, 347, 409, 862, 1528, 1206, 125, 126, 80, 1210, + /* 1140 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, + /* 1150 */ 124, 1133, 1633, 474, 1633, 371, 125, 114, 80, 1210, + /* 1160 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, /* 1170 */ 124, 1489, 329, 474, 331, 122, 122, 122, 122, 121, /* 1180 */ 121, 120, 120, 120, 119, 116, 444, 203, 1415, 568, - /* 1190 */ 1290, 862, 464, 1208, 436, 122, 122, 122, 122, 121, - /* 1200 */ 121, 120, 120, 120, 119, 116, 444, 553, 1133, 1636, - /* 1210 */ 539, 1636, 15, 15, 890, 122, 122, 122, 122, 121, + /* 1190 */ 1290, 862, 464, 1206, 436, 122, 122, 122, 122, 121, + /* 1200 */ 121, 120, 120, 120, 119, 116, 444, 553, 1133, 1634, + /* 1210 */ 539, 1634, 15, 15, 890, 122, 122, 122, 122, 121, /* 1220 */ 121, 120, 120, 120, 119, 116, 444, 568, 298, 538, - /* 1230 */ 1131, 1415, 1553, 1554, 1327, 409, 6, 6, 1165, 1264, + /* 1230 */ 1131, 1415, 1552, 1553, 1327, 409, 6, 6, 1163, 1264, /* 1240 */ 415, 320, 284, 284, 1415, 508, 565, 525, 300, 457, /* 1250 */ 43, 43, 568, 891, 12, 565, 330, 478, 425, 407, - /* 1260 */ 126, 80, 1212, 1212, 1047, 1050, 1037, 1037, 123, 123, - /* 1270 */ 124, 124, 124, 124, 568, 57, 57, 288, 1188, 1415, - /* 1280 */ 496, 458, 392, 392, 391, 273, 389, 1131, 1552, 847, - /* 1290 */ 1165, 407, 6, 568, 321, 1154, 470, 44, 44, 1551, - /* 1300 */ 1110, 426, 234, 6, 323, 256, 540, 256, 1154, 431, - /* 1310 */ 568, 1154, 322, 17, 487, 1111, 58, 58, 122, 122, + /* 1260 */ 126, 80, 1210, 1210, 1047, 1050, 1037, 1037, 123, 123, + /* 1270 */ 124, 124, 124, 124, 568, 57, 57, 288, 1186, 1415, + /* 1280 */ 496, 458, 392, 392, 391, 273, 389, 1131, 1551, 847, + /* 1290 */ 1163, 407, 6, 568, 321, 1152, 470, 44, 44, 1550, + /* 1300 */ 1110, 426, 234, 6, 323, 256, 540, 256, 1152, 431, + /* 1310 */ 568, 1152, 322, 17, 487, 1111, 58, 58, 122, 122, /* 1320 */ 122, 122, 121, 121, 120, 120, 120, 119, 116, 444, - /* 1330 */ 1112, 216, 481, 59, 59, 1188, 1189, 1188, 111, 560, + /* 1330 */ 1112, 216, 481, 59, 59, 1186, 1187, 1186, 111, 560, /* 1340 */ 324, 4, 236, 456, 526, 568, 237, 456, 568, 437, /* 1350 */ 168, 556, 420, 141, 479, 563, 568, 293, 568, 1091, /* 1360 */ 568, 293, 568, 1091, 531, 568, 870, 8, 60, 60, @@ -168455,7 +169956,7 @@ static const YYACTIONTYPE yy_action[] = { /* 1440 */ 1014, 132, 132, 67, 67, 568, 467, 568, 930, 471, /* 1450 */ 1360, 283, 226, 929, 315, 1359, 407, 568, 459, 407, /* 1460 */ 1014, 1014, 1016, 239, 407, 86, 213, 1346, 52, 52, - /* 1470 */ 68, 68, 1014, 1014, 1016, 1017, 27, 1579, 1176, 447, + /* 1470 */ 68, 68, 1014, 1014, 1016, 1017, 27, 1577, 1174, 447, /* 1480 */ 69, 69, 288, 97, 108, 1535, 106, 392, 392, 391, /* 1490 */ 273, 389, 568, 877, 847, 881, 568, 111, 560, 466, /* 1500 */ 4, 568, 152, 30, 38, 568, 1128, 234, 396, 323, @@ -168464,7 +169965,7 @@ static const YYACTIONTYPE yy_action[] = { /* 1530 */ 568, 289, 1508, 568, 31, 1507, 568, 445, 338, 483, /* 1540 */ 100, 54, 54, 344, 72, 72, 296, 236, 1076, 557, /* 1550 */ 445, 877, 1356, 134, 134, 168, 73, 73, 141, 161, - /* 1560 */ 161, 1568, 557, 535, 568, 319, 568, 348, 536, 1007, + /* 1560 */ 161, 1566, 557, 535, 568, 319, 568, 348, 536, 1007, /* 1570 */ 473, 261, 261, 889, 888, 235, 535, 568, 1024, 568, /* 1580 */ 475, 534, 261, 367, 109, 109, 521, 136, 136, 130, /* 1590 */ 130, 1024, 110, 366, 445, 569, 445, 109, 109, 1014, @@ -168472,7 +169973,7 @@ static const YYACTIONTYPE yy_action[] = { /* 1610 */ 410, 351, 1014, 568, 353, 316, 559, 568, 343, 568, /* 1620 */ 100, 497, 357, 258, 100, 896, 897, 140, 140, 355, /* 1630 */ 1306, 1014, 1014, 1016, 1017, 27, 139, 139, 362, 451, - /* 1640 */ 137, 137, 138, 138, 1014, 1014, 1016, 1017, 27, 1176, + /* 1640 */ 137, 137, 138, 138, 1014, 1014, 1016, 1017, 27, 1174, /* 1650 */ 447, 568, 372, 288, 111, 560, 1018, 4, 392, 392, /* 1660 */ 391, 273, 389, 568, 1137, 847, 568, 1072, 568, 258, /* 1670 */ 492, 563, 568, 211, 75, 75, 555, 960, 234, 261, @@ -168480,44 +169981,44 @@ static const YYACTIONTYPE yy_action[] = { /* 1690 */ 74, 42, 42, 1369, 445, 48, 48, 1414, 563, 972, /* 1700 */ 973, 1088, 1087, 1088, 1087, 860, 557, 150, 928, 1342, /* 1710 */ 113, 1354, 554, 1419, 1018, 1271, 1262, 1250, 236, 1249, - /* 1720 */ 1251, 445, 1587, 1339, 308, 276, 168, 309, 11, 141, + /* 1720 */ 1251, 445, 1585, 1339, 308, 276, 168, 309, 11, 141, /* 1730 */ 393, 310, 232, 557, 1401, 1024, 335, 291, 1396, 219, /* 1740 */ 336, 109, 109, 934, 297, 1406, 235, 341, 477, 110, /* 1750 */ 502, 445, 569, 445, 1389, 1405, 1014, 400, 1289, 365, /* 1760 */ 223, 1480, 1024, 1479, 1351, 1352, 1350, 1349, 109, 109, - /* 1770 */ 204, 1590, 1228, 558, 265, 218, 110, 205, 445, 569, + /* 1770 */ 204, 1588, 1226, 558, 265, 218, 110, 205, 445, 569, /* 1780 */ 445, 410, 387, 1014, 1527, 179, 316, 559, 1014, 1014, - /* 1790 */ 1016, 1017, 27, 230, 1525, 1225, 79, 560, 85, 4, + /* 1790 */ 1016, 1017, 27, 230, 1525, 1223, 79, 560, 85, 4, /* 1800 */ 418, 215, 548, 81, 84, 188, 1402, 173, 181, 461, /* 1810 */ 451, 35, 462, 563, 183, 1014, 1014, 1016, 1017, 27, /* 1820 */ 184, 1485, 185, 186, 495, 242, 98, 398, 1408, 36, /* 1830 */ 1407, 484, 91, 469, 401, 1410, 445, 192, 1474, 246, /* 1840 */ 1496, 490, 346, 277, 248, 196, 493, 511, 557, 350, /* 1850 */ 1252, 249, 250, 403, 1309, 1308, 111, 560, 432, 4, - /* 1860 */ 1307, 1300, 93, 1604, 881, 1603, 224, 404, 434, 520, - /* 1870 */ 263, 435, 1573, 563, 1279, 1278, 364, 1024, 306, 1277, - /* 1880 */ 264, 1602, 1559, 109, 109, 370, 1299, 307, 1558, 438, + /* 1860 */ 1307, 1300, 93, 1602, 881, 1601, 224, 404, 434, 520, + /* 1870 */ 263, 435, 1571, 563, 1279, 1278, 364, 1024, 306, 1277, + /* 1880 */ 264, 1600, 1557, 109, 109, 370, 1299, 307, 1556, 438, /* 1890 */ 128, 110, 1374, 445, 569, 445, 445, 546, 1014, 10, /* 1900 */ 1461, 105, 381, 1373, 34, 571, 99, 1332, 557, 314, - /* 1910 */ 1182, 530, 272, 274, 379, 210, 1331, 547, 385, 386, + /* 1910 */ 1180, 530, 272, 274, 379, 210, 1331, 547, 385, 386, /* 1920 */ 275, 572, 1247, 1242, 411, 412, 1512, 165, 178, 1513, /* 1930 */ 1014, 1014, 1016, 1017, 27, 1511, 1510, 1024, 78, 147, /* 1940 */ 166, 220, 221, 109, 109, 834, 304, 167, 446, 212, /* 1950 */ 318, 110, 231, 445, 569, 445, 144, 1086, 1014, 1084, - /* 1960 */ 326, 180, 169, 1207, 182, 334, 238, 913, 241, 1100, + /* 1960 */ 326, 180, 169, 1205, 182, 334, 238, 913, 241, 1100, /* 1970 */ 187, 170, 171, 421, 87, 88, 423, 189, 89, 90, /* 1980 */ 172, 1103, 243, 1099, 244, 158, 18, 245, 345, 247, - /* 1990 */ 1014, 1014, 1016, 1017, 27, 261, 1092, 193, 1222, 489, + /* 1990 */ 1014, 1014, 1016, 1017, 27, 261, 1092, 193, 1220, 489, /* 2000 */ 194, 37, 366, 849, 494, 251, 195, 506, 92, 19, /* 2010 */ 498, 358, 20, 503, 879, 361, 94, 892, 305, 159, - /* 2020 */ 513, 39, 95, 1170, 160, 1053, 964, 1139, 96, 174, - /* 2030 */ 1138, 225, 280, 282, 198, 958, 113, 1160, 1156, 260, - /* 2040 */ 21, 22, 23, 1158, 1164, 1163, 1144, 24, 33, 25, + /* 2020 */ 513, 39, 95, 1168, 160, 1053, 964, 1139, 96, 174, + /* 2030 */ 1138, 225, 280, 282, 198, 958, 113, 1158, 1154, 260, + /* 2040 */ 21, 22, 23, 1156, 1162, 1161, 1143, 24, 33, 25, /* 2050 */ 202, 542, 26, 100, 1067, 102, 1054, 103, 7, 1052, /* 2060 */ 1056, 1109, 1057, 1108, 266, 267, 28, 40, 390, 1019, - /* 2070 */ 861, 112, 29, 564, 1178, 1177, 268, 176, 143, 923, + /* 2070 */ 861, 112, 29, 564, 1176, 1175, 268, 176, 143, 923, /* 2080 */ 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238, - /* 2090 */ 1238, 1238, 1238, 1238, 269, 1595, + /* 2090 */ 1238, 1238, 1238, 1238, 269, 1593, }; static const YYCODETYPE yy_lookahead[] = { /* 0 */ 193, 193, 193, 274, 275, 276, 193, 274, 275, 276, @@ -168860,14 +170361,14 @@ static const short yy_reduce_ofst[] = { /* 400 */ 1722, 1723, 1733, 1717, 1724, 1727, 1728, 1725, 1740, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1641, 1641, 1641, 1469, 1236, 1347, 1236, 1236, 1236, 1469, + /* 0 */ 1639, 1639, 1639, 1469, 1236, 1347, 1236, 1236, 1236, 1469, /* 10 */ 1469, 1469, 1236, 1377, 1377, 1522, 1269, 1236, 1236, 1236, /* 20 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1468, 1236, 1236, - /* 30 */ 1236, 1236, 1557, 1557, 1236, 1236, 1236, 1236, 1236, 1236, + /* 30 */ 1236, 1236, 1555, 1555, 1236, 1236, 1236, 1236, 1236, 1236, /* 40 */ 1236, 1236, 1386, 1236, 1393, 1236, 1236, 1236, 1236, 1236, /* 50 */ 1470, 1471, 1236, 1236, 1236, 1521, 1523, 1486, 1400, 1399, /* 60 */ 1398, 1397, 1504, 1365, 1391, 1384, 1388, 1465, 1466, 1464, - /* 70 */ 1619, 1471, 1470, 1236, 1387, 1433, 1449, 1432, 1236, 1236, + /* 70 */ 1617, 1471, 1470, 1236, 1387, 1433, 1449, 1432, 1236, 1236, /* 80 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, /* 90 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, /* 100 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, @@ -168876,47 +170377,47 @@ static const YYACTIONTYPE yy_default[] = { /* 130 */ 1441, 1448, 1447, 1446, 1455, 1445, 1442, 1435, 1434, 1436, /* 140 */ 1437, 1236, 1236, 1260, 1236, 1236, 1257, 1311, 1236, 1236, /* 150 */ 1236, 1236, 1236, 1541, 1540, 1236, 1438, 1236, 1269, 1427, - /* 160 */ 1426, 1452, 1439, 1451, 1450, 1529, 1593, 1592, 1487, 1236, - /* 170 */ 1236, 1236, 1236, 1236, 1236, 1557, 1236, 1236, 1236, 1236, + /* 160 */ 1426, 1452, 1439, 1451, 1450, 1529, 1591, 1590, 1487, 1236, + /* 170 */ 1236, 1236, 1236, 1236, 1236, 1555, 1236, 1236, 1236, 1236, /* 180 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, /* 190 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1367, - /* 200 */ 1557, 1557, 1236, 1269, 1557, 1557, 1368, 1368, 1265, 1265, + /* 200 */ 1555, 1555, 1236, 1269, 1555, 1555, 1368, 1368, 1265, 1265, /* 210 */ 1371, 1236, 1536, 1338, 1338, 1338, 1338, 1347, 1338, 1236, /* 220 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, /* 230 */ 1236, 1236, 1236, 1236, 1526, 1524, 1236, 1236, 1236, 1236, /* 240 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, /* 250 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, /* 260 */ 1236, 1236, 1236, 1343, 1236, 1236, 1236, 1236, 1236, 1236, - /* 270 */ 1236, 1236, 1236, 1236, 1236, 1586, 1236, 1499, 1325, 1343, - /* 280 */ 1343, 1343, 1343, 1345, 1326, 1324, 1337, 1270, 1243, 1633, - /* 290 */ 1403, 1392, 1344, 1392, 1630, 1390, 1403, 1403, 1390, 1403, - /* 300 */ 1344, 1630, 1286, 1608, 1281, 1377, 1377, 1377, 1367, 1367, - /* 310 */ 1367, 1367, 1371, 1371, 1467, 1344, 1337, 1236, 1633, 1633, - /* 320 */ 1353, 1353, 1632, 1632, 1353, 1487, 1616, 1412, 1314, 1320, - /* 330 */ 1320, 1320, 1320, 1353, 1254, 1390, 1616, 1616, 1390, 1412, - /* 340 */ 1314, 1390, 1314, 1390, 1353, 1254, 1503, 1627, 1353, 1254, + /* 270 */ 1236, 1236, 1236, 1236, 1236, 1584, 1236, 1499, 1325, 1343, + /* 280 */ 1343, 1343, 1343, 1345, 1326, 1324, 1337, 1270, 1243, 1631, + /* 290 */ 1403, 1392, 1344, 1392, 1628, 1390, 1403, 1403, 1390, 1403, + /* 300 */ 1344, 1628, 1286, 1606, 1281, 1377, 1377, 1377, 1367, 1367, + /* 310 */ 1367, 1367, 1371, 1371, 1467, 1344, 1337, 1236, 1631, 1631, + /* 320 */ 1353, 1353, 1630, 1630, 1353, 1487, 1614, 1412, 1314, 1320, + /* 330 */ 1320, 1320, 1320, 1353, 1254, 1390, 1614, 1614, 1390, 1412, + /* 340 */ 1314, 1390, 1314, 1390, 1353, 1254, 1503, 1625, 1353, 1254, /* 350 */ 1477, 1353, 1254, 1353, 1254, 1477, 1312, 1312, 1312, 1301, - /* 360 */ 1236, 1236, 1477, 1312, 1286, 1312, 1301, 1312, 1312, 1575, - /* 370 */ 1236, 1481, 1481, 1477, 1353, 1567, 1567, 1380, 1380, 1385, - /* 380 */ 1371, 1472, 1353, 1236, 1385, 1383, 1381, 1390, 1304, 1589, - /* 390 */ 1589, 1585, 1585, 1585, 1638, 1638, 1536, 1601, 1269, 1269, - /* 400 */ 1269, 1269, 1601, 1288, 1288, 1270, 1270, 1269, 1601, 1236, - /* 410 */ 1236, 1236, 1236, 1236, 1236, 1596, 1236, 1531, 1488, 1357, + /* 360 */ 1236, 1236, 1477, 1312, 1286, 1312, 1301, 1312, 1312, 1573, + /* 370 */ 1236, 1481, 1481, 1477, 1353, 1565, 1565, 1380, 1380, 1385, + /* 380 */ 1371, 1472, 1353, 1236, 1385, 1383, 1381, 1390, 1304, 1587, + /* 390 */ 1587, 1583, 1583, 1583, 1636, 1636, 1536, 1599, 1269, 1269, + /* 400 */ 1269, 1269, 1599, 1288, 1288, 1270, 1270, 1269, 1599, 1236, + /* 410 */ 1236, 1236, 1236, 1236, 1236, 1594, 1236, 1531, 1488, 1357, /* 420 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, /* 430 */ 1236, 1236, 1236, 1236, 1542, 1236, 1236, 1236, 1236, 1236, /* 440 */ 1236, 1236, 1236, 1236, 1236, 1417, 1236, 1239, 1533, 1236, /* 450 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1394, 1395, 1358, /* 460 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1409, 1236, 1236, /* 470 */ 1236, 1404, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, - /* 480 */ 1629, 1236, 1236, 1236, 1236, 1236, 1236, 1502, 1501, 1236, + /* 480 */ 1627, 1236, 1236, 1236, 1236, 1236, 1236, 1502, 1501, 1236, /* 490 */ 1236, 1355, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, /* 500 */ 1236, 1236, 1236, 1236, 1236, 1284, 1236, 1236, 1236, 1236, /* 510 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, /* 520 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1382, /* 530 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, - /* 540 */ 1236, 1236, 1236, 1236, 1572, 1372, 1236, 1236, 1236, 1236, - /* 550 */ 1620, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, - /* 560 */ 1236, 1236, 1236, 1236, 1236, 1612, 1328, 1418, 1236, 1421, + /* 540 */ 1236, 1236, 1236, 1236, 1570, 1372, 1236, 1236, 1236, 1236, + /* 550 */ 1618, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, + /* 560 */ 1236, 1236, 1236, 1236, 1236, 1610, 1328, 1418, 1236, 1421, /* 570 */ 1258, 1236, 1248, 1236, 1236, }; /********** End of lemon-generated parsing tables *****************************/ @@ -169845,100 +171346,100 @@ static const char *const yyRuleName[] = { /* 306 */ "wqitem ::= nm eidlist_opt wqas LP select RP", /* 307 */ "wqlist ::= wqitem", /* 308 */ "wqlist ::= wqlist COMMA wqitem", - /* 309 */ "windowdefn_list ::= windowdefn", - /* 310 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn", - /* 311 */ "windowdefn ::= nm AS LP window RP", - /* 312 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt", - /* 313 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt", - /* 314 */ "window ::= ORDER BY sortlist frame_opt", - /* 315 */ "window ::= nm ORDER BY sortlist frame_opt", - /* 316 */ "window ::= frame_opt", - /* 317 */ "window ::= nm frame_opt", - /* 318 */ "frame_opt ::=", - /* 319 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt", - /* 320 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt", - /* 321 */ "range_or_rows ::= RANGE|ROWS|GROUPS", - /* 322 */ "frame_bound_s ::= frame_bound", - /* 323 */ "frame_bound_s ::= UNBOUNDED PRECEDING", - /* 324 */ "frame_bound_e ::= frame_bound", - /* 325 */ "frame_bound_e ::= UNBOUNDED FOLLOWING", - /* 326 */ "frame_bound ::= expr PRECEDING|FOLLOWING", - /* 327 */ "frame_bound ::= CURRENT ROW", - /* 328 */ "frame_exclude_opt ::=", - /* 329 */ "frame_exclude_opt ::= EXCLUDE frame_exclude", - /* 330 */ "frame_exclude ::= NO OTHERS", - /* 331 */ "frame_exclude ::= CURRENT ROW", - /* 332 */ "frame_exclude ::= GROUP|TIES", - /* 333 */ "window_clause ::= WINDOW windowdefn_list", - /* 334 */ "filter_over ::= filter_clause over_clause", - /* 335 */ "filter_over ::= over_clause", - /* 336 */ "filter_over ::= filter_clause", - /* 337 */ "over_clause ::= OVER LP window RP", - /* 338 */ "over_clause ::= OVER nm", - /* 339 */ "filter_clause ::= FILTER LP WHERE expr RP", - /* 340 */ "input ::= cmdlist", - /* 341 */ "cmdlist ::= cmdlist ecmd", - /* 342 */ "cmdlist ::= ecmd", - /* 343 */ "ecmd ::= SEMI", - /* 344 */ "ecmd ::= cmdx SEMI", - /* 345 */ "ecmd ::= explain cmdx SEMI", - /* 346 */ "trans_opt ::=", - /* 347 */ "trans_opt ::= TRANSACTION", - /* 348 */ "trans_opt ::= TRANSACTION nm", - /* 349 */ "savepoint_opt ::= SAVEPOINT", - /* 350 */ "savepoint_opt ::=", - /* 351 */ "cmd ::= create_table create_table_args", - /* 352 */ "table_option_set ::= table_option", - /* 353 */ "columnlist ::= columnlist COMMA columnname carglist", - /* 354 */ "columnlist ::= columnname carglist", - /* 355 */ "nm ::= ID|INDEXED|JOIN_KW", - /* 356 */ "nm ::= STRING", - /* 357 */ "typetoken ::= typename", - /* 358 */ "typename ::= ID|STRING", - /* 359 */ "signed ::= plus_num", - /* 360 */ "signed ::= minus_num", - /* 361 */ "carglist ::= carglist ccons", - /* 362 */ "carglist ::=", - /* 363 */ "ccons ::= NULL onconf", - /* 364 */ "ccons ::= GENERATED ALWAYS AS generated", - /* 365 */ "ccons ::= AS generated", - /* 366 */ "conslist_opt ::= COMMA conslist", - /* 367 */ "conslist ::= conslist tconscomma tcons", - /* 368 */ "conslist ::= tcons", - /* 369 */ "tconscomma ::=", - /* 370 */ "defer_subclause_opt ::= defer_subclause", - /* 371 */ "resolvetype ::= raisetype", - /* 372 */ "selectnowith ::= oneselect", - /* 373 */ "oneselect ::= values", - /* 374 */ "sclp ::= selcollist COMMA", - /* 375 */ "as ::= ID|STRING", - /* 376 */ "indexed_opt ::= indexed_by", - /* 377 */ "returning ::=", - /* 378 */ "expr ::= term", - /* 379 */ "likeop ::= LIKE_KW|MATCH", - /* 380 */ "case_operand ::= expr", - /* 381 */ "exprlist ::= nexprlist", - /* 382 */ "nmnum ::= plus_num", - /* 383 */ "nmnum ::= nm", - /* 384 */ "nmnum ::= ON", - /* 385 */ "nmnum ::= DELETE", - /* 386 */ "nmnum ::= DEFAULT", - /* 387 */ "plus_num ::= INTEGER|FLOAT", - /* 388 */ "foreach_clause ::=", - /* 389 */ "foreach_clause ::= FOR EACH ROW", - /* 390 */ "trnm ::= nm", - /* 391 */ "tridxby ::=", - /* 392 */ "database_kw_opt ::= DATABASE", - /* 393 */ "database_kw_opt ::=", - /* 394 */ "kwcolumn_opt ::=", - /* 395 */ "kwcolumn_opt ::= COLUMNKW", - /* 396 */ "vtabarglist ::= vtabarg", - /* 397 */ "vtabarglist ::= vtabarglist COMMA vtabarg", - /* 398 */ "vtabarg ::= vtabarg vtabargtoken", - /* 399 */ "anylist ::=", - /* 400 */ "anylist ::= anylist LP anylist RP", - /* 401 */ "anylist ::= anylist ANY", - /* 402 */ "with ::=", + /* 309 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn", + /* 310 */ "windowdefn ::= nm AS LP window RP", + /* 311 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt", + /* 312 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt", + /* 313 */ "window ::= ORDER BY sortlist frame_opt", + /* 314 */ "window ::= nm ORDER BY sortlist frame_opt", + /* 315 */ "window ::= nm frame_opt", + /* 316 */ "frame_opt ::=", + /* 317 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt", + /* 318 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt", + /* 319 */ "range_or_rows ::= RANGE|ROWS|GROUPS", + /* 320 */ "frame_bound_s ::= frame_bound", + /* 321 */ "frame_bound_s ::= UNBOUNDED PRECEDING", + /* 322 */ "frame_bound_e ::= frame_bound", + /* 323 */ "frame_bound_e ::= UNBOUNDED FOLLOWING", + /* 324 */ "frame_bound ::= expr PRECEDING|FOLLOWING", + /* 325 */ "frame_bound ::= CURRENT ROW", + /* 326 */ "frame_exclude_opt ::=", + /* 327 */ "frame_exclude_opt ::= EXCLUDE frame_exclude", + /* 328 */ "frame_exclude ::= NO OTHERS", + /* 329 */ "frame_exclude ::= CURRENT ROW", + /* 330 */ "frame_exclude ::= GROUP|TIES", + /* 331 */ "window_clause ::= WINDOW windowdefn_list", + /* 332 */ "filter_over ::= filter_clause over_clause", + /* 333 */ "filter_over ::= over_clause", + /* 334 */ "filter_over ::= filter_clause", + /* 335 */ "over_clause ::= OVER LP window RP", + /* 336 */ "over_clause ::= OVER nm", + /* 337 */ "filter_clause ::= FILTER LP WHERE expr RP", + /* 338 */ "input ::= cmdlist", + /* 339 */ "cmdlist ::= cmdlist ecmd", + /* 340 */ "cmdlist ::= ecmd", + /* 341 */ "ecmd ::= SEMI", + /* 342 */ "ecmd ::= cmdx SEMI", + /* 343 */ "ecmd ::= explain cmdx SEMI", + /* 344 */ "trans_opt ::=", + /* 345 */ "trans_opt ::= TRANSACTION", + /* 346 */ "trans_opt ::= TRANSACTION nm", + /* 347 */ "savepoint_opt ::= SAVEPOINT", + /* 348 */ "savepoint_opt ::=", + /* 349 */ "cmd ::= create_table create_table_args", + /* 350 */ "table_option_set ::= table_option", + /* 351 */ "columnlist ::= columnlist COMMA columnname carglist", + /* 352 */ "columnlist ::= columnname carglist", + /* 353 */ "nm ::= ID|INDEXED|JOIN_KW", + /* 354 */ "nm ::= STRING", + /* 355 */ "typetoken ::= typename", + /* 356 */ "typename ::= ID|STRING", + /* 357 */ "signed ::= plus_num", + /* 358 */ "signed ::= minus_num", + /* 359 */ "carglist ::= carglist ccons", + /* 360 */ "carglist ::=", + /* 361 */ "ccons ::= NULL onconf", + /* 362 */ "ccons ::= GENERATED ALWAYS AS generated", + /* 363 */ "ccons ::= AS generated", + /* 364 */ "conslist_opt ::= COMMA conslist", + /* 365 */ "conslist ::= conslist tconscomma tcons", + /* 366 */ "conslist ::= tcons", + /* 367 */ "tconscomma ::=", + /* 368 */ "defer_subclause_opt ::= defer_subclause", + /* 369 */ "resolvetype ::= raisetype", + /* 370 */ "selectnowith ::= oneselect", + /* 371 */ "oneselect ::= values", + /* 372 */ "sclp ::= selcollist COMMA", + /* 373 */ "as ::= ID|STRING", + /* 374 */ "indexed_opt ::= indexed_by", + /* 375 */ "returning ::=", + /* 376 */ "expr ::= term", + /* 377 */ "likeop ::= LIKE_KW|MATCH", + /* 378 */ "case_operand ::= expr", + /* 379 */ "exprlist ::= nexprlist", + /* 380 */ "nmnum ::= plus_num", + /* 381 */ "nmnum ::= nm", + /* 382 */ "nmnum ::= ON", + /* 383 */ "nmnum ::= DELETE", + /* 384 */ "nmnum ::= DEFAULT", + /* 385 */ "plus_num ::= INTEGER|FLOAT", + /* 386 */ "foreach_clause ::=", + /* 387 */ "foreach_clause ::= FOR EACH ROW", + /* 388 */ "trnm ::= nm", + /* 389 */ "tridxby ::=", + /* 390 */ "database_kw_opt ::= DATABASE", + /* 391 */ "database_kw_opt ::=", + /* 392 */ "kwcolumn_opt ::=", + /* 393 */ "kwcolumn_opt ::= COLUMNKW", + /* 394 */ "vtabarglist ::= vtabarg", + /* 395 */ "vtabarglist ::= vtabarglist COMMA vtabarg", + /* 396 */ "vtabarg ::= vtabarg vtabargtoken", + /* 397 */ "anylist ::=", + /* 398 */ "anylist ::= anylist LP anylist RP", + /* 399 */ "anylist ::= anylist ANY", + /* 400 */ "with ::=", + /* 401 */ "windowdefn_list ::= windowdefn", + /* 402 */ "window ::= frame_opt", }; #endif /* NDEBUG */ @@ -170754,100 +172255,100 @@ static const YYCODETYPE yyRuleInfoLhs[] = { 304, /* (306) wqitem ::= nm eidlist_opt wqas LP select RP */ 241, /* (307) wqlist ::= wqitem */ 241, /* (308) wqlist ::= wqlist COMMA wqitem */ - 306, /* (309) windowdefn_list ::= windowdefn */ - 306, /* (310) windowdefn_list ::= windowdefn_list COMMA windowdefn */ - 307, /* (311) windowdefn ::= nm AS LP window RP */ - 308, /* (312) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ - 308, /* (313) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ - 308, /* (314) window ::= ORDER BY sortlist frame_opt */ - 308, /* (315) window ::= nm ORDER BY sortlist frame_opt */ - 308, /* (316) window ::= frame_opt */ - 308, /* (317) window ::= nm frame_opt */ - 309, /* (318) frame_opt ::= */ - 309, /* (319) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ - 309, /* (320) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ - 313, /* (321) range_or_rows ::= RANGE|ROWS|GROUPS */ - 315, /* (322) frame_bound_s ::= frame_bound */ - 315, /* (323) frame_bound_s ::= UNBOUNDED PRECEDING */ - 316, /* (324) frame_bound_e ::= frame_bound */ - 316, /* (325) frame_bound_e ::= UNBOUNDED FOLLOWING */ - 314, /* (326) frame_bound ::= expr PRECEDING|FOLLOWING */ - 314, /* (327) frame_bound ::= CURRENT ROW */ - 317, /* (328) frame_exclude_opt ::= */ - 317, /* (329) frame_exclude_opt ::= EXCLUDE frame_exclude */ - 318, /* (330) frame_exclude ::= NO OTHERS */ - 318, /* (331) frame_exclude ::= CURRENT ROW */ - 318, /* (332) frame_exclude ::= GROUP|TIES */ - 251, /* (333) window_clause ::= WINDOW windowdefn_list */ - 273, /* (334) filter_over ::= filter_clause over_clause */ - 273, /* (335) filter_over ::= over_clause */ - 273, /* (336) filter_over ::= filter_clause */ - 312, /* (337) over_clause ::= OVER LP window RP */ - 312, /* (338) over_clause ::= OVER nm */ - 311, /* (339) filter_clause ::= FILTER LP WHERE expr RP */ - 185, /* (340) input ::= cmdlist */ - 186, /* (341) cmdlist ::= cmdlist ecmd */ - 186, /* (342) cmdlist ::= ecmd */ - 187, /* (343) ecmd ::= SEMI */ - 187, /* (344) ecmd ::= cmdx SEMI */ - 187, /* (345) ecmd ::= explain cmdx SEMI */ - 192, /* (346) trans_opt ::= */ - 192, /* (347) trans_opt ::= TRANSACTION */ - 192, /* (348) trans_opt ::= TRANSACTION nm */ - 194, /* (349) savepoint_opt ::= SAVEPOINT */ - 194, /* (350) savepoint_opt ::= */ - 190, /* (351) cmd ::= create_table create_table_args */ - 203, /* (352) table_option_set ::= table_option */ - 201, /* (353) columnlist ::= columnlist COMMA columnname carglist */ - 201, /* (354) columnlist ::= columnname carglist */ - 193, /* (355) nm ::= ID|INDEXED|JOIN_KW */ - 193, /* (356) nm ::= STRING */ - 208, /* (357) typetoken ::= typename */ - 209, /* (358) typename ::= ID|STRING */ - 210, /* (359) signed ::= plus_num */ - 210, /* (360) signed ::= minus_num */ - 207, /* (361) carglist ::= carglist ccons */ - 207, /* (362) carglist ::= */ - 215, /* (363) ccons ::= NULL onconf */ - 215, /* (364) ccons ::= GENERATED ALWAYS AS generated */ - 215, /* (365) ccons ::= AS generated */ - 202, /* (366) conslist_opt ::= COMMA conslist */ - 228, /* (367) conslist ::= conslist tconscomma tcons */ - 228, /* (368) conslist ::= tcons */ - 229, /* (369) tconscomma ::= */ - 233, /* (370) defer_subclause_opt ::= defer_subclause */ - 235, /* (371) resolvetype ::= raisetype */ - 239, /* (372) selectnowith ::= oneselect */ - 240, /* (373) oneselect ::= values */ - 254, /* (374) sclp ::= selcollist COMMA */ - 255, /* (375) as ::= ID|STRING */ - 264, /* (376) indexed_opt ::= indexed_by */ - 272, /* (377) returning ::= */ - 217, /* (378) expr ::= term */ - 274, /* (379) likeop ::= LIKE_KW|MATCH */ - 278, /* (380) case_operand ::= expr */ - 261, /* (381) exprlist ::= nexprlist */ - 284, /* (382) nmnum ::= plus_num */ - 284, /* (383) nmnum ::= nm */ - 284, /* (384) nmnum ::= ON */ - 284, /* (385) nmnum ::= DELETE */ - 284, /* (386) nmnum ::= DEFAULT */ - 211, /* (387) plus_num ::= INTEGER|FLOAT */ - 289, /* (388) foreach_clause ::= */ - 289, /* (389) foreach_clause ::= FOR EACH ROW */ - 292, /* (390) trnm ::= nm */ - 293, /* (391) tridxby ::= */ - 294, /* (392) database_kw_opt ::= DATABASE */ - 294, /* (393) database_kw_opt ::= */ - 297, /* (394) kwcolumn_opt ::= */ - 297, /* (395) kwcolumn_opt ::= COLUMNKW */ - 299, /* (396) vtabarglist ::= vtabarg */ - 299, /* (397) vtabarglist ::= vtabarglist COMMA vtabarg */ - 300, /* (398) vtabarg ::= vtabarg vtabargtoken */ - 303, /* (399) anylist ::= */ - 303, /* (400) anylist ::= anylist LP anylist RP */ - 303, /* (401) anylist ::= anylist ANY */ - 266, /* (402) with ::= */ + 306, /* (309) windowdefn_list ::= windowdefn_list COMMA windowdefn */ + 307, /* (310) windowdefn ::= nm AS LP window RP */ + 308, /* (311) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ + 308, /* (312) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ + 308, /* (313) window ::= ORDER BY sortlist frame_opt */ + 308, /* (314) window ::= nm ORDER BY sortlist frame_opt */ + 308, /* (315) window ::= nm frame_opt */ + 309, /* (316) frame_opt ::= */ + 309, /* (317) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ + 309, /* (318) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ + 313, /* (319) range_or_rows ::= RANGE|ROWS|GROUPS */ + 315, /* (320) frame_bound_s ::= frame_bound */ + 315, /* (321) frame_bound_s ::= UNBOUNDED PRECEDING */ + 316, /* (322) frame_bound_e ::= frame_bound */ + 316, /* (323) frame_bound_e ::= UNBOUNDED FOLLOWING */ + 314, /* (324) frame_bound ::= expr PRECEDING|FOLLOWING */ + 314, /* (325) frame_bound ::= CURRENT ROW */ + 317, /* (326) frame_exclude_opt ::= */ + 317, /* (327) frame_exclude_opt ::= EXCLUDE frame_exclude */ + 318, /* (328) frame_exclude ::= NO OTHERS */ + 318, /* (329) frame_exclude ::= CURRENT ROW */ + 318, /* (330) frame_exclude ::= GROUP|TIES */ + 251, /* (331) window_clause ::= WINDOW windowdefn_list */ + 273, /* (332) filter_over ::= filter_clause over_clause */ + 273, /* (333) filter_over ::= over_clause */ + 273, /* (334) filter_over ::= filter_clause */ + 312, /* (335) over_clause ::= OVER LP window RP */ + 312, /* (336) over_clause ::= OVER nm */ + 311, /* (337) filter_clause ::= FILTER LP WHERE expr RP */ + 185, /* (338) input ::= cmdlist */ + 186, /* (339) cmdlist ::= cmdlist ecmd */ + 186, /* (340) cmdlist ::= ecmd */ + 187, /* (341) ecmd ::= SEMI */ + 187, /* (342) ecmd ::= cmdx SEMI */ + 187, /* (343) ecmd ::= explain cmdx SEMI */ + 192, /* (344) trans_opt ::= */ + 192, /* (345) trans_opt ::= TRANSACTION */ + 192, /* (346) trans_opt ::= TRANSACTION nm */ + 194, /* (347) savepoint_opt ::= SAVEPOINT */ + 194, /* (348) savepoint_opt ::= */ + 190, /* (349) cmd ::= create_table create_table_args */ + 203, /* (350) table_option_set ::= table_option */ + 201, /* (351) columnlist ::= columnlist COMMA columnname carglist */ + 201, /* (352) columnlist ::= columnname carglist */ + 193, /* (353) nm ::= ID|INDEXED|JOIN_KW */ + 193, /* (354) nm ::= STRING */ + 208, /* (355) typetoken ::= typename */ + 209, /* (356) typename ::= ID|STRING */ + 210, /* (357) signed ::= plus_num */ + 210, /* (358) signed ::= minus_num */ + 207, /* (359) carglist ::= carglist ccons */ + 207, /* (360) carglist ::= */ + 215, /* (361) ccons ::= NULL onconf */ + 215, /* (362) ccons ::= GENERATED ALWAYS AS generated */ + 215, /* (363) ccons ::= AS generated */ + 202, /* (364) conslist_opt ::= COMMA conslist */ + 228, /* (365) conslist ::= conslist tconscomma tcons */ + 228, /* (366) conslist ::= tcons */ + 229, /* (367) tconscomma ::= */ + 233, /* (368) defer_subclause_opt ::= defer_subclause */ + 235, /* (369) resolvetype ::= raisetype */ + 239, /* (370) selectnowith ::= oneselect */ + 240, /* (371) oneselect ::= values */ + 254, /* (372) sclp ::= selcollist COMMA */ + 255, /* (373) as ::= ID|STRING */ + 264, /* (374) indexed_opt ::= indexed_by */ + 272, /* (375) returning ::= */ + 217, /* (376) expr ::= term */ + 274, /* (377) likeop ::= LIKE_KW|MATCH */ + 278, /* (378) case_operand ::= expr */ + 261, /* (379) exprlist ::= nexprlist */ + 284, /* (380) nmnum ::= plus_num */ + 284, /* (381) nmnum ::= nm */ + 284, /* (382) nmnum ::= ON */ + 284, /* (383) nmnum ::= DELETE */ + 284, /* (384) nmnum ::= DEFAULT */ + 211, /* (385) plus_num ::= INTEGER|FLOAT */ + 289, /* (386) foreach_clause ::= */ + 289, /* (387) foreach_clause ::= FOR EACH ROW */ + 292, /* (388) trnm ::= nm */ + 293, /* (389) tridxby ::= */ + 294, /* (390) database_kw_opt ::= DATABASE */ + 294, /* (391) database_kw_opt ::= */ + 297, /* (392) kwcolumn_opt ::= */ + 297, /* (393) kwcolumn_opt ::= COLUMNKW */ + 299, /* (394) vtabarglist ::= vtabarg */ + 299, /* (395) vtabarglist ::= vtabarglist COMMA vtabarg */ + 300, /* (396) vtabarg ::= vtabarg vtabargtoken */ + 303, /* (397) anylist ::= */ + 303, /* (398) anylist ::= anylist LP anylist RP */ + 303, /* (399) anylist ::= anylist ANY */ + 266, /* (400) with ::= */ + 306, /* (401) windowdefn_list ::= windowdefn */ + 308, /* (402) window ::= frame_opt */ }; /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number @@ -171162,100 +172663,100 @@ static const signed char yyRuleInfoNRhs[] = { -6, /* (306) wqitem ::= nm eidlist_opt wqas LP select RP */ -1, /* (307) wqlist ::= wqitem */ -3, /* (308) wqlist ::= wqlist COMMA wqitem */ - -1, /* (309) windowdefn_list ::= windowdefn */ - -3, /* (310) windowdefn_list ::= windowdefn_list COMMA windowdefn */ - -5, /* (311) windowdefn ::= nm AS LP window RP */ - -5, /* (312) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ - -6, /* (313) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ - -4, /* (314) window ::= ORDER BY sortlist frame_opt */ - -5, /* (315) window ::= nm ORDER BY sortlist frame_opt */ - -1, /* (316) window ::= frame_opt */ - -2, /* (317) window ::= nm frame_opt */ - 0, /* (318) frame_opt ::= */ - -3, /* (319) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ - -6, /* (320) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ - -1, /* (321) range_or_rows ::= RANGE|ROWS|GROUPS */ - -1, /* (322) frame_bound_s ::= frame_bound */ - -2, /* (323) frame_bound_s ::= UNBOUNDED PRECEDING */ - -1, /* (324) frame_bound_e ::= frame_bound */ - -2, /* (325) frame_bound_e ::= UNBOUNDED FOLLOWING */ - -2, /* (326) frame_bound ::= expr PRECEDING|FOLLOWING */ - -2, /* (327) frame_bound ::= CURRENT ROW */ - 0, /* (328) frame_exclude_opt ::= */ - -2, /* (329) frame_exclude_opt ::= EXCLUDE frame_exclude */ - -2, /* (330) frame_exclude ::= NO OTHERS */ - -2, /* (331) frame_exclude ::= CURRENT ROW */ - -1, /* (332) frame_exclude ::= GROUP|TIES */ - -2, /* (333) window_clause ::= WINDOW windowdefn_list */ - -2, /* (334) filter_over ::= filter_clause over_clause */ - -1, /* (335) filter_over ::= over_clause */ - -1, /* (336) filter_over ::= filter_clause */ - -4, /* (337) over_clause ::= OVER LP window RP */ - -2, /* (338) over_clause ::= OVER nm */ - -5, /* (339) filter_clause ::= FILTER LP WHERE expr RP */ - -1, /* (340) input ::= cmdlist */ - -2, /* (341) cmdlist ::= cmdlist ecmd */ - -1, /* (342) cmdlist ::= ecmd */ - -1, /* (343) ecmd ::= SEMI */ - -2, /* (344) ecmd ::= cmdx SEMI */ - -3, /* (345) ecmd ::= explain cmdx SEMI */ - 0, /* (346) trans_opt ::= */ - -1, /* (347) trans_opt ::= TRANSACTION */ - -2, /* (348) trans_opt ::= TRANSACTION nm */ - -1, /* (349) savepoint_opt ::= SAVEPOINT */ - 0, /* (350) savepoint_opt ::= */ - -2, /* (351) cmd ::= create_table create_table_args */ - -1, /* (352) table_option_set ::= table_option */ - -4, /* (353) columnlist ::= columnlist COMMA columnname carglist */ - -2, /* (354) columnlist ::= columnname carglist */ - -1, /* (355) nm ::= ID|INDEXED|JOIN_KW */ - -1, /* (356) nm ::= STRING */ - -1, /* (357) typetoken ::= typename */ - -1, /* (358) typename ::= ID|STRING */ - -1, /* (359) signed ::= plus_num */ - -1, /* (360) signed ::= minus_num */ - -2, /* (361) carglist ::= carglist ccons */ - 0, /* (362) carglist ::= */ - -2, /* (363) ccons ::= NULL onconf */ - -4, /* (364) ccons ::= GENERATED ALWAYS AS generated */ - -2, /* (365) ccons ::= AS generated */ - -2, /* (366) conslist_opt ::= COMMA conslist */ - -3, /* (367) conslist ::= conslist tconscomma tcons */ - -1, /* (368) conslist ::= tcons */ - 0, /* (369) tconscomma ::= */ - -1, /* (370) defer_subclause_opt ::= defer_subclause */ - -1, /* (371) resolvetype ::= raisetype */ - -1, /* (372) selectnowith ::= oneselect */ - -1, /* (373) oneselect ::= values */ - -2, /* (374) sclp ::= selcollist COMMA */ - -1, /* (375) as ::= ID|STRING */ - -1, /* (376) indexed_opt ::= indexed_by */ - 0, /* (377) returning ::= */ - -1, /* (378) expr ::= term */ - -1, /* (379) likeop ::= LIKE_KW|MATCH */ - -1, /* (380) case_operand ::= expr */ - -1, /* (381) exprlist ::= nexprlist */ - -1, /* (382) nmnum ::= plus_num */ - -1, /* (383) nmnum ::= nm */ - -1, /* (384) nmnum ::= ON */ - -1, /* (385) nmnum ::= DELETE */ - -1, /* (386) nmnum ::= DEFAULT */ - -1, /* (387) plus_num ::= INTEGER|FLOAT */ - 0, /* (388) foreach_clause ::= */ - -3, /* (389) foreach_clause ::= FOR EACH ROW */ - -1, /* (390) trnm ::= nm */ - 0, /* (391) tridxby ::= */ - -1, /* (392) database_kw_opt ::= DATABASE */ - 0, /* (393) database_kw_opt ::= */ - 0, /* (394) kwcolumn_opt ::= */ - -1, /* (395) kwcolumn_opt ::= COLUMNKW */ - -1, /* (396) vtabarglist ::= vtabarg */ - -3, /* (397) vtabarglist ::= vtabarglist COMMA vtabarg */ - -2, /* (398) vtabarg ::= vtabarg vtabargtoken */ - 0, /* (399) anylist ::= */ - -4, /* (400) anylist ::= anylist LP anylist RP */ - -2, /* (401) anylist ::= anylist ANY */ - 0, /* (402) with ::= */ + -3, /* (309) windowdefn_list ::= windowdefn_list COMMA windowdefn */ + -5, /* (310) windowdefn ::= nm AS LP window RP */ + -5, /* (311) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ + -6, /* (312) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ + -4, /* (313) window ::= ORDER BY sortlist frame_opt */ + -5, /* (314) window ::= nm ORDER BY sortlist frame_opt */ + -2, /* (315) window ::= nm frame_opt */ + 0, /* (316) frame_opt ::= */ + -3, /* (317) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ + -6, /* (318) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ + -1, /* (319) range_or_rows ::= RANGE|ROWS|GROUPS */ + -1, /* (320) frame_bound_s ::= frame_bound */ + -2, /* (321) frame_bound_s ::= UNBOUNDED PRECEDING */ + -1, /* (322) frame_bound_e ::= frame_bound */ + -2, /* (323) frame_bound_e ::= UNBOUNDED FOLLOWING */ + -2, /* (324) frame_bound ::= expr PRECEDING|FOLLOWING */ + -2, /* (325) frame_bound ::= CURRENT ROW */ + 0, /* (326) frame_exclude_opt ::= */ + -2, /* (327) frame_exclude_opt ::= EXCLUDE frame_exclude */ + -2, /* (328) frame_exclude ::= NO OTHERS */ + -2, /* (329) frame_exclude ::= CURRENT ROW */ + -1, /* (330) frame_exclude ::= GROUP|TIES */ + -2, /* (331) window_clause ::= WINDOW windowdefn_list */ + -2, /* (332) filter_over ::= filter_clause over_clause */ + -1, /* (333) filter_over ::= over_clause */ + -1, /* (334) filter_over ::= filter_clause */ + -4, /* (335) over_clause ::= OVER LP window RP */ + -2, /* (336) over_clause ::= OVER nm */ + -5, /* (337) filter_clause ::= FILTER LP WHERE expr RP */ + -1, /* (338) input ::= cmdlist */ + -2, /* (339) cmdlist ::= cmdlist ecmd */ + -1, /* (340) cmdlist ::= ecmd */ + -1, /* (341) ecmd ::= SEMI */ + -2, /* (342) ecmd ::= cmdx SEMI */ + -3, /* (343) ecmd ::= explain cmdx SEMI */ + 0, /* (344) trans_opt ::= */ + -1, /* (345) trans_opt ::= TRANSACTION */ + -2, /* (346) trans_opt ::= TRANSACTION nm */ + -1, /* (347) savepoint_opt ::= SAVEPOINT */ + 0, /* (348) savepoint_opt ::= */ + -2, /* (349) cmd ::= create_table create_table_args */ + -1, /* (350) table_option_set ::= table_option */ + -4, /* (351) columnlist ::= columnlist COMMA columnname carglist */ + -2, /* (352) columnlist ::= columnname carglist */ + -1, /* (353) nm ::= ID|INDEXED|JOIN_KW */ + -1, /* (354) nm ::= STRING */ + -1, /* (355) typetoken ::= typename */ + -1, /* (356) typename ::= ID|STRING */ + -1, /* (357) signed ::= plus_num */ + -1, /* (358) signed ::= minus_num */ + -2, /* (359) carglist ::= carglist ccons */ + 0, /* (360) carglist ::= */ + -2, /* (361) ccons ::= NULL onconf */ + -4, /* (362) ccons ::= GENERATED ALWAYS AS generated */ + -2, /* (363) ccons ::= AS generated */ + -2, /* (364) conslist_opt ::= COMMA conslist */ + -3, /* (365) conslist ::= conslist tconscomma tcons */ + -1, /* (366) conslist ::= tcons */ + 0, /* (367) tconscomma ::= */ + -1, /* (368) defer_subclause_opt ::= defer_subclause */ + -1, /* (369) resolvetype ::= raisetype */ + -1, /* (370) selectnowith ::= oneselect */ + -1, /* (371) oneselect ::= values */ + -2, /* (372) sclp ::= selcollist COMMA */ + -1, /* (373) as ::= ID|STRING */ + -1, /* (374) indexed_opt ::= indexed_by */ + 0, /* (375) returning ::= */ + -1, /* (376) expr ::= term */ + -1, /* (377) likeop ::= LIKE_KW|MATCH */ + -1, /* (378) case_operand ::= expr */ + -1, /* (379) exprlist ::= nexprlist */ + -1, /* (380) nmnum ::= plus_num */ + -1, /* (381) nmnum ::= nm */ + -1, /* (382) nmnum ::= ON */ + -1, /* (383) nmnum ::= DELETE */ + -1, /* (384) nmnum ::= DEFAULT */ + -1, /* (385) plus_num ::= INTEGER|FLOAT */ + 0, /* (386) foreach_clause ::= */ + -3, /* (387) foreach_clause ::= FOR EACH ROW */ + -1, /* (388) trnm ::= nm */ + 0, /* (389) tridxby ::= */ + -1, /* (390) database_kw_opt ::= DATABASE */ + 0, /* (391) database_kw_opt ::= */ + 0, /* (392) kwcolumn_opt ::= */ + -1, /* (393) kwcolumn_opt ::= COLUMNKW */ + -1, /* (394) vtabarglist ::= vtabarg */ + -3, /* (395) vtabarglist ::= vtabarglist COMMA vtabarg */ + -2, /* (396) vtabarg ::= vtabarg vtabargtoken */ + 0, /* (397) anylist ::= */ + -4, /* (398) anylist ::= anylist LP anylist RP */ + -2, /* (399) anylist ::= anylist ANY */ + 0, /* (400) with ::= */ + -1, /* (401) windowdefn_list ::= windowdefn */ + -1, /* (402) window ::= frame_opt */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -171298,10 +172799,10 @@ static YYACTIONTYPE yy_reduce( /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* explain ::= EXPLAIN */ -{ pParse->explain = 1; } +{ if( pParse->pReprepare==0 ) pParse->explain = 1; } break; case 1: /* explain ::= EXPLAIN QUERY PLAN */ -{ pParse->explain = 2; } +{ if( pParse->pReprepare==0 ) pParse->explain = 2; } break; case 2: /* cmdx ::= cmd */ { sqlite3FinishCoding(pParse); } @@ -171315,7 +172816,7 @@ static YYACTIONTYPE yy_reduce( case 5: /* transtype ::= DEFERRED */ case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6); case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7); - case 321: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==321); + case 319: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==319); {yymsp[0].minor.yy394 = yymsp[0].major; /*A-overwrites-X*/} break; case 8: /* cmd ::= COMMIT|END trans_opt */ @@ -171611,7 +173112,6 @@ static YYACTIONTYPE yy_reduce( if( p ){ parserDoubleLinkSelect(pParse, p); } - yymsp[0].minor.yy47 = p; /*A-overwrites-X*/ } break; case 88: /* selectnowith ::= selectnowith multiselect_op oneselect */ @@ -171703,14 +173203,17 @@ static YYACTIONTYPE yy_reduce( case 101: /* selcollist ::= sclp scanpt STAR */ { Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0); + sqlite3ExprSetErrorOffset(p, (int)(yymsp[0].minor.yy0.z - pParse->zTail)); yymsp[-2].minor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy322, p); } break; case 102: /* selcollist ::= sclp scanpt nm DOT STAR */ { - Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0); - Expr *pLeft = tokenExpr(pParse, TK_ID, yymsp[-2].minor.yy0); - Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight); + Expr *pRight, *pLeft, *pDot; + pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0); + sqlite3ExprSetErrorOffset(pRight, (int)(yymsp[0].minor.yy0.z - pParse->zTail)); + pLeft = tokenExpr(pParse, TK_ID, yymsp[-2].minor.yy0); + pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight); yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, pDot); } break; @@ -172604,11 +174107,7 @@ static YYACTIONTYPE yy_reduce( yymsp[-2].minor.yy521 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy521, yymsp[0].minor.yy385); } break; - case 309: /* windowdefn_list ::= windowdefn */ -{ yylhsminor.yy41 = yymsp[0].minor.yy41; } - yymsp[0].minor.yy41 = yylhsminor.yy41; - break; - case 310: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */ + case 309: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */ { assert( yymsp[0].minor.yy41!=0 ); sqlite3WindowChain(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy41); @@ -172617,7 +174116,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy41 = yylhsminor.yy41; break; - case 311: /* windowdefn ::= nm AS LP window RP */ + case 310: /* windowdefn ::= nm AS LP window RP */ { if( ALWAYS(yymsp[-1].minor.yy41) ){ yymsp[-1].minor.yy41->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n); @@ -172626,90 +174125,83 @@ static YYACTIONTYPE yy_reduce( } yymsp[-4].minor.yy41 = yylhsminor.yy41; break; - case 312: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */ + case 311: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */ { yymsp[-4].minor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy322, yymsp[-1].minor.yy322, 0); } break; - case 313: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ + case 312: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ { yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy322, yymsp[-1].minor.yy322, &yymsp[-5].minor.yy0); } yymsp[-5].minor.yy41 = yylhsminor.yy41; break; - case 314: /* window ::= ORDER BY sortlist frame_opt */ + case 313: /* window ::= ORDER BY sortlist frame_opt */ { yymsp[-3].minor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, yymsp[-1].minor.yy322, 0); } break; - case 315: /* window ::= nm ORDER BY sortlist frame_opt */ + case 314: /* window ::= nm ORDER BY sortlist frame_opt */ { yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, yymsp[-1].minor.yy322, &yymsp[-4].minor.yy0); } yymsp[-4].minor.yy41 = yylhsminor.yy41; break; - case 316: /* window ::= frame_opt */ - case 335: /* filter_over ::= over_clause */ yytestcase(yyruleno==335); -{ - yylhsminor.yy41 = yymsp[0].minor.yy41; -} - yymsp[0].minor.yy41 = yylhsminor.yy41; - break; - case 317: /* window ::= nm frame_opt */ + case 315: /* window ::= nm frame_opt */ { yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, 0, &yymsp[-1].minor.yy0); } yymsp[-1].minor.yy41 = yylhsminor.yy41; break; - case 318: /* frame_opt ::= */ + case 316: /* frame_opt ::= */ { yymsp[1].minor.yy41 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0); } break; - case 319: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ + case 317: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ { yylhsminor.yy41 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy394, yymsp[-1].minor.yy595.eType, yymsp[-1].minor.yy595.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy516); } yymsp[-2].minor.yy41 = yylhsminor.yy41; break; - case 320: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ + case 318: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ { yylhsminor.yy41 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy394, yymsp[-3].minor.yy595.eType, yymsp[-3].minor.yy595.pExpr, yymsp[-1].minor.yy595.eType, yymsp[-1].minor.yy595.pExpr, yymsp[0].minor.yy516); } yymsp[-5].minor.yy41 = yylhsminor.yy41; break; - case 322: /* frame_bound_s ::= frame_bound */ - case 324: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==324); + case 320: /* frame_bound_s ::= frame_bound */ + case 322: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==322); {yylhsminor.yy595 = yymsp[0].minor.yy595;} yymsp[0].minor.yy595 = yylhsminor.yy595; break; - case 323: /* frame_bound_s ::= UNBOUNDED PRECEDING */ - case 325: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==325); - case 327: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==327); + case 321: /* frame_bound_s ::= UNBOUNDED PRECEDING */ + case 323: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==323); + case 325: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==325); {yylhsminor.yy595.eType = yymsp[-1].major; yylhsminor.yy595.pExpr = 0;} yymsp[-1].minor.yy595 = yylhsminor.yy595; break; - case 326: /* frame_bound ::= expr PRECEDING|FOLLOWING */ + case 324: /* frame_bound ::= expr PRECEDING|FOLLOWING */ {yylhsminor.yy595.eType = yymsp[0].major; yylhsminor.yy595.pExpr = yymsp[-1].minor.yy528;} yymsp[-1].minor.yy595 = yylhsminor.yy595; break; - case 328: /* frame_exclude_opt ::= */ + case 326: /* frame_exclude_opt ::= */ {yymsp[1].minor.yy516 = 0;} break; - case 329: /* frame_exclude_opt ::= EXCLUDE frame_exclude */ + case 327: /* frame_exclude_opt ::= EXCLUDE frame_exclude */ {yymsp[-1].minor.yy516 = yymsp[0].minor.yy516;} break; - case 330: /* frame_exclude ::= NO OTHERS */ - case 331: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==331); + case 328: /* frame_exclude ::= NO OTHERS */ + case 329: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==329); {yymsp[-1].minor.yy516 = yymsp[-1].major; /*A-overwrites-X*/} break; - case 332: /* frame_exclude ::= GROUP|TIES */ + case 330: /* frame_exclude ::= GROUP|TIES */ {yymsp[0].minor.yy516 = yymsp[0].major; /*A-overwrites-X*/} break; - case 333: /* window_clause ::= WINDOW windowdefn_list */ + case 331: /* window_clause ::= WINDOW windowdefn_list */ { yymsp[-1].minor.yy41 = yymsp[0].minor.yy41; } break; - case 334: /* filter_over ::= filter_clause over_clause */ + case 332: /* filter_over ::= filter_clause over_clause */ { if( yymsp[0].minor.yy41 ){ yymsp[0].minor.yy41->pFilter = yymsp[-1].minor.yy528; @@ -172720,7 +174212,13 @@ static YYACTIONTYPE yy_reduce( } yymsp[-1].minor.yy41 = yylhsminor.yy41; break; - case 336: /* filter_over ::= filter_clause */ + case 333: /* filter_over ::= over_clause */ +{ + yylhsminor.yy41 = yymsp[0].minor.yy41; +} + yymsp[0].minor.yy41 = yylhsminor.yy41; + break; + case 334: /* filter_over ::= filter_clause */ { yylhsminor.yy41 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); if( yylhsminor.yy41 ){ @@ -172732,13 +174230,13 @@ static YYACTIONTYPE yy_reduce( } yymsp[0].minor.yy41 = yylhsminor.yy41; break; - case 337: /* over_clause ::= OVER LP window RP */ + case 335: /* over_clause ::= OVER LP window RP */ { yymsp[-3].minor.yy41 = yymsp[-1].minor.yy41; assert( yymsp[-3].minor.yy41!=0 ); } break; - case 338: /* over_clause ::= OVER nm */ + case 336: /* over_clause ::= OVER nm */ { yymsp[-1].minor.yy41 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); if( yymsp[-1].minor.yy41 ){ @@ -172746,73 +174244,75 @@ static YYACTIONTYPE yy_reduce( } } break; - case 339: /* filter_clause ::= FILTER LP WHERE expr RP */ + case 337: /* filter_clause ::= FILTER LP WHERE expr RP */ { yymsp[-4].minor.yy528 = yymsp[-1].minor.yy528; } break; default: - /* (340) input ::= cmdlist */ yytestcase(yyruleno==340); - /* (341) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==341); - /* (342) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=342); - /* (343) ecmd ::= SEMI */ yytestcase(yyruleno==343); - /* (344) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==344); - /* (345) ecmd ::= explain cmdx SEMI (NEVER REDUCES) */ assert(yyruleno!=345); - /* (346) trans_opt ::= */ yytestcase(yyruleno==346); - /* (347) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==347); - /* (348) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==348); - /* (349) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==349); - /* (350) savepoint_opt ::= */ yytestcase(yyruleno==350); - /* (351) cmd ::= create_table create_table_args */ yytestcase(yyruleno==351); - /* (352) table_option_set ::= table_option (OPTIMIZED OUT) */ assert(yyruleno!=352); - /* (353) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==353); - /* (354) columnlist ::= columnname carglist */ yytestcase(yyruleno==354); - /* (355) nm ::= ID|INDEXED|JOIN_KW */ yytestcase(yyruleno==355); - /* (356) nm ::= STRING */ yytestcase(yyruleno==356); - /* (357) typetoken ::= typename */ yytestcase(yyruleno==357); - /* (358) typename ::= ID|STRING */ yytestcase(yyruleno==358); - /* (359) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=359); - /* (360) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=360); - /* (361) carglist ::= carglist ccons */ yytestcase(yyruleno==361); - /* (362) carglist ::= */ yytestcase(yyruleno==362); - /* (363) ccons ::= NULL onconf */ yytestcase(yyruleno==363); - /* (364) ccons ::= GENERATED ALWAYS AS generated */ yytestcase(yyruleno==364); - /* (365) ccons ::= AS generated */ yytestcase(yyruleno==365); - /* (366) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==366); - /* (367) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==367); - /* (368) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=368); - /* (369) tconscomma ::= */ yytestcase(yyruleno==369); - /* (370) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=370); - /* (371) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=371); - /* (372) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=372); - /* (373) oneselect ::= values */ yytestcase(yyruleno==373); - /* (374) sclp ::= selcollist COMMA */ yytestcase(yyruleno==374); - /* (375) as ::= ID|STRING */ yytestcase(yyruleno==375); - /* (376) indexed_opt ::= indexed_by (OPTIMIZED OUT) */ assert(yyruleno!=376); - /* (377) returning ::= */ yytestcase(yyruleno==377); - /* (378) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=378); - /* (379) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==379); - /* (380) case_operand ::= expr */ yytestcase(yyruleno==380); - /* (381) exprlist ::= nexprlist */ yytestcase(yyruleno==381); - /* (382) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=382); - /* (383) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=383); - /* (384) nmnum ::= ON */ yytestcase(yyruleno==384); - /* (385) nmnum ::= DELETE */ yytestcase(yyruleno==385); - /* (386) nmnum ::= DEFAULT */ yytestcase(yyruleno==386); - /* (387) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==387); - /* (388) foreach_clause ::= */ yytestcase(yyruleno==388); - /* (389) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==389); - /* (390) trnm ::= nm */ yytestcase(yyruleno==390); - /* (391) tridxby ::= */ yytestcase(yyruleno==391); - /* (392) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==392); - /* (393) database_kw_opt ::= */ yytestcase(yyruleno==393); - /* (394) kwcolumn_opt ::= */ yytestcase(yyruleno==394); - /* (395) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==395); - /* (396) vtabarglist ::= vtabarg */ yytestcase(yyruleno==396); - /* (397) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==397); - /* (398) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==398); - /* (399) anylist ::= */ yytestcase(yyruleno==399); - /* (400) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==400); - /* (401) anylist ::= anylist ANY */ yytestcase(yyruleno==401); - /* (402) with ::= */ yytestcase(yyruleno==402); + /* (338) input ::= cmdlist */ yytestcase(yyruleno==338); + /* (339) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==339); + /* (340) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=340); + /* (341) ecmd ::= SEMI */ yytestcase(yyruleno==341); + /* (342) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==342); + /* (343) ecmd ::= explain cmdx SEMI (NEVER REDUCES) */ assert(yyruleno!=343); + /* (344) trans_opt ::= */ yytestcase(yyruleno==344); + /* (345) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==345); + /* (346) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==346); + /* (347) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==347); + /* (348) savepoint_opt ::= */ yytestcase(yyruleno==348); + /* (349) cmd ::= create_table create_table_args */ yytestcase(yyruleno==349); + /* (350) table_option_set ::= table_option (OPTIMIZED OUT) */ assert(yyruleno!=350); + /* (351) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==351); + /* (352) columnlist ::= columnname carglist */ yytestcase(yyruleno==352); + /* (353) nm ::= ID|INDEXED|JOIN_KW */ yytestcase(yyruleno==353); + /* (354) nm ::= STRING */ yytestcase(yyruleno==354); + /* (355) typetoken ::= typename */ yytestcase(yyruleno==355); + /* (356) typename ::= ID|STRING */ yytestcase(yyruleno==356); + /* (357) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=357); + /* (358) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=358); + /* (359) carglist ::= carglist ccons */ yytestcase(yyruleno==359); + /* (360) carglist ::= */ yytestcase(yyruleno==360); + /* (361) ccons ::= NULL onconf */ yytestcase(yyruleno==361); + /* (362) ccons ::= GENERATED ALWAYS AS generated */ yytestcase(yyruleno==362); + /* (363) ccons ::= AS generated */ yytestcase(yyruleno==363); + /* (364) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==364); + /* (365) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==365); + /* (366) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=366); + /* (367) tconscomma ::= */ yytestcase(yyruleno==367); + /* (368) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=368); + /* (369) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=369); + /* (370) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=370); + /* (371) oneselect ::= values */ yytestcase(yyruleno==371); + /* (372) sclp ::= selcollist COMMA */ yytestcase(yyruleno==372); + /* (373) as ::= ID|STRING */ yytestcase(yyruleno==373); + /* (374) indexed_opt ::= indexed_by (OPTIMIZED OUT) */ assert(yyruleno!=374); + /* (375) returning ::= */ yytestcase(yyruleno==375); + /* (376) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=376); + /* (377) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==377); + /* (378) case_operand ::= expr */ yytestcase(yyruleno==378); + /* (379) exprlist ::= nexprlist */ yytestcase(yyruleno==379); + /* (380) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=380); + /* (381) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=381); + /* (382) nmnum ::= ON */ yytestcase(yyruleno==382); + /* (383) nmnum ::= DELETE */ yytestcase(yyruleno==383); + /* (384) nmnum ::= DEFAULT */ yytestcase(yyruleno==384); + /* (385) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==385); + /* (386) foreach_clause ::= */ yytestcase(yyruleno==386); + /* (387) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==387); + /* (388) trnm ::= nm */ yytestcase(yyruleno==388); + /* (389) tridxby ::= */ yytestcase(yyruleno==389); + /* (390) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==390); + /* (391) database_kw_opt ::= */ yytestcase(yyruleno==391); + /* (392) kwcolumn_opt ::= */ yytestcase(yyruleno==392); + /* (393) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==393); + /* (394) vtabarglist ::= vtabarg */ yytestcase(yyruleno==394); + /* (395) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==395); + /* (396) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==396); + /* (397) anylist ::= */ yytestcase(yyruleno==397); + /* (398) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==398); + /* (399) anylist ::= anylist ANY */ yytestcase(yyruleno==399); + /* (400) with ::= */ yytestcase(yyruleno==400); + /* (401) windowdefn_list ::= windowdefn (OPTIMIZED OUT) */ assert(yyruleno!=401); + /* (402) window ::= frame_opt (OPTIMIZED OUT) */ assert(yyruleno!=402); break; /********** End reduce actions ************************************************/ }; @@ -173601,180 +175101,179 @@ static const unsigned char aKWCode[148] = {0, static int keywordCode(const char *z, int n, int *pType){ int i, j; const char *zKW; - if( n>=2 ){ - i = ((charMap(z[0])*4) ^ (charMap(z[n-1])*3) ^ n*1) % 127; - for(i=(int)aKWHash[i]; i>0; i=aKWNext[i]){ - if( aKWLen[i]!=n ) continue; - zKW = &zKWText[aKWOffset[i]]; + assert( n>=2 ); + i = ((charMap(z[0])*4) ^ (charMap(z[n-1])*3) ^ n*1) % 127; + for(i=(int)aKWHash[i]; i>0; i=aKWNext[i]){ + if( aKWLen[i]!=n ) continue; + zKW = &zKWText[aKWOffset[i]]; #ifdef SQLITE_ASCII - if( (z[0]&~0x20)!=zKW[0] ) continue; - if( (z[1]&~0x20)!=zKW[1] ) continue; - j = 2; - while( j=2 ) keywordCode((char*)z, n, &id); return id; } #define SQLITE_N_KEYWORD 147 @@ -174079,7 +175578,7 @@ SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *z, int *tokenType){ testcase( z[0]=='0' ); testcase( z[0]=='1' ); testcase( z[0]=='2' ); testcase( z[0]=='3' ); testcase( z[0]=='4' ); testcase( z[0]=='5' ); testcase( z[0]=='6' ); testcase( z[0]=='7' ); testcase( z[0]=='8' ); - testcase( z[0]=='9' ); + testcase( z[0]=='9' ); testcase( z[0]=='.' ); *tokenType = TK_INTEGER; #ifndef SQLITE_OMIT_HEX_INTEGER if( z[0]=='0' && (z[1]=='x' || z[1]=='X') && sqlite3Isxdigit(z[2]) ){ @@ -174151,7 +175650,8 @@ SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *z, int *tokenType){ return i; } case CC_KYWD0: { - for(i=1; aiClass[z[i]]<=CC_KYWD; i++){} + if( aiClass[z[1]]>CC_KYWD ){ i = 1; break; } + for(i=2; aiClass[z[i]]<=CC_KYWD; i++){} if( IdChar(z[i]) ){ /* This token started out using characters that can appear in keywords, ** but z[i] is a character not allowed within keywords, so this must @@ -174930,12 +176430,6 @@ static int sqlite3TestExtInit(sqlite3 *db){ ** Forward declarations of external module initializer functions ** for modules that need them. */ -#ifdef SQLITE_ENABLE_FTS1 -SQLITE_PRIVATE int sqlite3Fts1Init(sqlite3*); -#endif -#ifdef SQLITE_ENABLE_FTS2 -SQLITE_PRIVATE int sqlite3Fts2Init(sqlite3*); -#endif #ifdef SQLITE_ENABLE_FTS5 SQLITE_PRIVATE int sqlite3Fts5Init(sqlite3*); #endif @@ -174948,12 +176442,6 @@ SQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3*); ** built-in extensions. */ static int (*const sqlite3BuiltinExtensions[])(sqlite3*) = { -#ifdef SQLITE_ENABLE_FTS1 - sqlite3Fts1Init, -#endif -#ifdef SQLITE_ENABLE_FTS2 - sqlite3Fts2Init, -#endif #ifdef SQLITE_ENABLE_FTS3 sqlite3Fts3Init, #endif @@ -176566,9 +178054,9 @@ static int sqliteDefaultBusyCallback( void *ptr, /* Database connection */ int count /* Number of times table has been busy */ ){ -#if SQLITE_OS_WIN || HAVE_USLEEP +#if SQLITE_OS_WIN || !defined(HAVE_NANOSLEEP) || HAVE_NANOSLEEP /* This case is for systems that have support for sleeping for fractions of - ** a second. Examples: All windows systems, unix systems with usleep() */ + ** a second. Examples: All windows systems, unix systems with nanosleep() */ static const u8 delays[] = { 1, 2, 5, 10, 15, 20, 25, 25, 25, 50, 50, 100 }; static const u8 totals[] = @@ -178206,7 +179694,7 @@ static int openDatabase( ** 0 off off ** ** Legacy behavior is 3 (double-quoted string literals are allowed anywhere) -** and so that is the default. But developers are encouranged to use +** and so that is the default. But developers are encouraged to use ** -DSQLITE_DQS=0 (best) or -DSQLITE_DQS=1 (second choice) if possible. */ #if !defined(SQLITE_DQS) @@ -178741,7 +180229,7 @@ SQLITE_API int sqlite3_table_column_metadata( /* Find the column for which info is requested */ if( zColumnName==0 ){ - /* Query for existance of table only */ + /* Query for existence of table only */ }else{ for(iCol=0; iColnCol; iCol++){ pCol = &pTab->aCol[iCol]; @@ -179061,10 +180549,12 @@ SQLITE_API int sqlite3_test_control(int op, ...){ sqlite3ShowSrcList(0); sqlite3ShowWith(0); sqlite3ShowUpsert(0); +#ifndef SQLITE_OMIT_TRIGGER sqlite3ShowTriggerStep(0); sqlite3ShowTriggerStepList(0); sqlite3ShowTrigger(0); sqlite3ShowTriggerList(0); +#endif #ifndef SQLITE_OMIT_WINDOWFUNC sqlite3ShowWindow(0); sqlite3ShowWinFunc(0); @@ -179181,7 +180671,7 @@ SQLITE_API int sqlite3_test_control(int op, ...){ ** formed and never corrupt. This flag is clear by default, indicating that ** database files might have arbitrary corruption. Setting the flag during ** testing causes certain assert() statements in the code to be activated - ** that demonstrat invariants on well-formed database files. + ** that demonstrate invariants on well-formed database files. */ case SQLITE_TESTCTRL_NEVER_CORRUPT: { sqlite3GlobalConfig.neverCorrupt = va_arg(ap, int); @@ -179335,7 +180825,7 @@ SQLITE_API int sqlite3_test_control(int op, ...){ ** ** op==0 Store the current sqlite3TreeTrace in *ptr ** op==1 Set sqlite3TreeTrace to the value *ptr - ** op==3 Store the current sqlite3WhereTrace in *ptr + ** op==2 Store the current sqlite3WhereTrace in *ptr ** op==3 Set sqlite3WhereTrace to the value *ptr */ case SQLITE_TESTCTRL_TRACEFLAGS: { @@ -179371,6 +180861,23 @@ SQLITE_API int sqlite3_test_control(int op, ...){ break; } +#if !defined(SQLITE_OMIT_WSD) + /* sqlite3_test_control(SQLITE_TESTCTRL_USELONGDOUBLE, int X); + ** + ** X<0 Make no changes to the bUseLongDouble. Just report value. + ** X==0 Disable bUseLongDouble + ** X==1 Enable bUseLongDouble + ** X==2 Set bUseLongDouble to its default value for this platform + */ + case SQLITE_TESTCTRL_USELONGDOUBLE: { + int b = va_arg(ap, int); + if( b==2 ) b = sizeof(LONGDOUBLE_TYPE)>8; + if( b>=0 ) sqlite3Config.bUseLongDouble = b>0; + rc = sqlite3Config.bUseLongDouble!=0; + break; + } +#endif + #if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_WSD) /* sqlite3_test_control(SQLITE_TESTCTRL_TUNE, id, *piValue) @@ -179671,7 +181178,7 @@ SQLITE_API int sqlite3_snapshot_get( } /* -** Open a read-transaction on the snapshot idendified by pSnapshot. +** Open a read-transaction on the snapshot identified by pSnapshot. */ SQLITE_API int sqlite3_snapshot_open( sqlite3 *db, @@ -195706,6 +197213,7 @@ static int fts3IncrmergeLoad( for(i=nHeight; i>=0 && rc==SQLITE_OK; i--){ NodeReader reader; + memset(&reader, 0, sizeof(reader)); pNode = &pWriter->aNodeWriter[i]; if( pNode->block.a){ @@ -199752,25 +201260,51 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeFold(int c, int eRemoveDiacritic){ ** increase for the parser. (Ubuntu14.10 gcc 4.8.4 x64 with -Os). */ static const char jsonIsSpace[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; #define fast_isspace(x) (jsonIsSpace[(unsigned char)x]) +/* +** Characters that are special to JSON. Control charaters, +** '"' and '\\'. +*/ +static const char jsonIsOk[256] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 +}; + + #if !defined(SQLITE_DEBUG) && !defined(SQLITE_COVERAGE_TEST) # define VVA(X) #else @@ -199781,6 +201315,7 @@ static const char jsonIsSpace[] = { typedef struct JsonString JsonString; typedef struct JsonNode JsonNode; typedef struct JsonParse JsonParse; +typedef struct JsonCleanup JsonCleanup; /* An instance of this object represents a JSON string ** under construction. Really, this is a generic string accumulator @@ -199796,16 +201331,26 @@ struct JsonString { char zSpace[100]; /* Initial static space */ }; +/* A deferred cleanup task. A list of JsonCleanup objects might be +** run when the JsonParse object is destroyed. +*/ +struct JsonCleanup { + JsonCleanup *pJCNext; /* Next in a list */ + void (*xOp)(void*); /* Routine to run */ + void *pArg; /* Argument to xOp() */ +}; + /* JSON type values */ -#define JSON_NULL 0 -#define JSON_TRUE 1 -#define JSON_FALSE 2 -#define JSON_INT 3 -#define JSON_REAL 4 -#define JSON_STRING 5 -#define JSON_ARRAY 6 -#define JSON_OBJECT 7 +#define JSON_SUBST 0 /* Special edit node. Uses u.iPrev */ +#define JSON_NULL 1 +#define JSON_TRUE 2 +#define JSON_FALSE 3 +#define JSON_INT 4 +#define JSON_REAL 5 +#define JSON_STRING 6 +#define JSON_ARRAY 7 +#define JSON_OBJECT 8 /* The "subtype" set for JSON values */ #define JSON_SUBTYPE 74 /* Ascii for "J" */ @@ -199814,52 +201359,87 @@ struct JsonString { ** Names of the various JSON types: */ static const char * const jsonType[] = { + "subst", "null", "true", "false", "integer", "real", "text", "array", "object" }; /* Bit values for the JsonNode.jnFlag field */ -#define JNODE_RAW 0x01 /* Content is raw, not JSON encoded */ -#define JNODE_ESCAPE 0x02 /* Content is text with \ escapes */ -#define JNODE_REMOVE 0x04 /* Do not output */ -#define JNODE_REPLACE 0x08 /* Replace with JsonNode.u.iReplace */ -#define JNODE_PATCH 0x10 /* Patch with JsonNode.u.pPatch */ -#define JNODE_APPEND 0x20 /* More ARRAY/OBJECT entries at u.iAppend */ -#define JNODE_LABEL 0x40 /* Is a label of an object */ -#define JNODE_JSON5 0x80 /* Node contains JSON5 enhancements */ +#define JNODE_RAW 0x01 /* Content is raw, not JSON encoded */ +#define JNODE_ESCAPE 0x02 /* Content is text with \ escapes */ +#define JNODE_REMOVE 0x04 /* Do not output */ +#define JNODE_REPLACE 0x08 /* Target of a JSON_SUBST node */ +#define JNODE_APPEND 0x10 /* More ARRAY/OBJECT entries at u.iAppend */ +#define JNODE_LABEL 0x20 /* Is a label of an object */ +#define JNODE_JSON5 0x40 /* Node contains JSON5 enhancements */ -/* A single node of parsed JSON +/* A single node of parsed JSON. An array of these nodes describes +** a parse of JSON + edits. +** +** Use the json_parse() SQL function (available when compiled with +** -DSQLITE_DEBUG) to see a dump of complete JsonParse objects, including +** a complete listing and decoding of the array of JsonNodes. */ struct JsonNode { u8 eType; /* One of the JSON_ type values */ u8 jnFlags; /* JNODE flags */ u8 eU; /* Which union element to use */ - u32 n; /* Bytes of content, or number of sub-nodes */ + u32 n; /* Bytes of content for INT, REAL or STRING + ** Number of sub-nodes for ARRAY and OBJECT + ** Node that SUBST applies to */ union { const char *zJContent; /* 1: Content for INT, REAL, and STRING */ u32 iAppend; /* 2: More terms for ARRAY and OBJECT */ u32 iKey; /* 3: Key for ARRAY objects in json_tree() */ - u32 iReplace; /* 4: Replacement content for JNODE_REPLACE */ - JsonNode *pPatch; /* 5: Node chain of patch for JNODE_PATCH */ + u32 iPrev; /* 4: Previous SUBST node, or 0 */ } u; }; -/* A completely parsed JSON string + +/* A parsed and possibly edited JSON string. Lifecycle: +** +** 1. JSON comes in and is parsed into an array aNode[]. The original +** JSON text is stored in zJson. +** +** 2. Zero or more changes are made (via json_remove() or json_replace() +** or similar) to the aNode[] array. +** +** 3. A new, edited and mimified JSON string is generated from aNode +** and stored in zAlt. The JsonParse object always owns zAlt. +** +** Step 1 always happens. Step 2 and 3 may or may not happen, depending +** on the operation. +** +** aNode[].u.zJContent entries typically point into zJson. Hence zJson +** must remain valid for the lifespan of the parse. For edits, +** aNode[].u.zJContent might point to malloced space other than zJson. +** Entries in pClup are responsible for freeing that extra malloced space. +** +** When walking the parse tree in aNode[], edits are ignored if useMod is +** false. */ struct JsonParse { u32 nNode; /* Number of slots of aNode[] used */ u32 nAlloc; /* Number of slots of aNode[] allocated */ JsonNode *aNode; /* Array of nodes containing the parse */ - const char *zJson; /* Original JSON string */ + char *zJson; /* Original JSON string (before edits) */ + char *zAlt; /* Revised and/or mimified JSON */ u32 *aUp; /* Index of parent of each node */ + JsonCleanup *pClup;/* Cleanup operations prior to freeing this object */ u16 iDepth; /* Nesting depth */ u8 nErr; /* Number of errors seen */ u8 oom; /* Set to true if out of memory */ + u8 bJsonIsRCStr; /* True if zJson is an RCStr */ u8 hasNonstd; /* True if input uses non-standard features like JSON5 */ + u8 useMod; /* Actually use the edits contain inside aNode */ + u8 hasMod; /* aNode contains edits from the original zJson */ + u32 nJPRef; /* Number of references to this object */ int nJson; /* Length of the zJson string in bytes */ + int nAlt; /* Length of alternative JSON string zAlt, in bytes */ u32 iErr; /* Error location in zJson[] */ - u32 iHold; /* Replace cache line with the lowest iHold value */ + u32 iSubst; /* Last JSON_SUBST entry in aNode[] */ + u32 iHold; /* Age of this entry in the cache for LRU replacement */ }; /* @@ -199892,16 +201472,14 @@ static void jsonInit(JsonString *p, sqlite3_context *pCtx){ jsonZero(p); } - /* Free all allocated memory and reset the JsonString object back to its ** initial state. */ static void jsonReset(JsonString *p){ - if( !p->bStatic ) sqlite3_free(p->zBuf); + if( !p->bStatic ) sqlite3RCStrUnref(p->zBuf); jsonZero(p); } - /* Report an out-of-memory (OOM) condition */ static void jsonOom(JsonString *p){ @@ -199918,7 +201496,7 @@ static int jsonGrow(JsonString *p, u32 N){ char *zNew; if( p->bStatic ){ if( p->bErr ) return 1; - zNew = sqlite3_malloc64(nTotal); + zNew = sqlite3RCStrNew(nTotal); if( zNew==0 ){ jsonOom(p); return SQLITE_NOMEM; @@ -199927,12 +201505,12 @@ static int jsonGrow(JsonString *p, u32 N){ p->zBuf = zNew; p->bStatic = 0; }else{ - zNew = sqlite3_realloc64(p->zBuf, nTotal); - if( zNew==0 ){ - jsonOom(p); + p->zBuf = sqlite3RCStrResize(p->zBuf, nTotal); + if( p->zBuf==0 ){ + p->bErr = 1; + jsonZero(p); return SQLITE_NOMEM; } - p->zBuf = zNew; } p->nAlloc = nTotal; return SQLITE_OK; @@ -199940,12 +201518,35 @@ static int jsonGrow(JsonString *p, u32 N){ /* Append N bytes from zIn onto the end of the JsonString string. */ -static void jsonAppendRaw(JsonString *p, const char *zIn, u32 N){ - if( N==0 ) return; - if( (N+p->nUsed >= p->nAlloc) && jsonGrow(p,N)!=0 ) return; +static SQLITE_NOINLINE void jsonAppendExpand( + JsonString *p, + const char *zIn, + u32 N +){ + assert( N>0 ); + if( jsonGrow(p,N) ) return; memcpy(p->zBuf+p->nUsed, zIn, N); p->nUsed += N; } +static void jsonAppendRaw(JsonString *p, const char *zIn, u32 N){ + if( N==0 ) return; + if( N+p->nUsed >= p->nAlloc ){ + jsonAppendExpand(p,zIn,N); + }else{ + memcpy(p->zBuf+p->nUsed, zIn, N); + p->nUsed += N; + } +} +static void jsonAppendRawNZ(JsonString *p, const char *zIn, u32 N){ + assert( N>0 ); + if( N+p->nUsed >= p->nAlloc ){ + jsonAppendExpand(p,zIn,N); + }else{ + memcpy(p->zBuf+p->nUsed, zIn, N); + p->nUsed += N; + } +} + /* Append formatted text (not to exceed N bytes) to the JsonString. */ @@ -199960,10 +201561,35 @@ static void jsonPrintf(int N, JsonString *p, const char *zFormat, ...){ /* Append a single character */ -static void jsonAppendChar(JsonString *p, char c){ - if( p->nUsed>=p->nAlloc && jsonGrow(p,1)!=0 ) return; +static SQLITE_NOINLINE void jsonAppendCharExpand(JsonString *p, char c){ + if( jsonGrow(p,1) ) return; p->zBuf[p->nUsed++] = c; } +static void jsonAppendChar(JsonString *p, char c){ + if( p->nUsed>=p->nAlloc ){ + jsonAppendCharExpand(p,c); + }else{ + p->zBuf[p->nUsed++] = c; + } +} + +/* Try to force the string to be a zero-terminated RCStr string. +** +** Return true on success. Return false if an OOM prevents this +** from happening. +*/ +static int jsonForceRCStr(JsonString *p){ + jsonAppendChar(p, 0); + if( p->bErr ) return 0; + p->nUsed--; + if( p->bStatic==0 ) return 1; + p->nAlloc = 0; + p->nUsed++; + jsonGrow(p, p->nUsed); + p->nUsed--; + return p->bStatic==0; +} + /* Append a comma separator to the output buffer, if the previous ** character is not '[' or '{'. @@ -199972,7 +201598,8 @@ static void jsonAppendSeparator(JsonString *p){ char c; if( p->nUsed==0 ) return; c = p->zBuf[p->nUsed-1]; - if( c!='[' && c!='{' ) jsonAppendChar(p, ','); + if( c=='[' || c=='{' ) return; + jsonAppendChar(p, ','); } /* Append the N-byte string in zIn to the end of the JsonString string @@ -199986,11 +201613,16 @@ static void jsonAppendString(JsonString *p, const char *zIn, u32 N){ p->zBuf[p->nUsed++] = '"'; for(i=0; izBuf[p->nUsed++] = c; + }else if( c=='"' || c=='\\' ){ json_simple_escape: if( (p->nUsed+N+3-i > p->nAlloc) && jsonGrow(p,N+3-i)!=0 ) return; p->zBuf[p->nUsed++] = '\\'; - }else if( c<=0x1f ){ + p->zBuf[p->nUsed++] = c; + }else if( c=='\'' ){ + p->zBuf[p->nUsed++] = c; + }else{ static const char aSpecial[] = { 0, 0, 0, 0, 0, 0, 0, 0, 'b', 't', 'n', 0, 'f', 'r', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 @@ -200001,6 +201633,7 @@ static void jsonAppendString(JsonString *p, const char *zIn, u32 N){ assert( aSpecial['\n']=='n' ); assert( aSpecial['\r']=='r' ); assert( aSpecial['\t']=='t' ); + assert( c>=0 && czBuf[p->nUsed++] = 'u'; p->zBuf[p->nUsed++] = '0'; p->zBuf[p->nUsed++] = '0'; - p->zBuf[p->nUsed++] = '0' + (c>>4); - c = "0123456789abcdef"[c&0xf]; + p->zBuf[p->nUsed++] = "0123456789abcdef"[c>>4]; + p->zBuf[p->nUsed++] = "0123456789abcdef"[c&0xf]; } - p->zBuf[p->nUsed++] = c; } p->zBuf[p->nUsed++] = '"'; assert( p->nUsednAlloc ); @@ -200032,7 +201664,7 @@ static void jsonAppendNormalizedString(JsonString *p, const char *zIn, u32 N){ while( N>0 ){ for(i=0; i0 ){ - jsonAppendRaw(p, zIn, i); + jsonAppendRawNZ(p, zIn, i); zIn += i; N -= i; if( N==0 ) break; @@ -200043,16 +201675,16 @@ static void jsonAppendNormalizedString(JsonString *p, const char *zIn, u32 N){ jsonAppendChar(p, '\''); break; case 'v': - jsonAppendRaw(p, "\\u0009", 6); + jsonAppendRawNZ(p, "\\u0009", 6); break; case 'x': - jsonAppendRaw(p, "\\u00", 4); - jsonAppendRaw(p, &zIn[2], 2); + jsonAppendRawNZ(p, "\\u00", 4); + jsonAppendRawNZ(p, &zIn[2], 2); zIn += 2; N -= 2; break; case '0': - jsonAppendRaw(p, "\\u0000", 6); + jsonAppendRawNZ(p, "\\u0000", 6); break; case '\r': if( zIn[2]=='\n' ){ @@ -200070,7 +201702,7 @@ static void jsonAppendNormalizedString(JsonString *p, const char *zIn, u32 N){ N -= 2; break; default: - jsonAppendRaw(p, zIn, 2); + jsonAppendRawNZ(p, zIn, 2); break; } zIn += 2; @@ -200100,11 +201732,12 @@ static void jsonAppendNormalizedInt(JsonString *p, const char *zIn, u32 N){ jsonPrintf(100,p,"%lld",i); }else{ assert( rc==2 ); - jsonAppendRaw(p, "9.0e999", 7); + jsonAppendRawNZ(p, "9.0e999", 7); } return; } - jsonAppendRaw(p, zIn, N); + assert( N>0 ); + jsonAppendRawNZ(p, zIn, N); } /* @@ -200136,7 +201769,7 @@ static void jsonAppendNormalizedReal(JsonString *p, const char *zIn, u32 N){ } } if( N>0 ){ - jsonAppendRaw(p, zIn, N); + jsonAppendRawNZ(p, zIn, N); } } @@ -200152,7 +201785,7 @@ static void jsonAppendValue( ){ switch( sqlite3_value_type(pValue) ){ case SQLITE_NULL: { - jsonAppendRaw(p, "null", 4); + jsonAppendRawNZ(p, "null", 4); break; } case SQLITE_FLOAT: { @@ -200188,15 +201821,25 @@ static void jsonAppendValue( /* Make the JSON in p the result of the SQL function. +** +** The JSON string is reset. */ static void jsonResult(JsonString *p){ if( p->bErr==0 ){ - sqlite3_result_text64(p->pCtx, p->zBuf, p->nUsed, - p->bStatic ? SQLITE_TRANSIENT : sqlite3_free, - SQLITE_UTF8); - jsonZero(p); + if( p->bStatic ){ + sqlite3_result_text64(p->pCtx, p->zBuf, p->nUsed, + SQLITE_TRANSIENT, SQLITE_UTF8); + }else if( jsonForceRCStr(p) ){ + sqlite3RCStrRef(p->zBuf); + sqlite3_result_text64(p->pCtx, p->zBuf, p->nUsed, + (void(*)(void*))sqlite3RCStrUnref, + SQLITE_UTF8); + } } - assert( p->bStatic ); + if( p->bErr==1 ){ + sqlite3_result_error_nomem(p->pCtx); + } + jsonReset(p); } /************************************************************************** @@ -200221,20 +201864,73 @@ static u32 jsonNodeSize(JsonNode *pNode){ ** delete the JsonParse object itself. */ static void jsonParseReset(JsonParse *pParse){ - sqlite3_free(pParse->aNode); - pParse->aNode = 0; + while( pParse->pClup ){ + JsonCleanup *pTask = pParse->pClup; + pParse->pClup = pTask->pJCNext; + pTask->xOp(pTask->pArg); + sqlite3_free(pTask); + } + assert( pParse->nJPRef<=1 ); + if( pParse->aNode ){ + sqlite3_free(pParse->aNode); + pParse->aNode = 0; + } pParse->nNode = 0; pParse->nAlloc = 0; - sqlite3_free(pParse->aUp); - pParse->aUp = 0; + if( pParse->aUp ){ + sqlite3_free(pParse->aUp); + pParse->aUp = 0; + } + if( pParse->bJsonIsRCStr ){ + sqlite3RCStrUnref(pParse->zJson); + pParse->zJson = 0; + pParse->bJsonIsRCStr = 0; + } + if( pParse->zAlt ){ + sqlite3RCStrUnref(pParse->zAlt); + pParse->zAlt = 0; + } } /* ** Free a JsonParse object that was obtained from sqlite3_malloc(). +** +** Note that destroying JsonParse might call sqlite3RCStrUnref() to +** destroy the zJson value. The RCStr object might recursively invoke +** JsonParse to destroy this pParse object again. Take care to ensure +** that this recursive destructor sequence terminates harmlessly. */ static void jsonParseFree(JsonParse *pParse){ - jsonParseReset(pParse); - sqlite3_free(pParse); + if( pParse->nJPRef>1 ){ + pParse->nJPRef--; + }else{ + jsonParseReset(pParse); + sqlite3_free(pParse); + } +} + +/* +** Add a cleanup task to the JsonParse object. +** +** If an OOM occurs, the cleanup operation happens immediately +** and this function returns SQLITE_NOMEM. +*/ +static int jsonParseAddCleanup( + JsonParse *pParse, /* Add the cleanup task to this parser */ + void(*xOp)(void*), /* The cleanup task */ + void *pArg /* Argument to the cleanup */ +){ + JsonCleanup *pTask = sqlite3_malloc64( sizeof(*pTask) ); + if( pTask==0 ){ + pParse->oom = 1; + xOp(pArg); + return SQLITE_ERROR; + } + pTask->pJCNext = pParse->pClup; + pParse->pClup = pTask; + pTask->xOp = xOp; + pTask->pArg = pArg; + return SQLITE_OK; } /* @@ -200243,32 +201939,38 @@ static void jsonParseFree(JsonParse *pParse){ ** the number of JsonNode objects that are encoded. */ static void jsonRenderNode( + JsonParse *pParse, /* the complete parse of the JSON */ JsonNode *pNode, /* The node to render */ - JsonString *pOut, /* Write JSON here */ - sqlite3_value **aReplace /* Replacement values */ + JsonString *pOut /* Write JSON here */ ){ assert( pNode!=0 ); - if( pNode->jnFlags & (JNODE_REPLACE|JNODE_PATCH) ){ - if( (pNode->jnFlags & JNODE_REPLACE)!=0 && ALWAYS(aReplace!=0) ){ - assert( pNode->eU==4 ); - jsonAppendValue(pOut, aReplace[pNode->u.iReplace]); - return; + while( (pNode->jnFlags & JNODE_REPLACE)!=0 && pParse->useMod ){ + u32 idx = (u32)(pNode - pParse->aNode); + u32 i = pParse->iSubst; + while( 1 /*exit-by-break*/ ){ + assert( inNode ); + assert( pParse->aNode[i].eType==JSON_SUBST ); + assert( pParse->aNode[i].eU==4 ); + assert( pParse->aNode[i].u.iPrevaNode[i].n==idx ){ + pNode = &pParse->aNode[i+1]; + break; + } + i = pParse->aNode[i].u.iPrev; } - assert( pNode->eU==5 ); - pNode = pNode->u.pPatch; } switch( pNode->eType ){ default: { assert( pNode->eType==JSON_NULL ); - jsonAppendRaw(pOut, "null", 4); + jsonAppendRawNZ(pOut, "null", 4); break; } case JSON_TRUE: { - jsonAppendRaw(pOut, "true", 4); + jsonAppendRawNZ(pOut, "true", 4); break; } case JSON_FALSE: { - jsonAppendRaw(pOut, "false", 5); + jsonAppendRawNZ(pOut, "false", 5); break; } case JSON_STRING: { @@ -200284,7 +201986,8 @@ static void jsonRenderNode( }else if( pNode->jnFlags & JNODE_JSON5 ){ jsonAppendNormalizedString(pOut, pNode->u.zJContent, pNode->n); }else{ - jsonAppendRaw(pOut, pNode->u.zJContent, pNode->n); + assert( pNode->n>0 ); + jsonAppendRawNZ(pOut, pNode->u.zJContent, pNode->n); } break; } @@ -200293,7 +201996,8 @@ static void jsonRenderNode( if( pNode->jnFlags & JNODE_JSON5 ){ jsonAppendNormalizedReal(pOut, pNode->u.zJContent, pNode->n); }else{ - jsonAppendRaw(pOut, pNode->u.zJContent, pNode->n); + assert( pNode->n>0 ); + jsonAppendRawNZ(pOut, pNode->u.zJContent, pNode->n); } break; } @@ -200302,7 +202006,8 @@ static void jsonRenderNode( if( pNode->jnFlags & JNODE_JSON5 ){ jsonAppendNormalizedInt(pOut, pNode->u.zJContent, pNode->n); }else{ - jsonAppendRaw(pOut, pNode->u.zJContent, pNode->n); + assert( pNode->n>0 ); + jsonAppendRawNZ(pOut, pNode->u.zJContent, pNode->n); } break; } @@ -200311,15 +202016,16 @@ static void jsonRenderNode( jsonAppendChar(pOut, '['); for(;;){ while( j<=pNode->n ){ - if( (pNode[j].jnFlags & JNODE_REMOVE)==0 ){ + if( (pNode[j].jnFlags & JNODE_REMOVE)==0 || pParse->useMod==0 ){ jsonAppendSeparator(pOut); - jsonRenderNode(&pNode[j], pOut, aReplace); + jsonRenderNode(pParse, &pNode[j], pOut); } j += jsonNodeSize(&pNode[j]); } if( (pNode->jnFlags & JNODE_APPEND)==0 ) break; + if( pParse->useMod==0 ) break; assert( pNode->eU==2 ); - pNode = &pNode[pNode->u.iAppend]; + pNode = &pParse->aNode[pNode->u.iAppend]; j = 1; } jsonAppendChar(pOut, ']'); @@ -200330,17 +202036,18 @@ static void jsonRenderNode( jsonAppendChar(pOut, '{'); for(;;){ while( j<=pNode->n ){ - if( (pNode[j+1].jnFlags & JNODE_REMOVE)==0 ){ + if( (pNode[j+1].jnFlags & JNODE_REMOVE)==0 || pParse->useMod==0 ){ jsonAppendSeparator(pOut); - jsonRenderNode(&pNode[j], pOut, aReplace); + jsonRenderNode(pParse, &pNode[j], pOut); jsonAppendChar(pOut, ':'); - jsonRenderNode(&pNode[j+1], pOut, aReplace); + jsonRenderNode(pParse, &pNode[j+1], pOut); } j += 1 + jsonNodeSize(&pNode[j+1]); } if( (pNode->jnFlags & JNODE_APPEND)==0 ) break; + if( pParse->useMod==0 ) break; assert( pNode->eU==2 ); - pNode = &pNode[pNode->u.iAppend]; + pNode = &pParse->aNode[pNode->u.iAppend]; j = 1; } jsonAppendChar(pOut, '}'); @@ -200350,18 +202057,29 @@ static void jsonRenderNode( } /* -** Return a JsonNode and all its descendents as a JSON string. +** Return a JsonNode and all its descendants as a JSON string. */ static void jsonReturnJson( + JsonParse *pParse, /* The complete JSON */ JsonNode *pNode, /* Node to return */ sqlite3_context *pCtx, /* Return value for this function */ - sqlite3_value **aReplace /* Array of replacement values */ + int bGenerateAlt /* Also store the rendered text in zAlt */ ){ JsonString s; - jsonInit(&s, pCtx); - jsonRenderNode(pNode, &s, aReplace); - jsonResult(&s); - sqlite3_result_subtype(pCtx, JSON_SUBTYPE); + if( pParse->oom ){ + sqlite3_result_error_nomem(pCtx); + return; + } + if( pParse->nErr==0 ){ + jsonInit(&s, pCtx); + jsonRenderNode(pParse, pNode, &s); + if( bGenerateAlt && pParse->zAlt==0 && jsonForceRCStr(&s) ){ + pParse->zAlt = sqlite3RCStrRef(s.zBuf); + pParse->nAlt = s.nUsed; + } + jsonResult(&s); + sqlite3_result_subtype(pCtx, JSON_SUBTYPE); + } } /* @@ -200399,9 +202117,9 @@ static u32 jsonHexToInt4(const char *z){ ** Make the JsonNode the return value of the function. */ static void jsonReturn( + JsonParse *pParse, /* Complete JSON parse tree */ JsonNode *pNode, /* Node to return */ - sqlite3_context *pCtx, /* Return value for this function */ - sqlite3_value **aReplace /* Array of replacement values */ + sqlite3_context *pCtx /* Return value for this function */ ){ switch( pNode->eType ){ default: { @@ -200423,7 +202141,6 @@ static void jsonReturn( int bNeg = 0; const char *z; - assert( pNode->eU==1 ); z = pNode->u.zJContent; if( z[0]=='-' ){ z++; bNeg = 1; } @@ -200548,7 +202265,7 @@ static void jsonReturn( } case JSON_ARRAY: case JSON_OBJECT: { - jsonReturnJson(pNode, pCtx, aReplace); + jsonReturnJson(pParse, pNode, pCtx, 0); break; } } @@ -200570,6 +202287,12 @@ static int jsonParseAddNode(JsonParse*,u32,u32,const char*); #endif +/* +** Add a single node to pParse->aNode after first expanding the +** size of the aNode array. Return the index of the new node. +** +** If an OOM error occurs, set pParse->oom and return -1. +*/ static JSON_NOINLINE int jsonParseAddNodeExpand( JsonParse *pParse, /* Append the node to this object */ u32 eType, /* Node type */ @@ -200586,7 +202309,7 @@ static JSON_NOINLINE int jsonParseAddNodeExpand( pParse->oom = 1; return -1; } - pParse->nAlloc = nNew; + pParse->nAlloc = sqlite3_msize(pNew)/sizeof(JsonNode); pParse->aNode = pNew; assert( pParse->nNodenAlloc ); return jsonParseAddNode(pParse, eType, n, zContent); @@ -200604,10 +202327,13 @@ static int jsonParseAddNode( const char *zContent /* Content */ ){ JsonNode *p; - if( pParse->aNode==0 || pParse->nNode>=pParse->nAlloc ){ + assert( pParse->aNode!=0 || pParse->nNode>=pParse->nAlloc ); + if( pParse->nNode>=pParse->nAlloc ){ return jsonParseAddNodeExpand(pParse, eType, n, zContent); } + assert( pParse->aNode!=0 ); p = &pParse->aNode[pParse->nNode]; + assert( p!=0 ); p->eType = (u8)(eType & 0xff); p->jnFlags = (u8)(eType >> 8); VVA( p->eU = zContent ? 1 : 0 ); @@ -200616,6 +202342,52 @@ static int jsonParseAddNode( return pParse->nNode++; } +/* +** Add an array of new nodes to the current pParse->aNode array. +** Return the index of the first node added. +** +** If an OOM error occurs, set pParse->oom. +*/ +static void jsonParseAddNodeArray( + JsonParse *pParse, /* Append the node to this object */ + JsonNode *aNode, /* Array of nodes to add */ + u32 nNode /* Number of elements in aNew */ +){ + assert( aNode!=0 ); + assert( nNode>=1 ); + if( pParse->nNode + nNode > pParse->nAlloc ){ + u32 nNew = pParse->nNode + nNode; + JsonNode *aNew = sqlite3_realloc64(pParse->aNode, nNew*sizeof(JsonNode)); + if( aNew==0 ){ + pParse->oom = 1; + return; + } + pParse->nAlloc = sqlite3_msize(aNew)/sizeof(JsonNode); + pParse->aNode = aNew; + } + memcpy(&pParse->aNode[pParse->nNode], aNode, nNode*sizeof(JsonNode)); + pParse->nNode += nNode; +} + +/* +** Add a new JSON_SUBST node. The node immediately following +** this new node will be the substitute content for iNode. +*/ +static int jsonParseAddSubstNode( + JsonParse *pParse, /* Add the JSON_SUBST here */ + u32 iNode /* References this node */ +){ + int idx = jsonParseAddNode(pParse, JSON_SUBST, iNode, 0); + if( pParse->oom ) return -1; + pParse->aNode[iNode].jnFlags |= JNODE_REPLACE; + pParse->aNode[idx].eU = 4; + pParse->aNode[idx].u.iPrev = pParse->iSubst; + pParse->iSubst = idx; + pParse->hasMod = 1; + pParse->useMod = 1; + return idx; +} + /* ** Return true if z[] begins with 2 (or more) hexadecimal digits */ @@ -200782,7 +202554,7 @@ static const struct NanInfName { ** ** Special return values: ** -** 0 End if input +** 0 End of input ** -1 Syntax error ** -2 '}' seen ** -3 ']' seen @@ -200957,15 +202729,12 @@ json_parse_restart: jnFlags = 0; parse_string: cDelim = z[i]; - j = i+1; - for(;;){ + for(j=i+1; 1; j++){ + if( jsonIsOk[(unsigned char)z[j]] ) continue; c = z[j]; - if( (c & ~0x1f)==0 ){ - /* Control characters are not allowed in strings */ - pParse->iErr = j; - return -1; - } - if( c=='\\' ){ + if( c==cDelim ){ + break; + }else if( c=='\\' ){ c = z[++j]; if( c=='"' || c=='\\' || c=='/' || c=='b' || c=='f' || c=='n' || c=='r' || c=='t' @@ -200985,10 +202754,11 @@ json_parse_restart: pParse->iErr = j; return -1; } - }else if( c==cDelim ){ - break; + }else if( c<=0x1f ){ + /* Control characters are not allowed in strings */ + pParse->iErr = j; + return -1; } - j++; } jsonParseAddNode(pParse, JSON_STRING | (jnFlags<<8), j+1-i, &z[i]); return j+1; @@ -201224,20 +202994,18 @@ json_parse_restart: /* ** Parse a complete JSON string. Return 0 on success or non-zero if there -** are any errors. If an error occurs, free all memory associated with -** pParse. +** are any errors. If an error occurs, free all memory held by pParse, +** but not pParse itself. ** -** pParse is uninitialized when this routine is called. +** pParse must be initialized to an empty parse object prior to calling +** this routine. */ static int jsonParse( JsonParse *pParse, /* Initialize and fill this JsonParse object */ - sqlite3_context *pCtx, /* Report errors here */ - const char *zJson /* Input JSON text to be parsed */ + sqlite3_context *pCtx /* Report errors here */ ){ int i; - memset(pParse, 0, sizeof(*pParse)); - if( zJson==0 ) return 1; - pParse->zJson = zJson; + const char *zJson = pParse->zJson; i = jsonParseValue(pParse, 0); if( pParse->oom ) i = -1; if( i>0 ){ @@ -201266,6 +203034,7 @@ static int jsonParse( return 0; } + /* Mark node i of pParse as being a child of iParent. Call recursively ** to fill in all the descendants of node i. */ @@ -201315,35 +203084,49 @@ static int jsonParseFindParents(JsonParse *pParse){ #define JSON_CACHE_SZ 4 /* Max number of cache entries */ /* -** Obtain a complete parse of the JSON found in the first argument -** of the argv array. Use the sqlite3_get_auxdata() cache for this -** parse if it is available. If the cache is not available or if it -** is no longer valid, parse the JSON again and return the new parse, -** and also register the new parse so that it will be available for +** Obtain a complete parse of the JSON found in the pJson argument +** +** Use the sqlite3_get_auxdata() cache to find a preexisting parse +** if it is available. If the cache is not available or if it +** is no longer valid, parse the JSON again and return the new parse. +** Also register the new parse so that it will be available for ** future sqlite3_get_auxdata() calls. ** ** If an error occurs and pErrCtx!=0 then report the error on pErrCtx ** and return NULL. ** -** If an error occurs and pErrCtx==0 then return the Parse object with -** JsonParse.nErr non-zero. If the caller invokes this routine with -** pErrCtx==0 and it gets back a JsonParse with nErr!=0, then the caller -** is responsible for invoking jsonParseFree() on the returned value. -** But the caller may invoke jsonParseFree() *only* if pParse->nErr!=0. +** The returned pointer (if it is not NULL) is owned by the cache in +** most cases, not the caller. The caller does NOT need to invoke +** jsonParseFree(), in most cases. +** +** Except, if an error occurs and pErrCtx==0 then return the JsonParse +** object with JsonParse.nErr non-zero and the caller will own the JsonParse +** object. In that case, it will be the responsibility of the caller to +** invoke jsonParseFree(). To summarize: +** +** pErrCtx!=0 || p->nErr==0 ==> Return value p is owned by the +** cache. Call does not need to +** free it. +** +** pErrCtx==0 && p->nErr!=0 ==> Return value is owned by the caller +** and so the caller must free it. */ static JsonParse *jsonParseCached( - sqlite3_context *pCtx, - sqlite3_value **argv, - sqlite3_context *pErrCtx + sqlite3_context *pCtx, /* Context to use for cache search */ + sqlite3_value *pJson, /* Function param containing JSON text */ + sqlite3_context *pErrCtx, /* Write parse errors here if not NULL */ + int bUnedited /* No prior edits allowed */ ){ - const char *zJson = (const char*)sqlite3_value_text(argv[0]); - int nJson = sqlite3_value_bytes(argv[0]); + char *zJson = (char*)sqlite3_value_text(pJson); + int nJson = sqlite3_value_bytes(pJson); JsonParse *p; JsonParse *pMatch = 0; int iKey; int iMinKey = 0; u32 iMinHold = 0xffffffff; u32 iMaxHold = 0; + int bJsonRCStr; + if( zJson==0 ) return 0; for(iKey=0; iKeynJson==nJson - && memcmp(p->zJson,zJson,nJson)==0 + && (p->hasMod==0 || bUnedited==0) + && (p->zJson==zJson || memcmp(p->zJson,zJson,nJson)==0) ){ p->nErr = 0; + p->useMod = 0; + pMatch = p; + }else + if( pMatch==0 + && p->zAlt!=0 + && bUnedited==0 + && p->nAlt==nJson + && memcmp(p->zAlt, zJson, nJson)==0 + ){ + p->nErr = 0; + p->useMod = 1; pMatch = p; }else if( p->iHoldiHold; @@ -201366,28 +203161,44 @@ static JsonParse *jsonParseCached( } } if( pMatch ){ + /* The input JSON text was found in the cache. Use the preexisting + ** parse of this JSON */ pMatch->nErr = 0; pMatch->iHold = iMaxHold+1; + assert( pMatch->nJPRef>0 ); /* pMatch is owned by the cache */ return pMatch; } - p = sqlite3_malloc64( sizeof(*p) + nJson + 1 ); + + /* The input JSON was not found anywhere in the cache. We will need + ** to parse it ourselves and generate a new JsonParse object. + */ + bJsonRCStr = sqlite3ValueIsOfClass(pJson,(void(*)(void*))sqlite3RCStrUnref); + p = sqlite3_malloc64( sizeof(*p) + (bJsonRCStr ? 0 : nJson+1) ); if( p==0 ){ sqlite3_result_error_nomem(pCtx); return 0; } memset(p, 0, sizeof(*p)); - p->zJson = (char*)&p[1]; - memcpy((char*)p->zJson, zJson, nJson+1); - if( jsonParse(p, pErrCtx, p->zJson) ){ + if( bJsonRCStr ){ + p->zJson = sqlite3RCStrRef(zJson); + p->bJsonIsRCStr = 1; + }else{ + p->zJson = (char*)&p[1]; + memcpy(p->zJson, zJson, nJson+1); + } + p->nJPRef = 1; + if( jsonParse(p, pErrCtx) ){ if( pErrCtx==0 ){ p->nErr = 1; + assert( p->nJPRef==1 ); /* Caller will own the new JsonParse object p */ return p; } - sqlite3_free(p); + jsonParseFree(p); return 0; } p->nJson = nJson; p->iHold = iMaxHold+1; + /* Transfer ownership of the new JsonParse to the cache */ sqlite3_set_auxdata(pCtx, JSON_CACHE_ID+iMinKey, p, (void(*)(void*))jsonParseFree); return (JsonParse*)sqlite3_get_auxdata(pCtx, JSON_CACHE_ID+iMinKey); @@ -201438,9 +203249,31 @@ static JsonNode *jsonLookupStep( ){ u32 i, j, nKey; const char *zKey; - JsonNode *pRoot = &pParse->aNode[iRoot]; + JsonNode *pRoot; + if( pParse->oom ) return 0; + pRoot = &pParse->aNode[iRoot]; + if( pRoot->jnFlags & (JNODE_REPLACE|JNODE_REMOVE) && pParse->useMod ){ + while( (pRoot->jnFlags & JNODE_REPLACE)!=0 ){ + u32 idx = (u32)(pRoot - pParse->aNode); + i = pParse->iSubst; + while( 1 /*exit-by-break*/ ){ + assert( inNode ); + assert( pParse->aNode[i].eType==JSON_SUBST ); + assert( pParse->aNode[i].eU==4 ); + assert( pParse->aNode[i].u.iPrevaNode[i].n==idx ){ + pRoot = &pParse->aNode[i+1]; + iRoot = i+1; + break; + } + i = pParse->aNode[i].u.iPrev; + } + } + if( pRoot->jnFlags & JNODE_REMOVE ){ + return 0; + } + } if( zPath[0]==0 ) return pRoot; - if( pRoot->jnFlags & JNODE_REPLACE ) return 0; if( zPath[0]=='.' ){ if( pRoot->eType!=JSON_OBJECT ) return 0; zPath++; @@ -201474,14 +203307,16 @@ static JsonNode *jsonLookupStep( j += jsonNodeSize(&pRoot[j]); } if( (pRoot->jnFlags & JNODE_APPEND)==0 ) break; + if( pParse->useMod==0 ) break; assert( pRoot->eU==2 ); - iRoot += pRoot->u.iAppend; + iRoot = pRoot->u.iAppend; pRoot = &pParse->aNode[iRoot]; j = 1; } if( pApnd ){ u32 iStart, iLabel; JsonNode *pNode; + assert( pParse->useMod ); iStart = jsonParseAddNode(pParse, JSON_OBJECT, 2, 0); iLabel = jsonParseAddNode(pParse, JSON_STRING, nKey, zKey); zPath += i; @@ -201490,7 +203325,7 @@ static JsonNode *jsonLookupStep( if( pNode ){ pRoot = &pParse->aNode[iRoot]; assert( pRoot->eU==0 ); - pRoot->u.iAppend = iStart - iRoot; + pRoot->u.iAppend = iStart; pRoot->jnFlags |= JNODE_APPEND; VVA( pRoot->eU = 2 ); pParse->aNode[iLabel].jnFlags |= JNODE_RAW; @@ -201511,12 +203346,13 @@ static JsonNode *jsonLookupStep( if( pRoot->eType!=JSON_ARRAY ) return 0; for(;;){ while( j<=pBase->n ){ - if( (pBase[j].jnFlags & JNODE_REMOVE)==0 ) i++; + if( (pBase[j].jnFlags & JNODE_REMOVE)==0 || pParse->useMod==0 ) i++; j += jsonNodeSize(&pBase[j]); } if( (pBase->jnFlags & JNODE_APPEND)==0 ) break; + if( pParse->useMod==0 ) break; assert( pBase->eU==2 ); - iBase += pBase->u.iAppend; + iBase = pBase->u.iAppend; pBase = &pParse->aNode[iBase]; j = 1; } @@ -201544,13 +203380,16 @@ static JsonNode *jsonLookupStep( zPath += j + 1; j = 1; for(;;){ - while( j<=pRoot->n && (i>0 || (pRoot[j].jnFlags & JNODE_REMOVE)!=0) ){ - if( (pRoot[j].jnFlags & JNODE_REMOVE)==0 ) i--; + while( j<=pRoot->n + && (i>0 || ((pRoot[j].jnFlags & JNODE_REMOVE)!=0 && pParse->useMod)) + ){ + if( (pRoot[j].jnFlags & JNODE_REMOVE)==0 || pParse->useMod==0 ) i--; j += jsonNodeSize(&pRoot[j]); } if( (pRoot->jnFlags & JNODE_APPEND)==0 ) break; + if( pParse->useMod==0 ) break; assert( pRoot->eU==2 ); - iRoot += pRoot->u.iAppend; + iRoot = pRoot->u.iAppend; pRoot = &pParse->aNode[iRoot]; j = 1; } @@ -201560,13 +203399,14 @@ static JsonNode *jsonLookupStep( if( i==0 && pApnd ){ u32 iStart; JsonNode *pNode; + assert( pParse->useMod ); iStart = jsonParseAddNode(pParse, JSON_ARRAY, 1, 0); pNode = jsonLookupAppend(pParse, zPath, pApnd, pzErr); if( pParse->oom ) return 0; if( pNode ){ pRoot = &pParse->aNode[iRoot]; assert( pRoot->eU==0 ); - pRoot->u.iAppend = iStart - iRoot; + pRoot->u.iAppend = iStart; pRoot->jnFlags |= JNODE_APPEND; VVA( pRoot->eU = 2 ); } @@ -201693,47 +203533,90 @@ static void jsonRemoveAllNulls(JsonNode *pNode){ ** SQL functions used for testing and debugging ****************************************************************************/ +#if SQLITE_DEBUG +/* +** Print N node entries. +*/ +static void jsonDebugPrintNodeEntries( + JsonNode *aNode, /* First node entry to print */ + int N /* Number of node entries to print */ +){ + int i; + for(i=0; iaNode, p->nNode); +} +static void jsonDebugPrintNode(JsonNode *pNode){ + jsonDebugPrintNodeEntries(pNode, jsonNodeSize(pNode)); +} +#else + /* The usual case */ +# define jsonDebugPrintNode(X) +# define jsonDebugPrintParse(X) +#endif + #ifdef SQLITE_DEBUG /* -** The json_parse(JSON) function returns a string which describes -** a parse of the JSON provided. Or it returns NULL if JSON is not -** well-formed. +** SQL function: json_parse(JSON) +** +** Parse JSON using jsonParseCached(). Then print a dump of that +** parse on standard output. Return the mimified JSON result, just +** like the json() function. */ static void jsonParseFunc( sqlite3_context *ctx, int argc, sqlite3_value **argv ){ - JsonString s; /* Output string - not real JSON */ - JsonParse x; /* The parse */ - u32 i; + JsonParse *p; /* The parse */ assert( argc==1 ); - if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return; - jsonParseFindParents(&x); - jsonInit(&s, ctx); - for(i=0; inNode); + printf("nAlloc = %u\n", p->nAlloc); + printf("nJson = %d\n", p->nJson); + printf("nAlt = %d\n", p->nAlt); + printf("nErr = %u\n", p->nErr); + printf("oom = %u\n", p->oom); + printf("hasNonstd = %u\n", p->hasNonstd); + printf("useMod = %u\n", p->useMod); + printf("hasMod = %u\n", p->hasMod); + printf("nJPRef = %u\n", p->nJPRef); + printf("iSubst = %u\n", p->iSubst); + printf("iHold = %u\n", p->iHold); + jsonDebugPrintNodeEntries(p->aNode, p->nNode); + jsonReturnJson(p, p->aNode, ctx, 1); } /* @@ -201817,7 +203700,7 @@ static void jsonArrayLengthFunc( u32 i; JsonNode *pNode; - p = jsonParseCached(ctx, argv, ctx); + p = jsonParseCached(ctx, argv[0], ctx, 0); if( p==0 ) return; assert( p->nNode ); if( argc==2 ){ @@ -201830,9 +203713,14 @@ static void jsonArrayLengthFunc( return; } if( pNode->eType==JSON_ARRAY ){ - assert( (pNode->jnFlags & JNODE_APPEND)==0 ); - for(i=1; i<=pNode->n; n++){ - i += jsonNodeSize(&pNode[i]); + while( 1 /*exit-by-break*/ ){ + for(i=1; i<=pNode->n; n++){ + i += jsonNodeSize(&pNode[i]); + } + if( (pNode->jnFlags & JNODE_APPEND)==0 ) break; + if( p->useMod==0 ) break; + assert( pNode->eU==2 ); + pNode = &p->aNode[pNode->u.iAppend]; } } sqlite3_result_int64(ctx, n); @@ -201879,7 +203767,7 @@ static void jsonExtractFunc( JsonString jx; if( argc<2 ) return; - p = jsonParseCached(ctx, argv, ctx); + p = jsonParseCached(ctx, argv[0], ctx, 0); if( p==0 ) return; if( argc==2 ){ /* With a single PATH argument */ @@ -201897,11 +203785,11 @@ static void jsonExtractFunc( */ jsonInit(&jx, ctx); if( sqlite3Isdigit(zPath[0]) ){ - jsonAppendRaw(&jx, "$[", 2); + jsonAppendRawNZ(&jx, "$[", 2); jsonAppendRaw(&jx, zPath, (int)strlen(zPath)); - jsonAppendRaw(&jx, "]", 2); + jsonAppendRawNZ(&jx, "]", 2); }else{ - jsonAppendRaw(&jx, "$.", 1 + (zPath[0]!='[')); + jsonAppendRawNZ(&jx, "$.", 1 + (zPath[0]!='[')); jsonAppendRaw(&jx, zPath, (int)strlen(zPath)); jsonAppendChar(&jx, 0); } @@ -201912,15 +203800,15 @@ static void jsonExtractFunc( } if( pNode ){ if( flags & JSON_JSON ){ - jsonReturnJson(pNode, ctx, 0); + jsonReturnJson(p, pNode, ctx, 0); }else{ - jsonReturn(pNode, ctx, 0); + jsonReturn(p, pNode, ctx); sqlite3_result_subtype(ctx, 0); } } }else{ pNode = jsonLookup(p, zPath, 0, ctx); - if( p->nErr==0 && pNode ) jsonReturn(pNode, ctx, 0); + if( p->nErr==0 && pNode ) jsonReturn(p, pNode, ctx); } }else{ /* Two or more PATH arguments results in a JSON array with each @@ -201934,9 +203822,9 @@ static void jsonExtractFunc( if( p->nErr ) break; jsonAppendSeparator(&jx); if( pNode ){ - jsonRenderNode(pNode, &jx, 0); + jsonRenderNode(p, pNode, &jx); }else{ - jsonAppendRaw(&jx, "null", 4); + jsonAppendRawNZ(&jx, "null", 4); } } if( i==argc ){ @@ -201981,45 +203869,38 @@ static JsonNode *jsonMergePatch( assert( pTarget[j].eType==JSON_STRING ); assert( pTarget[j].jnFlags & JNODE_LABEL ); if( jsonSameLabel(&pPatch[i], &pTarget[j]) ){ - if( pTarget[j+1].jnFlags & (JNODE_REMOVE|JNODE_PATCH) ) break; + if( pTarget[j+1].jnFlags & (JNODE_REMOVE|JNODE_REPLACE) ) break; if( pPatch[i+1].eType==JSON_NULL ){ pTarget[j+1].jnFlags |= JNODE_REMOVE; }else{ JsonNode *pNew = jsonMergePatch(pParse, iTarget+j+1, &pPatch[i+1]); if( pNew==0 ) return 0; - pTarget = &pParse->aNode[iTarget]; - if( pNew!=&pTarget[j+1] ){ - assert( pTarget[j+1].eU==0 - || pTarget[j+1].eU==1 - || pTarget[j+1].eU==2 ); - testcase( pTarget[j+1].eU==1 ); - testcase( pTarget[j+1].eU==2 ); - VVA( pTarget[j+1].eU = 5 ); - pTarget[j+1].u.pPatch = pNew; - pTarget[j+1].jnFlags |= JNODE_PATCH; + if( pNew!=&pParse->aNode[iTarget+j+1] ){ + jsonParseAddSubstNode(pParse, iTarget+j+1); + jsonParseAddNodeArray(pParse, pNew, jsonNodeSize(pNew)); } + pTarget = &pParse->aNode[iTarget]; } break; } } if( j>=pTarget->n && pPatch[i+1].eType!=JSON_NULL ){ - int iStart, iPatch; - iStart = jsonParseAddNode(pParse, JSON_OBJECT, 2, 0); + int iStart; + JsonNode *pApnd; + u32 nApnd; + iStart = jsonParseAddNode(pParse, JSON_OBJECT, 0, 0); jsonParseAddNode(pParse, JSON_STRING, nKey, zKey); - iPatch = jsonParseAddNode(pParse, JSON_TRUE, 0, 0); + pApnd = &pPatch[i+1]; + if( pApnd->eType==JSON_OBJECT ) jsonRemoveAllNulls(pApnd); + nApnd = jsonNodeSize(pApnd); + jsonParseAddNodeArray(pParse, pApnd, jsonNodeSize(pApnd)); if( pParse->oom ) return 0; - jsonRemoveAllNulls(pPatch); - pTarget = &pParse->aNode[iTarget]; - assert( pParse->aNode[iRoot].eU==0 || pParse->aNode[iRoot].eU==2 ); - testcase( pParse->aNode[iRoot].eU==2 ); + pParse->aNode[iStart].n = 1+nApnd; pParse->aNode[iRoot].jnFlags |= JNODE_APPEND; + pParse->aNode[iRoot].u.iAppend = iStart; VVA( pParse->aNode[iRoot].eU = 2 ); - pParse->aNode[iRoot].u.iAppend = iStart - iRoot; iRoot = iStart; - assert( pParse->aNode[iPatch].eU==0 ); - VVA( pParse->aNode[iPatch].eU = 5 ); - pParse->aNode[iPatch].jnFlags |= JNODE_PATCH; - pParse->aNode[iPatch].u.pPatch = &pPatch[i+1]; + pTarget = &pParse->aNode[iTarget]; } } return pTarget; @@ -202035,25 +203916,28 @@ static void jsonPatchFunc( int argc, sqlite3_value **argv ){ - JsonParse x; /* The JSON that is being patched */ - JsonParse y; /* The patch */ + JsonParse *pX; /* The JSON that is being patched */ + JsonParse *pY; /* The patch */ JsonNode *pResult; /* The result of the merge */ UNUSED_PARAMETER(argc); - if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return; - if( jsonParse(&y, ctx, (const char*)sqlite3_value_text(argv[1])) ){ - jsonParseReset(&x); - return; - } - pResult = jsonMergePatch(&x, 0, y.aNode); - assert( pResult!=0 || x.oom ); - if( pResult ){ - jsonReturnJson(pResult, ctx, 0); + pX = jsonParseCached(ctx, argv[0], ctx, 1); + if( pX==0 ) return; + assert( pX->hasMod==0 ); + pX->hasMod = 1; + pY = jsonParseCached(ctx, argv[1], ctx, 1); + if( pY==0 ) return; + pX->useMod = 1; + pY->useMod = 1; + pResult = jsonMergePatch(pX, 0, pY->aNode); + assert( pResult!=0 || pX->oom ); + if( pResult && pX->oom==0 ){ + jsonDebugPrintParse(pX); + jsonDebugPrintNode(pResult); + jsonReturnJson(pX, pResult, ctx, 0); }else{ sqlite3_result_error_nomem(ctx); } - jsonParseReset(&x); - jsonParseReset(&y); } @@ -202109,26 +203993,118 @@ static void jsonRemoveFunc( int argc, sqlite3_value **argv ){ - JsonParse x; /* The parse */ + JsonParse *pParse; /* The parse */ JsonNode *pNode; const char *zPath; u32 i; if( argc<1 ) return; - if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return; - assert( x.nNode ); + pParse = jsonParseCached(ctx, argv[0], ctx, argc>1); + if( pParse==0 ) return; for(i=1; i<(u32)argc; i++){ zPath = (const char*)sqlite3_value_text(argv[i]); if( zPath==0 ) goto remove_done; - pNode = jsonLookup(&x, zPath, 0, ctx); - if( x.nErr ) goto remove_done; - if( pNode ) pNode->jnFlags |= JNODE_REMOVE; + pNode = jsonLookup(pParse, zPath, 0, ctx); + if( pParse->nErr ) goto remove_done; + if( pNode ){ + pNode->jnFlags |= JNODE_REMOVE; + pParse->hasMod = 1; + pParse->useMod = 1; + } } - if( (x.aNode[0].jnFlags & JNODE_REMOVE)==0 ){ - jsonReturnJson(x.aNode, ctx, 0); + if( (pParse->aNode[0].jnFlags & JNODE_REMOVE)==0 ){ + jsonReturnJson(pParse, pParse->aNode, ctx, 1); } remove_done: - jsonParseReset(&x); + jsonDebugPrintParse(p); +} + +/* +** Substitute the value at iNode with the pValue parameter. +*/ +static void jsonReplaceNode( + sqlite3_context *pCtx, + JsonParse *p, + int iNode, + sqlite3_value *pValue +){ + int idx = jsonParseAddSubstNode(p, iNode); + if( idx<=0 ){ + assert( p->oom ); + return; + } + switch( sqlite3_value_type(pValue) ){ + case SQLITE_NULL: { + jsonParseAddNode(p, JSON_NULL, 0, 0); + break; + } + case SQLITE_FLOAT: { + char *z = sqlite3_mprintf("%!0.15g", sqlite3_value_double(pValue)); + int n; + if( z==0 ){ + p->oom = 1; + break; + } + n = sqlite3Strlen30(z); + jsonParseAddNode(p, JSON_REAL, n, z); + jsonParseAddCleanup(p, sqlite3_free, z); + break; + } + case SQLITE_INTEGER: { + char *z = sqlite3_mprintf("%lld", sqlite3_value_int64(pValue)); + int n; + if( z==0 ){ + p->oom = 1; + break; + } + n = sqlite3Strlen30(z); + jsonParseAddNode(p, JSON_INT, n, z); + jsonParseAddCleanup(p, sqlite3_free, z); + + break; + } + case SQLITE_TEXT: { + const char *z = (const char*)sqlite3_value_text(pValue); + u32 n = (u32)sqlite3_value_bytes(pValue); + if( z==0 ){ + p->oom = 1; + break; + } + if( sqlite3_value_subtype(pValue)!=JSON_SUBTYPE ){ + char *zCopy = sqlite3DbStrDup(0, z); + int k; + if( zCopy ){ + jsonParseAddCleanup(p, sqlite3_free, zCopy); + }else{ + p->oom = 1; + sqlite3_result_error_nomem(pCtx); + } + k = jsonParseAddNode(p, JSON_STRING, n, zCopy); + assert( k>0 || p->oom ); + if( p->oom==0 ) p->aNode[k].jnFlags |= JNODE_RAW; + }else{ + JsonParse *pPatch = jsonParseCached(pCtx, pValue, pCtx, 1); + if( pPatch==0 ){ + p->oom = 1; + break; + } + jsonParseAddNodeArray(p, pPatch->aNode, pPatch->nNode); + /* The nodes copied out of pPatch and into p likely contain + ** u.zJContent pointers into pPatch->zJson. So preserve the + ** content of pPatch until p is destroyed. */ + assert( pPatch->nJPRef>=1 ); + pPatch->nJPRef++; + jsonParseAddCleanup(p, (void(*)(void*))jsonParseFree, pPatch); + } + break; + } + default: { + jsonParseAddNode(p, JSON_NULL, 0, 0); + sqlite3_result_error(pCtx, "JSON cannot hold BLOB values", -1); + p->nErr++; + break; + } + } } /* @@ -202142,7 +204118,7 @@ static void jsonReplaceFunc( int argc, sqlite3_value **argv ){ - JsonParse x; /* The parse */ + JsonParse *pParse; /* The parse */ JsonNode *pNode; const char *zPath; u32 i; @@ -202152,28 +204128,20 @@ static void jsonReplaceFunc( jsonWrongNumArgs(ctx, "replace"); return; } - if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return; - assert( x.nNode ); + pParse = jsonParseCached(ctx, argv[0], ctx, argc>1); + if( pParse==0 ) return; for(i=1; i<(u32)argc; i+=2){ zPath = (const char*)sqlite3_value_text(argv[i]); - pNode = jsonLookup(&x, zPath, 0, ctx); - if( x.nErr ) goto replace_err; + pParse->useMod = 1; + pNode = jsonLookup(pParse, zPath, 0, ctx); + if( pParse->nErr ) goto replace_err; if( pNode ){ - assert( pNode->eU==0 || pNode->eU==1 || pNode->eU==4 ); - testcase( pNode->eU!=0 && pNode->eU!=1 ); - pNode->jnFlags |= (u8)JNODE_REPLACE; - VVA( pNode->eU = 4 ); - pNode->u.iReplace = i + 1; + jsonReplaceNode(ctx, pParse, (u32)(pNode - pParse->aNode), argv[i+1]); } } - if( x.aNode[0].jnFlags & JNODE_REPLACE ){ - assert( x.aNode[0].eU==4 ); - sqlite3_result_value(ctx, argv[x.aNode[0].u.iReplace]); - }else{ - jsonReturnJson(x.aNode, ctx, argv); - } + jsonReturnJson(pParse, pParse->aNode, ctx, 1); replace_err: - jsonParseReset(&x); + jsonDebugPrintParse(pParse); } @@ -202194,7 +204162,7 @@ static void jsonSetFunc( int argc, sqlite3_value **argv ){ - JsonParse x; /* The parse */ + JsonParse *pParse; /* The parse */ JsonNode *pNode; const char *zPath; u32 i; @@ -202206,33 +204174,27 @@ static void jsonSetFunc( jsonWrongNumArgs(ctx, bIsSet ? "set" : "insert"); return; } - if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return; - assert( x.nNode ); + pParse = jsonParseCached(ctx, argv[0], ctx, argc>1); + if( pParse==0 ) return; for(i=1; i<(u32)argc; i+=2){ zPath = (const char*)sqlite3_value_text(argv[i]); bApnd = 0; - pNode = jsonLookup(&x, zPath, &bApnd, ctx); - if( x.oom ){ + pParse->useMod = 1; + pNode = jsonLookup(pParse, zPath, &bApnd, ctx); + if( pParse->oom ){ sqlite3_result_error_nomem(ctx); goto jsonSetDone; - }else if( x.nErr ){ + }else if( pParse->nErr ){ goto jsonSetDone; }else if( pNode && (bApnd || bIsSet) ){ - testcase( pNode->eU!=0 && pNode->eU!=1 ); - assert( pNode->eU!=3 && pNode->eU!=5 ); - VVA( pNode->eU = 4 ); - pNode->jnFlags |= (u8)JNODE_REPLACE; - pNode->u.iReplace = i + 1; + jsonReplaceNode(ctx, pParse, (u32)(pNode - pParse->aNode), argv[i+1]); } } - if( x.aNode[0].jnFlags & JNODE_REPLACE ){ - assert( x.aNode[0].eU==4 ); - sqlite3_result_value(ctx, argv[x.aNode[0].u.iReplace]); - }else{ - jsonReturnJson(x.aNode, ctx, argv); - } + jsonDebugPrintParse(pParse); + jsonReturnJson(pParse, pParse->aNode, ctx, 1); + jsonSetDone: - jsonParseReset(&x); + /* no cleanup required */; } /* @@ -202251,7 +204213,7 @@ static void jsonTypeFunc( const char *zPath; JsonNode *pNode; - p = jsonParseCached(ctx, argv, ctx); + p = jsonParseCached(ctx, argv[0], ctx, 0); if( p==0 ) return; if( argc==2 ){ zPath = (const char*)sqlite3_value_text(argv[1]); @@ -202277,13 +204239,19 @@ static void jsonValidFunc( ){ JsonParse *p; /* The parse */ UNUSED_PARAMETER(argc); - if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return; - p = jsonParseCached(ctx, argv, 0); + if( sqlite3_value_type(argv[0])==SQLITE_NULL ){ +#ifdef SQLITE_LEGACY_JSON_VALID + /* Incorrect legacy behavior was to return FALSE for a NULL input */ + sqlite3_result_int(ctx, 0); +#endif + return; + } + p = jsonParseCached(ctx, argv[0], 0, 0); if( p==0 || p->oom ){ sqlite3_result_error_nomem(ctx); sqlite3_free(p); }else{ - sqlite3_result_int(ctx, p->nErr==0 && p->hasNonstd==0); + sqlite3_result_int(ctx, p->nErr==0 && (p->hasNonstd==0 || p->useMod)); if( p->nErr ) jsonParseFree(p); } } @@ -202324,7 +204292,7 @@ static void jsonErrorFunc( JsonParse *p; /* The parse */ UNUSED_PARAMETER(argc); if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return; - p = jsonParseCached(ctx, argv, 0); + p = jsonParseCached(ctx, argv[0], 0, 0); if( p==0 || p->oom ){ sqlite3_result_error_nomem(ctx); sqlite3_free(p); @@ -202333,7 +204301,7 @@ static void jsonErrorFunc( }else{ int n = 1; u32 i; - const char *z = p->zJson; + const char *z = (const char*)sqlite3_value_text(argv[0]); for(i=0; iiErr && ALWAYS(z[i]); i++){ if( (z[i]&0xc0)!=0x80 ) n++; } @@ -202381,7 +204349,8 @@ static void jsonArrayCompute(sqlite3_context *ctx, int isFinal){ assert( pStr->bStatic ); }else if( isFinal ){ sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, - pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free); + pStr->bStatic ? SQLITE_TRANSIENT : + (void(*)(void*))sqlite3RCStrUnref); pStr->bStatic = 1; }else{ sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT); @@ -202422,7 +204391,7 @@ static void jsonGroupInverse( pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0); #ifdef NEVER /* pStr is always non-NULL since jsonArrayStep() or jsonObjectStep() will - ** always have been called to initalize it */ + ** always have been called to initialize it */ if( NEVER(!pStr) ) return; #endif z = pStr->zBuf; @@ -202489,7 +204458,8 @@ static void jsonObjectCompute(sqlite3_context *ctx, int isFinal){ assert( pStr->bStatic ); }else if( isFinal ){ sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, - pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free); + pStr->bStatic ? SQLITE_TRANSIENT : + (void(*)(void*))sqlite3RCStrUnref); pStr->bStatic = 1; }else{ sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT); @@ -202600,7 +204570,6 @@ static int jsonEachOpenTree(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){ /* Reset a JsonEachCursor back to its original state. Free any memory ** held. */ static void jsonEachCursorReset(JsonEachCursor *p){ - sqlite3_free(p->zJson); sqlite3_free(p->zRoot); jsonParseReset(&p->sParse); p->iRowid = 0; @@ -202738,7 +204707,7 @@ static int jsonEachColumn( case JEACH_KEY: { if( p->i==0 ) break; if( p->eType==JSON_OBJECT ){ - jsonReturn(pThis, ctx, 0); + jsonReturn(&p->sParse, pThis, ctx); }else if( p->eType==JSON_ARRAY ){ u32 iKey; if( p->bRecursive ){ @@ -202754,7 +204723,7 @@ static int jsonEachColumn( } case JEACH_VALUE: { if( pThis->jnFlags & JNODE_LABEL ) pThis++; - jsonReturn(pThis, ctx, 0); + jsonReturn(&p->sParse, pThis, ctx); break; } case JEACH_TYPE: { @@ -202765,7 +204734,7 @@ static int jsonEachColumn( case JEACH_ATOM: { if( pThis->jnFlags & JNODE_LABEL ) pThis++; if( pThis->eType>=JSON_ARRAY ) break; - jsonReturn(pThis, ctx, 0); + jsonReturn(&p->sParse, pThis, ctx); break; } case JEACH_ID: { @@ -202920,11 +204889,19 @@ static int jsonEachFilter( if( idxNum==0 ) return SQLITE_OK; z = (const char*)sqlite3_value_text(argv[0]); if( z==0 ) return SQLITE_OK; - n = sqlite3_value_bytes(argv[0]); - p->zJson = sqlite3_malloc64( n+1 ); - if( p->zJson==0 ) return SQLITE_NOMEM; - memcpy(p->zJson, z, (size_t)n+1); - if( jsonParse(&p->sParse, 0, p->zJson) ){ + memset(&p->sParse, 0, sizeof(p->sParse)); + p->sParse.nJPRef = 1; + if( sqlite3ValueIsOfClass(argv[0], (void(*)(void*))sqlite3RCStrUnref) ){ + p->sParse.zJson = sqlite3RCStrRef((char*)z); + }else{ + n = sqlite3_value_bytes(argv[0]); + p->sParse.zJson = sqlite3RCStrNew( n+1 ); + if( p->sParse.zJson==0 ) return SQLITE_NOMEM; + memcpy(p->sParse.zJson, z, (size_t)n+1); + } + p->sParse.bJsonIsRCStr = 1; + p->zJson = p->sParse.zJson; + if( jsonParse(&p->sParse, 0) ){ int rc = SQLITE_NOMEM; if( p->sParse.oom==0 ){ sqlite3_free(cur->pVtab->zErrMsg); @@ -203202,6 +205179,11 @@ typedef unsigned int u32; #endif #endif /* !defined(SQLITE_AMALGAMATION) */ +/* Macro to check for 4-byte alignment. Only used inside of assert() */ +#ifdef SQLITE_DEBUG +# define FOUR_BYTE_ALIGNED(X) ((((char*)(X) - (char*)0) & 3)==0) +#endif + /* #include */ /* #include */ /* #include */ @@ -203608,7 +205590,7 @@ static int readInt16(u8 *p){ return (p[0]<<8) + p[1]; } static void readCoord(u8 *p, RtreeCoord *pCoord){ - assert( (((sqlite3_uint64)p)&3)==0 ); /* p is always 4-byte aligned */ + assert( FOUR_BYTE_ALIGNED(p) ); #if SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300 pCoord->u = _byteswap_ulong(*(u32*)p); #elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000 @@ -203662,7 +205644,7 @@ static void writeInt16(u8 *p, int i){ } static int writeCoord(u8 *p, RtreeCoord *pCoord){ u32 i; - assert( (((sqlite3_uint64)p)&3)==0 ); /* p is always 4-byte aligned */ + assert( FOUR_BYTE_ALIGNED(p) ); assert( sizeof(RtreeCoord)==4 ); assert( sizeof(u32)==4 ); #if SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000 @@ -204390,7 +206372,7 @@ static void rtreeNonleafConstraint( assert(p->op==RTREE_LE || p->op==RTREE_LT || p->op==RTREE_GE || p->op==RTREE_GT || p->op==RTREE_EQ || p->op==RTREE_TRUE || p->op==RTREE_FALSE ); - assert( (((sqlite3_uint64)pCellData)&3)==0 ); /* 4-byte aligned */ + assert( FOUR_BYTE_ALIGNED(pCellData) ); switch( p->op ){ case RTREE_TRUE: return; /* Always satisfied */ case RTREE_FALSE: break; /* Never satisfied */ @@ -204443,7 +206425,7 @@ static void rtreeLeafConstraint( || p->op==RTREE_GT || p->op==RTREE_EQ || p->op==RTREE_TRUE || p->op==RTREE_FALSE ); pCellData += 8 + p->iCoord*4; - assert( (((sqlite3_uint64)pCellData)&3)==0 ); /* 4-byte aligned */ + assert( FOUR_BYTE_ALIGNED(pCellData) ); RTREE_DECODE_COORD(eInt, pCellData, xN); switch( p->op ){ case RTREE_TRUE: return; /* Always satisfied */ @@ -205013,7 +206995,20 @@ static int rtreeFilter( p->pInfo->nCoord = pRtree->nDim2; p->pInfo->anQueue = pCsr->anQueue; p->pInfo->mxLevel = pRtree->iDepth + 1; - }else if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){ + }else if( eType==SQLITE_INTEGER ){ + sqlite3_int64 iVal = sqlite3_value_int64(argv[ii]); +#ifdef SQLITE_RTREE_INT_ONLY + p->u.rValue = iVal; +#else + p->u.rValue = (double)iVal; + if( iVal>=((sqlite3_int64)1)<<48 + || iVal<=-(((sqlite3_int64)1)<<48) + ){ + if( p->op==RTREE_LT ) p->op = RTREE_LE; + if( p->op==RTREE_GT ) p->op = RTREE_GE; + } +#endif + }else if( eType==SQLITE_FLOAT ){ #ifdef SQLITE_RTREE_INT_ONLY p->u.rValue = sqlite3_value_int64(argv[ii]); #else @@ -205144,11 +207139,12 @@ static int rtreeBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ || p->op==SQLITE_INDEX_CONSTRAINT_MATCH) ){ u8 op; + u8 doOmit = 1; switch( p->op ){ - case SQLITE_INDEX_CONSTRAINT_EQ: op = RTREE_EQ; break; - case SQLITE_INDEX_CONSTRAINT_GT: op = RTREE_GT; break; + case SQLITE_INDEX_CONSTRAINT_EQ: op = RTREE_EQ; doOmit = 0; break; + case SQLITE_INDEX_CONSTRAINT_GT: op = RTREE_GT; doOmit = 0; break; case SQLITE_INDEX_CONSTRAINT_LE: op = RTREE_LE; break; - case SQLITE_INDEX_CONSTRAINT_LT: op = RTREE_LT; break; + case SQLITE_INDEX_CONSTRAINT_LT: op = RTREE_LT; doOmit = 0; break; case SQLITE_INDEX_CONSTRAINT_GE: op = RTREE_GE; break; case SQLITE_INDEX_CONSTRAINT_MATCH: op = RTREE_MATCH; break; default: op = 0; break; @@ -205157,7 +207153,7 @@ static int rtreeBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ zIdxStr[iIdx++] = op; zIdxStr[iIdx++] = (char)(p->iColumn - 1 + '0'); pIdxInfo->aConstraintUsage[ii].argvIndex = (iIdx/2); - pIdxInfo->aConstraintUsage[ii].omit = 1; + pIdxInfo->aConstraintUsage[ii].omit = doOmit; } } } @@ -218645,6 +220641,7 @@ static int sessionPreupdateEqual( rc = pSession->hook.xOld(pSession->hook.pCtx, iCol, &pVal); } assert( rc==SQLITE_OK ); + (void)rc; /* Suppress warning about unused variable */ if( sqlite3_value_type(pVal)!=eType ) return 0; /* A SessionChange object never has a NULL value in a PK column */ @@ -224060,7 +226057,7 @@ struct Fts5PhraseIter { ** See xPhraseFirstColumn above. */ struct Fts5ExtensionApi { - int iVersion; /* Currently always set to 3 */ + int iVersion; /* Currently always set to 2 */ void *(*xUserData)(Fts5Context*); @@ -224289,8 +226286,8 @@ struct Fts5ExtensionApi { ** as separate queries of the FTS index are required for each synonym. ** ** When using methods (2) or (3), it is important that the tokenizer only -** provide synonyms when tokenizing document text (method (2)) or query -** text (method (3)), not both. Doing so will not cause any errors, but is +** provide synonyms when tokenizing document text (method (3)) or query +** text (method (2)), not both. Doing so will not cause any errors, but is ** inefficient. */ typedef struct Fts5Tokenizer Fts5Tokenizer; @@ -224338,7 +226335,7 @@ struct fts5_api { int (*xCreateTokenizer)( fts5_api *pApi, const char *zName, - void *pContext, + void *pUserData, fts5_tokenizer *pTokenizer, void (*xDestroy)(void*) ); @@ -224347,7 +226344,7 @@ struct fts5_api { int (*xFindTokenizer)( fts5_api *pApi, const char *zName, - void **ppContext, + void **ppUserData, fts5_tokenizer *pTokenizer ); @@ -224355,7 +226352,7 @@ struct fts5_api { int (*xCreateFunction)( fts5_api *pApi, const char *zName, - void *pContext, + void *pUserData, fts5_extension_function xFunction, void (*xDestroy)(void*) ); @@ -224527,6 +226524,10 @@ typedef struct Fts5Config Fts5Config; ** attempt to merge together. A value of 1 sets the object to use the ** compile time default. Zero disables auto-merge altogether. ** +** bContentlessDelete: +** True if the contentless_delete option was present in the CREATE +** VIRTUAL TABLE statement. +** ** zContent: ** ** zContentRowid: @@ -224561,6 +226562,7 @@ struct Fts5Config { int nPrefix; /* Number of prefix indexes */ int *aPrefix; /* Sizes in bytes of nPrefix prefix indexes */ int eContent; /* An FTS5_CONTENT value */ + int bContentlessDelete; /* "contentless_delete=" option (dflt==0) */ char *zContent; /* content table */ char *zContentRowid; /* "content_rowid=" option value */ int bColumnsize; /* "columnsize=" option value (dflt==1) */ @@ -224582,6 +226584,7 @@ struct Fts5Config { char *zRank; /* Name of rank function */ char *zRankArgs; /* Arguments to rank function */ int bSecureDelete; /* 'secure-delete' */ + int nDeleteMerge; /* 'deletemerge' */ /* If non-NULL, points to sqlite3_vtab.base.zErrmsg. Often NULL. */ char **pzErrmsg; @@ -224904,6 +226907,9 @@ static int sqlite3Fts5IndexReset(Fts5Index *p); static int sqlite3Fts5IndexLoadConfig(Fts5Index *p); +static int sqlite3Fts5IndexGetOrigin(Fts5Index *p, i64 *piOrigin); +static int sqlite3Fts5IndexContentlessDelete(Fts5Index *p, i64 iOrigin, i64 iRowid); + /* ** End of interface to code in fts5_index.c. **************************************************************************/ @@ -224988,6 +226994,11 @@ static int sqlite3Fts5HashWrite( */ static void sqlite3Fts5HashClear(Fts5Hash*); +/* +** Return true if the hash is empty, false otherwise. +*/ +static int sqlite3Fts5HashIsEmpty(Fts5Hash*); + static int sqlite3Fts5HashQuery( Fts5Hash*, /* Hash table to query */ int nPre, @@ -225009,6 +227020,7 @@ static void sqlite3Fts5HashScanEntry(Fts5Hash *, ); + /* ** End of interface to code in fts5_hash.c. **************************************************************************/ @@ -225252,7 +227264,8 @@ static void sqlite3Fts5UnicodeAscii(u8*, u8*); #define FTS5_STAR 15 /* This file is automatically generated by Lemon from input grammar -** source file "fts5parse.y". */ +** source file "fts5parse.y". +*/ /* ** 2000-05-29 ** @@ -227880,6 +229893,8 @@ static void sqlite3Fts5TermsetFree(Fts5Termset *p){ #define FTS5_DEFAULT_CRISISMERGE 16 #define FTS5_DEFAULT_HASHSIZE (1024*1024) +#define FTS5_DEFAULT_DELETE_AUTOMERGE 10 /* default 10% */ + /* Maximum allowed page size */ #define FTS5_MAX_PAGE_SIZE (64*1024) @@ -228210,6 +230225,16 @@ static int fts5ConfigParseSpecial( return rc; } + if( sqlite3_strnicmp("contentless_delete", zCmd, nCmd)==0 ){ + if( (zArg[0]!='0' && zArg[0]!='1') || zArg[1]!='\0' ){ + *pzErr = sqlite3_mprintf("malformed contentless_delete=... directive"); + rc = SQLITE_ERROR; + }else{ + pConfig->bContentlessDelete = (zArg[0]=='1'); + } + return rc; + } + if( sqlite3_strnicmp("content_rowid", zCmd, nCmd)==0 ){ if( pConfig->zContentRowid ){ *pzErr = sqlite3_mprintf("multiple content_rowid=... directives"); @@ -228454,6 +230479,28 @@ static int sqlite3Fts5ConfigParse( sqlite3_free(zTwo); } + /* We only allow contentless_delete=1 if the table is indeed contentless. */ + if( rc==SQLITE_OK + && pRet->bContentlessDelete + && pRet->eContent!=FTS5_CONTENT_NONE + ){ + *pzErr = sqlite3_mprintf( + "contentless_delete=1 requires a contentless table" + ); + rc = SQLITE_ERROR; + } + + /* We only allow contentless_delete=1 if columnsize=0 is not present. + ** + ** This restriction may be removed at some point. + */ + if( rc==SQLITE_OK && pRet->bContentlessDelete && pRet->bColumnsize==0 ){ + *pzErr = sqlite3_mprintf( + "contentless_delete=1 is incompatible with columnsize=0" + ); + rc = SQLITE_ERROR; + } + /* If a tokenizer= option was successfully parsed, the tokenizer has ** already been allocated. Otherwise, allocate an instance of the default ** tokenizer (unicode61) now. */ @@ -228748,6 +230795,18 @@ static int sqlite3Fts5ConfigSetValue( } } + else if( 0==sqlite3_stricmp(zKey, "deletemerge") ){ + int nVal = -1; + if( SQLITE_INTEGER==sqlite3_value_numeric_type(pVal) ){ + nVal = sqlite3_value_int(pVal); + }else{ + *pbBadkey = 1; + } + if( nVal<0 ) nVal = FTS5_DEFAULT_DELETE_AUTOMERGE; + if( nVal>100 ) nVal = 0; + pConfig->nDeleteMerge = nVal; + } + else if( 0==sqlite3_stricmp(zKey, "rank") ){ const char *zIn = (const char*)sqlite3_value_text(pVal); char *zRank; @@ -228796,6 +230855,7 @@ static int sqlite3Fts5ConfigLoad(Fts5Config *pConfig, int iCookie){ pConfig->nUsermerge = FTS5_DEFAULT_USERMERGE; pConfig->nCrisisMerge = FTS5_DEFAULT_CRISISMERGE; pConfig->nHashSize = FTS5_DEFAULT_HASHSIZE; + pConfig->nDeleteMerge = FTS5_DEFAULT_DELETE_AUTOMERGE; zSql = sqlite3Fts5Mprintf(&rc, zSelect, pConfig->zDb, pConfig->zName); if( zSql ){ @@ -231319,7 +233379,7 @@ static Fts5ExprNode *sqlite3Fts5ParseImplicitAnd( return pRet; } -#ifdef SQLITE_TEST +#if defined(SQLITE_TEST) || defined(SQLITE_FTS5_DEBUG) static char *fts5ExprTermPrint(Fts5ExprTerm *pTerm){ sqlite3_int64 nByte = 0; Fts5ExprTerm *p; @@ -231425,6 +233485,8 @@ static char *fts5ExprPrintTcl( if( zRet==0 ) return 0; } + }else if( pExpr->eType==0 ){ + zRet = sqlite3_mprintf("{}"); }else{ char const *zOp = 0; int i; @@ -231686,14 +233748,14 @@ static void fts5ExprFold( sqlite3_result_int(pCtx, sqlite3Fts5UnicodeFold(iCode, bRemoveDiacritics)); } } -#endif /* ifdef SQLITE_TEST */ +#endif /* if SQLITE_TEST || SQLITE_FTS5_DEBUG */ /* ** This is called during initialization to register the fts5_expr() scalar ** UDF with the SQLite handle passed as the only argument. */ static int sqlite3Fts5ExprInit(Fts5Global *pGlobal, sqlite3 *db){ -#ifdef SQLITE_TEST +#if defined(SQLITE_TEST) || defined(SQLITE_FTS5_DEBUG) struct Fts5ExprFunc { const char *z; void (*x)(sqlite3_context*,int,sqlite3_value**); @@ -232453,7 +234515,6 @@ static int fts5HashEntrySort( pList = fts5HashEntryMerge(pList, ap[i]); } - pHash->nEntry = 0; sqlite3_free(ap); *ppSorted = pList; return SQLITE_OK; @@ -232507,6 +234568,28 @@ static int sqlite3Fts5HashScanInit( return fts5HashEntrySort(p, pTerm, nTerm, &p->pScan); } +#ifdef SQLITE_DEBUG +static int fts5HashCount(Fts5Hash *pHash){ + int nEntry = 0; + int ii; + for(ii=0; iinSlot; ii++){ + Fts5HashEntry *p = 0; + for(p=pHash->aSlot[ii]; p; p=p->pHashNext){ + nEntry++; + } + } + return nEntry; +} +#endif + +/* +** Return true if the hash table is empty, false otherwise. +*/ +static int sqlite3Fts5HashIsEmpty(Fts5Hash *pHash){ + assert( pHash->nEntry==fts5HashCount(pHash) ); + return pHash->nEntry==0; +} + static void sqlite3Fts5HashScanNext(Fts5Hash *p){ assert( !sqlite3Fts5HashScanEof(p) ); p->pScan = p->pScan->pScanNext; @@ -232595,6 +234678,24 @@ static void sqlite3Fts5HashScanEntry( #define FTS5_MAX_LEVEL 64 +/* +** There are two versions of the format used for the structure record: +** +** 1. the legacy format, that may be read by all fts5 versions, and +** +** 2. the V2 format, which is used by contentless_delete=1 databases. +** +** Both begin with a 4-byte "configuration cookie" value. Then, a legacy +** format structure record contains a varint - the number of levels in +** the structure. Whereas a V2 structure record contains the constant +** 4 bytes [0xff 0x00 0x00 0x01]. This is unambiguous as the value of a +** varint has to be at least 16256 to begin with "0xFF". And the default +** maximum number of levels is 64. +** +** See below for more on structure record formats. +*/ +#define FTS5_STRUCTURE_V2 "\xFF\x00\x00\x01" + /* ** Details: ** @@ -232602,7 +234703,7 @@ static void sqlite3Fts5HashScanEntry( ** ** CREATE TABLE %_data(id INTEGER PRIMARY KEY, block BLOB); ** -** , contains the following 5 types of records. See the comments surrounding +** , contains the following 6 types of records. See the comments surrounding ** the FTS5_*_ROWID macros below for a description of how %_data rowids are ** assigned to each fo them. ** @@ -232611,12 +234712,12 @@ static void sqlite3Fts5HashScanEntry( ** The set of segments that make up an index - the index structure - are ** recorded in a single record within the %_data table. The record consists ** of a single 32-bit configuration cookie value followed by a list of -** SQLite varints. If the FTS table features more than one index (because -** there are one or more prefix indexes), it is guaranteed that all share -** the same cookie value. +** SQLite varints. ** -** Immediately following the configuration cookie, the record begins with -** three varints: +** If the structure record is a V2 record, the configuration cookie is +** followed by the following 4 bytes: [0xFF 0x00 0x00 0x01]. +** +** Next, the record continues with three varints: ** ** + number of levels, ** + total number of segments on all levels, @@ -232631,6 +234732,12 @@ static void sqlite3Fts5HashScanEntry( ** + first leaf page number (often 1, always greater than 0) ** + final leaf page number ** +** Then, for V2 structures only: +** +** + lower origin counter value, +** + upper origin counter value, +** + the number of tombstone hash pages. +** ** 2. The Averages Record: ** ** A single record within the %_data table. The data is a list of varints. @@ -232746,6 +234853,38 @@ static void sqlite3Fts5HashScanEntry( ** * A list of delta-encoded varints - the first rowid on each subsequent ** child page. ** +** 6. Tombstone Hash Page +** +** These records are only ever present in contentless_delete=1 tables. +** There are zero or more of these associated with each segment. They +** are used to store the tombstone rowids for rows contained in the +** associated segments. +** +** The set of nHashPg tombstone hash pages associated with a single +** segment together form a single hash table containing tombstone rowids. +** To find the page of the hash on which a key might be stored: +** +** iPg = (rowid % nHashPg) +** +** Then, within page iPg, which has nSlot slots: +** +** iSlot = (rowid / nHashPg) % nSlot +** +** Each tombstone hash page begins with an 8 byte header: +** +** 1-byte: Key-size (the size in bytes of each slot). Either 4 or 8. +** 1-byte: rowid-0-tombstone flag. This flag is only valid on the +** first tombstone hash page for each segment (iPg=0). If set, +** the hash table contains rowid 0. If clear, it does not. +** Rowid 0 is handled specially. +** 2-bytes: unused. +** 4-bytes: Big-endian integer containing number of entries on page. +** +** Following this are nSlot 4 or 8 byte slots (depending on the key-size +** in the first byte of the page header). The number of slots may be +** determined based on the size of the page record and the key-size: +** +** nSlot = (nByte - 8) / key-size */ /* @@ -232779,6 +234918,7 @@ static void sqlite3Fts5HashScanEntry( #define FTS5_SEGMENT_ROWID(segid, pgno) fts5_dri(segid, 0, 0, pgno) #define FTS5_DLIDX_ROWID(segid, height, pgno) fts5_dri(segid, 1, height, pgno) +#define FTS5_TOMBSTONE_ROWID(segid,ipg) fts5_dri(segid+(1<<16), 0, 0, ipg) #ifdef SQLITE_DEBUG static int sqlite3Fts5Corrupt() { return SQLITE_CORRUPT_VTAB; } @@ -232814,6 +234954,12 @@ struct Fts5Data { /* ** One object per %_data table. +** +** nContentlessDelete: +** The number of contentless delete operations since the most recent +** call to fts5IndexFlush() or fts5IndexDiscardData(). This is tracked +** so that extra auto-merge work can be done by fts5IndexFlush() to +** account for the delete operations. */ struct Fts5Index { Fts5Config *pConfig; /* Virtual table configuration */ @@ -232828,6 +234974,8 @@ struct Fts5Index { int nPendingData; /* Current bytes of pending data */ i64 iWriteRowid; /* Rowid for current doc being written */ int bDelete; /* Current write is a delete */ + int nContentlessDelete; /* Number of contentless delete ops */ + int nPendingRow; /* Number of INSERT in hash table */ /* Error state. */ int rc; /* Current error code */ @@ -232862,11 +235010,23 @@ struct Fts5DoclistIter { ** The contents of the "structure" record for each index are represented ** using an Fts5Structure record in memory. Which uses instances of the ** other Fts5StructureXXX types as components. +** +** nOriginCntr: +** This value is set to non-zero for structure records created for +** contentlessdelete=1 tables only. In that case it represents the +** origin value to apply to the next top-level segment created. */ struct Fts5StructureSegment { int iSegid; /* Segment id */ int pgnoFirst; /* First leaf page number in segment */ int pgnoLast; /* Last leaf page number in segment */ + + /* contentlessdelete=1 tables only: */ + u64 iOrigin1; + u64 iOrigin2; + int nPgTombstone; /* Number of tombstone hash table pages */ + u64 nEntryTombstone; /* Number of tombstone entries that "count" */ + u64 nEntry; /* Number of rows in this segment */ }; struct Fts5StructureLevel { int nMerge; /* Number of segments in incr-merge */ @@ -232876,6 +235036,7 @@ struct Fts5StructureLevel { struct Fts5Structure { int nRef; /* Object reference count */ u64 nWriteCounter; /* Total leaves written to level 0 */ + u64 nOriginCntr; /* Origin value for next top-level segment */ int nSegment; /* Total segments in this structure */ int nLevel; /* Number of levels in this index */ Fts5StructureLevel aLevel[1]; /* Array of nLevel level objects */ @@ -232964,6 +235125,13 @@ struct Fts5CResult { ** ** iTermIdx: ** Index of current term on iTermLeafPgno. +** +** apTombstone/nTombstone: +** These are used for contentless_delete=1 tables only. When the cursor +** is first allocated, the apTombstone[] array is allocated so that it +** is large enough for all tombstones hash pages associated with the +** segment. The pages themselves are loaded lazily from the database as +** they are required. */ struct Fts5SegIter { Fts5StructureSegment *pSeg; /* Segment to iterate through */ @@ -232972,6 +235140,8 @@ struct Fts5SegIter { Fts5Data *pLeaf; /* Current leaf data */ Fts5Data *pNextLeaf; /* Leaf page (iLeafPgno+1) */ i64 iLeafOffset; /* Byte offset within current leaf */ + Fts5Data **apTombstone; /* Array of tombstone pages */ + int nTombstone; /* Next method */ void (*xNext)(Fts5Index*, Fts5SegIter*, int*); @@ -233101,6 +235271,60 @@ static u16 fts5GetU16(const u8 *aIn){ return ((u16)aIn[0] << 8) + aIn[1]; } +/* +** The only argument points to a buffer at least 8 bytes in size. This +** function interprets the first 8 bytes of the buffer as a 64-bit big-endian +** unsigned integer and returns the result. +*/ +static u64 fts5GetU64(u8 *a){ + return ((u64)a[0] << 56) + + ((u64)a[1] << 48) + + ((u64)a[2] << 40) + + ((u64)a[3] << 32) + + ((u64)a[4] << 24) + + ((u64)a[5] << 16) + + ((u64)a[6] << 8) + + ((u64)a[7] << 0); +} + +/* +** The only argument points to a buffer at least 4 bytes in size. This +** function interprets the first 4 bytes of the buffer as a 32-bit big-endian +** unsigned integer and returns the result. +*/ +static u32 fts5GetU32(const u8 *a){ + return ((u32)a[0] << 24) + + ((u32)a[1] << 16) + + ((u32)a[2] << 8) + + ((u32)a[3] << 0); +} + +/* +** Write iVal, formated as a 64-bit big-endian unsigned integer, to the +** buffer indicated by the first argument. +*/ +static void fts5PutU64(u8 *a, u64 iVal){ + a[0] = ((iVal >> 56) & 0xFF); + a[1] = ((iVal >> 48) & 0xFF); + a[2] = ((iVal >> 40) & 0xFF); + a[3] = ((iVal >> 32) & 0xFF); + a[4] = ((iVal >> 24) & 0xFF); + a[5] = ((iVal >> 16) & 0xFF); + a[6] = ((iVal >> 8) & 0xFF); + a[7] = ((iVal >> 0) & 0xFF); +} + +/* +** Write iVal, formated as a 32-bit big-endian unsigned integer, to the +** buffer indicated by the first argument. +*/ +static void fts5PutU32(u8 *a, u32 iVal){ + a[0] = ((iVal >> 24) & 0xFF); + a[1] = ((iVal >> 16) & 0xFF); + a[2] = ((iVal >> 8) & 0xFF); + a[3] = ((iVal >> 0) & 0xFF); +} + /* ** Allocate and return a buffer at least nByte bytes in size. ** @@ -233328,10 +235552,17 @@ static void fts5DataDelete(Fts5Index *p, i64 iFirst, i64 iLast){ /* ** Remove all records associated with segment iSegid. */ -static void fts5DataRemoveSegment(Fts5Index *p, int iSegid){ +static void fts5DataRemoveSegment(Fts5Index *p, Fts5StructureSegment *pSeg){ + int iSegid = pSeg->iSegid; i64 iFirst = FTS5_SEGMENT_ROWID(iSegid, 0); i64 iLast = FTS5_SEGMENT_ROWID(iSegid+1, 0)-1; fts5DataDelete(p, iFirst, iLast); + + if( pSeg->nPgTombstone ){ + i64 iTomb1 = FTS5_TOMBSTONE_ROWID(iSegid, 0); + i64 iTomb2 = FTS5_TOMBSTONE_ROWID(iSegid, pSeg->nPgTombstone-1); + fts5DataDelete(p, iTomb1, iTomb2); + } if( p->pIdxDeleter==0 ){ Fts5Config *pConfig = p->pConfig; fts5IndexPrepareStmt(p, &p->pIdxDeleter, sqlite3_mprintf( @@ -233442,11 +235673,19 @@ static int fts5StructureDecode( int nSegment = 0; sqlite3_int64 nByte; /* Bytes of space to allocate at pRet */ Fts5Structure *pRet = 0; /* Structure object to return */ + int bStructureV2 = 0; /* True for FTS5_STRUCTURE_V2 */ + u64 nOriginCntr = 0; /* Largest origin value seen so far */ /* Grab the cookie value */ if( piCookie ) *piCookie = sqlite3Fts5Get32(pData); i = 4; + /* Check if this is a V2 structure record. Set bStructureV2 if it is. */ + if( 0==memcmp(&pData[i], FTS5_STRUCTURE_V2, 4) ){ + i += 4; + bStructureV2 = 1; + } + /* Read the total number of levels and segments from the start of the ** structure record. */ i += fts5GetVarint32(&pData[i], nLevel); @@ -233497,6 +235736,14 @@ static int fts5StructureDecode( i += fts5GetVarint32(&pData[i], pSeg->iSegid); i += fts5GetVarint32(&pData[i], pSeg->pgnoFirst); i += fts5GetVarint32(&pData[i], pSeg->pgnoLast); + if( bStructureV2 ){ + i += fts5GetVarint(&pData[i], &pSeg->iOrigin1); + i += fts5GetVarint(&pData[i], &pSeg->iOrigin2); + i += fts5GetVarint32(&pData[i], pSeg->nPgTombstone); + i += fts5GetVarint(&pData[i], &pSeg->nEntryTombstone); + i += fts5GetVarint(&pData[i], &pSeg->nEntry); + nOriginCntr = MAX(nOriginCntr, pSeg->iOrigin2); + } if( pSeg->pgnoLastpgnoFirst ){ rc = FTS5_CORRUPT; break; @@ -233507,6 +235754,9 @@ static int fts5StructureDecode( } } if( nSegment!=0 && rc==SQLITE_OK ) rc = FTS5_CORRUPT; + if( bStructureV2 ){ + pRet->nOriginCntr = nOriginCntr+1; + } if( rc!=SQLITE_OK ){ fts5StructureRelease(pRet); @@ -233719,6 +235969,7 @@ static void fts5StructureWrite(Fts5Index *p, Fts5Structure *pStruct){ Fts5Buffer buf; /* Buffer to serialize record into */ int iLvl; /* Used to iterate through levels */ int iCookie; /* Cookie value to store */ + int nHdr = (pStruct->nOriginCntr>0 ? (4+4+9+9+9) : (4+9+9)); assert( pStruct->nSegment==fts5StructureCountSegments(pStruct) ); memset(&buf, 0, sizeof(Fts5Buffer)); @@ -233727,9 +235978,12 @@ static void fts5StructureWrite(Fts5Index *p, Fts5Structure *pStruct){ iCookie = p->pConfig->iCookie; if( iCookie<0 ) iCookie = 0; - if( 0==sqlite3Fts5BufferSize(&p->rc, &buf, 4+9+9+9) ){ + if( 0==sqlite3Fts5BufferSize(&p->rc, &buf, nHdr) ){ sqlite3Fts5Put32(buf.p, iCookie); buf.n = 4; + if( pStruct->nOriginCntr>0 ){ + fts5BufferSafeAppendBlob(&buf, FTS5_STRUCTURE_V2, 4); + } fts5BufferSafeAppendVarint(&buf, pStruct->nLevel); fts5BufferSafeAppendVarint(&buf, pStruct->nSegment); fts5BufferSafeAppendVarint(&buf, (i64)pStruct->nWriteCounter); @@ -233743,9 +235997,17 @@ static void fts5StructureWrite(Fts5Index *p, Fts5Structure *pStruct){ assert( pLvl->nMerge<=pLvl->nSeg ); for(iSeg=0; iSegnSeg; iSeg++){ - fts5BufferAppendVarint(&p->rc, &buf, pLvl->aSeg[iSeg].iSegid); - fts5BufferAppendVarint(&p->rc, &buf, pLvl->aSeg[iSeg].pgnoFirst); - fts5BufferAppendVarint(&p->rc, &buf, pLvl->aSeg[iSeg].pgnoLast); + Fts5StructureSegment *pSeg = &pLvl->aSeg[iSeg]; + fts5BufferAppendVarint(&p->rc, &buf, pSeg->iSegid); + fts5BufferAppendVarint(&p->rc, &buf, pSeg->pgnoFirst); + fts5BufferAppendVarint(&p->rc, &buf, pSeg->pgnoLast); + if( pStruct->nOriginCntr>0 ){ + fts5BufferAppendVarint(&p->rc, &buf, pSeg->iOrigin1); + fts5BufferAppendVarint(&p->rc, &buf, pSeg->iOrigin2); + fts5BufferAppendVarint(&p->rc, &buf, pSeg->nPgTombstone); + fts5BufferAppendVarint(&p->rc, &buf, pSeg->nEntryTombstone); + fts5BufferAppendVarint(&p->rc, &buf, pSeg->nEntry); + } } } @@ -234268,6 +236530,23 @@ static void fts5SegIterSetNext(Fts5Index *p, Fts5SegIter *pIter){ } } +/* +** Allocate a tombstone hash page array (pIter->apTombstone) for the +** iterator passed as the second argument. If an OOM error occurs, leave +** an error in the Fts5Index object. +*/ +static void fts5SegIterAllocTombstone(Fts5Index *p, Fts5SegIter *pIter){ + const int nTomb = pIter->pSeg->nPgTombstone; + if( nTomb>0 ){ + Fts5Data **apTomb = 0; + apTomb = (Fts5Data**)sqlite3Fts5MallocZero(&p->rc, sizeof(Fts5Data)*nTomb); + if( apTomb ){ + pIter->apTombstone = apTomb; + pIter->nTombstone = nTomb; + } + } +} + /* ** Initialize the iterator object pIter to iterate through the entries in ** segment pSeg. The iterator is left pointing to the first entry when @@ -234309,6 +236588,7 @@ static void fts5SegIterInit( pIter->iPgidxOff = pIter->pLeaf->szLeaf+1; fts5SegIterLoadTerm(p, pIter, 0); fts5SegIterLoadNPos(p, pIter); + fts5SegIterAllocTombstone(p, pIter); } } @@ -235010,6 +237290,7 @@ static void fts5SegIterSeekInit( } fts5SegIterSetNext(p, pIter); + fts5SegIterAllocTombstone(p, pIter); /* Either: ** @@ -235090,6 +237371,20 @@ static void fts5SegIterHashInit( fts5SegIterSetNext(p, pIter); } +/* +** Array ap[] contains n elements. Release each of these elements using +** fts5DataRelease(). Then free the array itself using sqlite3_free(). +*/ +static void fts5IndexFreeArray(Fts5Data **ap, int n){ + if( ap ){ + int ii; + for(ii=0; iiterm); fts5DataRelease(pIter->pLeaf); fts5DataRelease(pIter->pNextLeaf); + fts5IndexFreeArray(pIter->apTombstone, pIter->nTombstone); fts5DlidxIterFree(pIter->pDlidx); sqlite3_free(pIter->aRowidOffset); memset(pIter, 0, sizeof(Fts5SegIter)); @@ -235434,6 +237730,84 @@ static void fts5MultiIterSetEof(Fts5Iter *pIter){ pIter->iSwitchRowid = pSeg->iRowid; } +/* +** The argument to this macro must be an Fts5Data structure containing a +** tombstone hash page. This macro returns the key-size of the hash-page. +*/ +#define TOMBSTONE_KEYSIZE(pPg) (pPg->p[0]==4 ? 4 : 8) + +#define TOMBSTONE_NSLOT(pPg) \ + ((pPg->nn > 16) ? ((pPg->nn-8) / TOMBSTONE_KEYSIZE(pPg)) : 1) + +/* +** Query a single tombstone hash table for rowid iRowid. Return true if +** it is found or false otherwise. The tombstone hash table is one of +** nHashTable tables. +*/ +static int fts5IndexTombstoneQuery( + Fts5Data *pHash, /* Hash table page to query */ + int nHashTable, /* Number of pages attached to segment */ + u64 iRowid /* Rowid to query hash for */ +){ + const int szKey = TOMBSTONE_KEYSIZE(pHash); + const int nSlot = TOMBSTONE_NSLOT(pHash); + int iSlot = (iRowid / nHashTable) % nSlot; + int nCollide = nSlot; + + if( iRowid==0 ){ + return pHash->p[1]; + }else if( szKey==4 ){ + u32 *aSlot = (u32*)&pHash->p[8]; + while( aSlot[iSlot] ){ + if( fts5GetU32((u8*)&aSlot[iSlot])==iRowid ) return 1; + if( nCollide--==0 ) break; + iSlot = (iSlot+1)%nSlot; + } + }else{ + u64 *aSlot = (u64*)&pHash->p[8]; + while( aSlot[iSlot] ){ + if( fts5GetU64((u8*)&aSlot[iSlot])==iRowid ) return 1; + if( nCollide--==0 ) break; + iSlot = (iSlot+1)%nSlot; + } + } + + return 0; +} + +/* +** Return true if the iterator passed as the only argument points +** to an segment entry for which there is a tombstone. Return false +** if there is no tombstone or if the iterator is already at EOF. +*/ +static int fts5MultiIterIsDeleted(Fts5Iter *pIter){ + int iFirst = pIter->aFirst[1].iFirst; + Fts5SegIter *pSeg = &pIter->aSeg[iFirst]; + + if( pSeg->pLeaf && pSeg->nTombstone ){ + /* Figure out which page the rowid might be present on. */ + int iPg = ((u64)pSeg->iRowid) % pSeg->nTombstone; + assert( iPg>=0 ); + + /* If tombstone hash page iPg has not yet been loaded from the + ** database, load it now. */ + if( pSeg->apTombstone[iPg]==0 ){ + pSeg->apTombstone[iPg] = fts5DataRead(pIter->pIndex, + FTS5_TOMBSTONE_ROWID(pSeg->pSeg->iSegid, iPg) + ); + if( pSeg->apTombstone[iPg]==0 ) return 0; + } + + return fts5IndexTombstoneQuery( + pSeg->apTombstone[iPg], + pSeg->nTombstone, + pSeg->iRowid + ); + } + + return 0; +} + /* ** Move the iterator to the next entry. ** @@ -235471,7 +237845,9 @@ static void fts5MultiIterNext( fts5AssertMultiIterSetup(p, pIter); assert( pSeg==&pIter->aSeg[pIter->aFirst[1].iFirst] && pSeg->pLeaf ); - if( pIter->bSkipEmpty==0 || pSeg->nPos ){ + if( (pIter->bSkipEmpty==0 || pSeg->nPos) + && 0==fts5MultiIterIsDeleted(pIter) + ){ pIter->xSetOutputs(pIter, pSeg); return; } @@ -235503,7 +237879,9 @@ static void fts5MultiIterNext2( } fts5AssertMultiIterSetup(p, pIter); - }while( fts5MultiIterIsEmpty(p, pIter) ); + }while( (fts5MultiIterIsEmpty(p, pIter) || fts5MultiIterIsDeleted(pIter)) + && (p->rc==SQLITE_OK) + ); } } @@ -236058,7 +238436,9 @@ static void fts5MultiIterNew( fts5MultiIterSetEof(pNew); fts5AssertMultiIterSetup(p, pNew); - if( pNew->bSkipEmpty && fts5MultiIterIsEmpty(p, pNew) ){ + if( (pNew->bSkipEmpty && fts5MultiIterIsEmpty(p, pNew)) + || fts5MultiIterIsDeleted(pNew) + ){ fts5MultiIterNext(p, pNew, 0, 0); }else if( pNew->base.bEof==0 ){ Fts5SegIter *pSeg = &pNew->aSeg[pNew->aFirst[1].iFirst]; @@ -236236,7 +238616,9 @@ static void fts5IndexDiscardData(Fts5Index *p){ if( p->pHash ){ sqlite3Fts5HashClear(p->pHash); p->nPendingData = 0; + p->nPendingRow = 0; } + p->nContentlessDelete = 0; } /* @@ -236873,6 +239255,12 @@ static void fts5IndexMergeLevel( /* Read input from all segments in the input level */ nInput = pLvl->nSeg; + + /* Set the range of origins that will go into the output segment. */ + if( pStruct->nOriginCntr>0 ){ + pSeg->iOrigin1 = pLvl->aSeg[0].iOrigin1; + pSeg->iOrigin2 = pLvl->aSeg[pLvl->nSeg-1].iOrigin2; + } } bOldest = (pLvlOut->nSeg==1 && pStruct->nLevel==iLvl+2); @@ -236932,8 +239320,11 @@ static void fts5IndexMergeLevel( int i; /* Remove the redundant segments from the %_data table */ + assert( pSeg->nEntry==0 ); for(i=0; iaSeg[i].iSegid); + Fts5StructureSegment *pOld = &pLvl->aSeg[i]; + pSeg->nEntry += (pOld->nEntry - pOld->nEntryTombstone); + fts5DataRemoveSegment(p, pOld); } /* Remove the redundant segments from the input level */ @@ -236959,6 +239350,43 @@ static void fts5IndexMergeLevel( if( pnRem ) *pnRem -= writer.nLeafWritten; } +/* +** If this is not a contentless_delete=1 table, or if the 'deletemerge' +** configuration option is set to 0, then this function always returns -1. +** Otherwise, it searches the structure object passed as the second argument +** for a level suitable for merging due to having a large number of +** tombstones in the tombstone hash. If one is found, its index is returned. +** Otherwise, if there is no suitable level, -1. +*/ +static int fts5IndexFindDeleteMerge(Fts5Index *p, Fts5Structure *pStruct){ + Fts5Config *pConfig = p->pConfig; + int iRet = -1; + if( pConfig->bContentlessDelete && pConfig->nDeleteMerge>0 ){ + int ii; + int nBest = 0; + + for(ii=0; iinLevel; ii++){ + Fts5StructureLevel *pLvl = &pStruct->aLevel[ii]; + i64 nEntry = 0; + i64 nTomb = 0; + int iSeg; + for(iSeg=0; iSegnSeg; iSeg++){ + nEntry += pLvl->aSeg[iSeg].nEntry; + nTomb += pLvl->aSeg[iSeg].nEntryTombstone; + } + assert_nc( nEntry>0 || pLvl->nSeg==0 ); + if( nEntry>0 ){ + int nPercent = (nTomb * 100) / nEntry; + if( nPercent>=pConfig->nDeleteMerge && nPercent>nBest ){ + iRet = ii; + nBest = nPercent; + } + } + } + } + return iRet; +} + /* ** Do up to nPg pages of automerge work on the index. ** @@ -236978,14 +239406,15 @@ static int fts5IndexMerge( int iBestLvl = 0; /* Level offering the most input segments */ int nBest = 0; /* Number of input segments on best level */ - /* Set iBestLvl to the level to read input segments from. */ + /* Set iBestLvl to the level to read input segments from. Or to -1 if + ** there is no level suitable to merge segments from. */ assert( pStruct->nLevel>0 ); for(iLvl=0; iLvlnLevel; iLvl++){ Fts5StructureLevel *pLvl = &pStruct->aLevel[iLvl]; if( pLvl->nMerge ){ if( pLvl->nMerge>nBest ){ iBestLvl = iLvl; - nBest = pLvl->nMerge; + nBest = nMin; } break; } @@ -236994,22 +239423,18 @@ static int fts5IndexMerge( iBestLvl = iLvl; } } - - /* If nBest is still 0, then the index must be empty. */ -#ifdef SQLITE_DEBUG - for(iLvl=0; nBest==0 && iLvlnLevel; iLvl++){ - assert( pStruct->aLevel[iLvl].nSeg==0 ); + if( nBestaLevel[iBestLvl].nMerge==0 ){ - break; - } + if( iBestLvl<0 ) break; bRet = 1; fts5IndexMergeLevel(p, &pStruct, iBestLvl, &nRem); if( p->rc==SQLITE_OK && pStruct->aLevel[iBestLvl].nMerge==0 ){ fts5StructurePromote(p, iBestLvl+1, pStruct); } + + if( nMin==1 ) nMin = 2; } *ppStruct = pStruct; return bRet; @@ -237175,7 +239600,7 @@ static void fts5SecureDeleteOverflow( pLeaf = 0; }else if( bDetailNone ){ break; - }else if( iNext>=pLeaf->szLeaf || iNext<4 ){ + }else if( iNext>=pLeaf->szLeaf || pLeaf->nnszLeaf || iNext<4 ){ p->rc = FTS5_CORRUPT; break; }else{ @@ -237194,9 +239619,13 @@ static void fts5SecureDeleteOverflow( int i1 = pLeaf->szLeaf; int i2 = 0; + i1 += fts5GetVarint32(&aPg[i1], iFirst); + if( iFirstrc = FTS5_CORRUPT; + break; + } aIdx = sqlite3Fts5MallocZero(&p->rc, (pLeaf->nn-pLeaf->szLeaf)+2); if( aIdx==0 ) break; - i1 += fts5GetVarint32(&aPg[i1], iFirst); i2 = sqlite3Fts5PutVarint(aIdx, iFirst-nShift); if( i1nn ){ memcpy(&aIdx[i2], &aPg[i1], pLeaf->nn-i1); @@ -237379,7 +239808,9 @@ static void fts5DoSecureDelete( iOff += sqlite3Fts5PutVarint(&aPg[iOff], nPrefix); } iOff += sqlite3Fts5PutVarint(&aPg[iOff], nSuffix); - if( nPrefix2>nPrefix ){ + if( nPrefix2>pSeg->term.n ){ + p->rc = FTS5_CORRUPT; + }else if( nPrefix2>nPrefix ){ memcpy(&aPg[iOff], &pSeg->term.p[nPrefix], nPrefix2-nPrefix); iOff += (nPrefix2-nPrefix); } @@ -237516,187 +239947,197 @@ static void fts5FlushOneHash(Fts5Index *p){ /* Obtain a reference to the index structure and allocate a new segment-id ** for the new level-0 segment. */ pStruct = fts5StructureRead(p); - iSegid = fts5AllocateSegid(p, pStruct); fts5StructureInvalidate(p); - if( iSegid ){ - const int pgsz = p->pConfig->pgsz; - int eDetail = p->pConfig->eDetail; - int bSecureDelete = p->pConfig->bSecureDelete; - Fts5StructureSegment *pSeg; /* New segment within pStruct */ - Fts5Buffer *pBuf; /* Buffer in which to assemble leaf page */ - Fts5Buffer *pPgidx; /* Buffer in which to assemble pgidx */ + if( sqlite3Fts5HashIsEmpty(pHash)==0 ){ + iSegid = fts5AllocateSegid(p, pStruct); + if( iSegid ){ + const int pgsz = p->pConfig->pgsz; + int eDetail = p->pConfig->eDetail; + int bSecureDelete = p->pConfig->bSecureDelete; + Fts5StructureSegment *pSeg; /* New segment within pStruct */ + Fts5Buffer *pBuf; /* Buffer in which to assemble leaf page */ + Fts5Buffer *pPgidx; /* Buffer in which to assemble pgidx */ - Fts5SegWriter writer; - fts5WriteInit(p, &writer, iSegid); + Fts5SegWriter writer; + fts5WriteInit(p, &writer, iSegid); - pBuf = &writer.writer.buf; - pPgidx = &writer.writer.pgidx; + pBuf = &writer.writer.buf; + pPgidx = &writer.writer.pgidx; - /* fts5WriteInit() should have initialized the buffers to (most likely) - ** the maximum space required. */ - assert( p->rc || pBuf->nSpace>=(pgsz + FTS5_DATA_PADDING) ); - assert( p->rc || pPgidx->nSpace>=(pgsz + FTS5_DATA_PADDING) ); + /* fts5WriteInit() should have initialized the buffers to (most likely) + ** the maximum space required. */ + assert( p->rc || pBuf->nSpace>=(pgsz + FTS5_DATA_PADDING) ); + assert( p->rc || pPgidx->nSpace>=(pgsz + FTS5_DATA_PADDING) ); - /* Begin scanning through hash table entries. This loop runs once for each - ** term/doclist currently stored within the hash table. */ - if( p->rc==SQLITE_OK ){ - p->rc = sqlite3Fts5HashScanInit(pHash, 0, 0); - } - while( p->rc==SQLITE_OK && 0==sqlite3Fts5HashScanEof(pHash) ){ - const char *zTerm; /* Buffer containing term */ - int nTerm; /* Size of zTerm in bytes */ - const u8 *pDoclist; /* Pointer to doclist for this term */ - int nDoclist; /* Size of doclist in bytes */ - - /* Get the term and doclist for this entry. */ - sqlite3Fts5HashScanEntry(pHash, &zTerm, &pDoclist, &nDoclist); - nTerm = (int)strlen(zTerm); - if( bSecureDelete==0 ){ - fts5WriteAppendTerm(p, &writer, nTerm, (const u8*)zTerm); - if( p->rc!=SQLITE_OK ) break; - assert( writer.bFirstRowidInPage==0 ); + /* Begin scanning through hash table entries. This loop runs once for each + ** term/doclist currently stored within the hash table. */ + if( p->rc==SQLITE_OK ){ + p->rc = sqlite3Fts5HashScanInit(pHash, 0, 0); } + while( p->rc==SQLITE_OK && 0==sqlite3Fts5HashScanEof(pHash) ){ + const char *zTerm; /* Buffer containing term */ + int nTerm; /* Size of zTerm in bytes */ + const u8 *pDoclist; /* Pointer to doclist for this term */ + int nDoclist; /* Size of doclist in bytes */ - if( !bSecureDelete && pgsz>=(pBuf->n + pPgidx->n + nDoclist + 1) ){ - /* The entire doclist will fit on the current leaf. */ - fts5BufferSafeAppendBlob(pBuf, pDoclist, nDoclist); - }else{ - int bTermWritten = !bSecureDelete; - i64 iRowid = 0; - i64 iPrev = 0; - int iOff = 0; + /* Get the term and doclist for this entry. */ + sqlite3Fts5HashScanEntry(pHash, &zTerm, &pDoclist, &nDoclist); + nTerm = (int)strlen(zTerm); + if( bSecureDelete==0 ){ + fts5WriteAppendTerm(p, &writer, nTerm, (const u8*)zTerm); + if( p->rc!=SQLITE_OK ) break; + assert( writer.bFirstRowidInPage==0 ); + } - /* The entire doclist will not fit on this leaf. The following - ** loop iterates through the poslists that make up the current - ** doclist. */ - while( p->rc==SQLITE_OK && iOff=(pBuf->n + pPgidx->n + nDoclist + 1) ){ + /* The entire doclist will fit on the current leaf. */ + fts5BufferSafeAppendBlob(pBuf, pDoclist, nDoclist); + }else{ + int bTermWritten = !bSecureDelete; + i64 iRowid = 0; + i64 iPrev = 0; + int iOff = 0; - /* If in secure delete mode, and if this entry in the poslist is - ** in fact a delete, then edit the existing segments directly - ** using fts5FlushSecureDelete(). */ - if( bSecureDelete ){ - if( eDetail==FTS5_DETAIL_NONE ){ - if( iOffrc==SQLITE_OK && iOffrc!=SQLITE_OK || pDoclist[iOff]==0x01 ){ iOff++; - nDoclist = 0; - }else{ continue; } } - }else if( (pDoclist[iOff] & 0x01) ){ - fts5FlushSecureDelete(p, pStruct, zTerm, iRowid); - if( p->rc!=SQLITE_OK || pDoclist[iOff]==0x01 ){ - iOff++; - continue; - } } - } - if( p->rc==SQLITE_OK && bTermWritten==0 ){ - fts5WriteAppendTerm(p, &writer, nTerm, (const u8*)zTerm); - bTermWritten = 1; - assert( p->rc!=SQLITE_OK || writer.bFirstRowidInPage==0 ); - } + if( p->rc==SQLITE_OK && bTermWritten==0 ){ + fts5WriteAppendTerm(p, &writer, nTerm, (const u8*)zTerm); + bTermWritten = 1; + assert( p->rc!=SQLITE_OK || writer.bFirstRowidInPage==0 ); + } - if( writer.bFirstRowidInPage ){ - fts5PutU16(&pBuf->p[0], (u16)pBuf->n); /* first rowid on page */ - pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iRowid); - writer.bFirstRowidInPage = 0; - fts5WriteDlidxAppend(p, &writer, iRowid); - }else{ - pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iRowid-iPrev); - } - if( p->rc!=SQLITE_OK ) break; - assert( pBuf->n<=pBuf->nSpace ); - iPrev = iRowid; + if( writer.bFirstRowidInPage ){ + fts5PutU16(&pBuf->p[0], (u16)pBuf->n); /* first rowid on page */ + pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iRowid); + writer.bFirstRowidInPage = 0; + fts5WriteDlidxAppend(p, &writer, iRowid); + }else{ + u64 iRowidDelta = (u64)iRowid - (u64)iPrev; + pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iRowidDelta); + } + if( p->rc!=SQLITE_OK ) break; + assert( pBuf->n<=pBuf->nSpace ); + iPrev = iRowid; - if( eDetail==FTS5_DETAIL_NONE ){ - if( iOffp[pBuf->n++] = 0; - iOff++; + if( eDetail==FTS5_DETAIL_NONE ){ if( iOffp[pBuf->n++] = 0; iOff++; + if( iOffp[pBuf->n++] = 0; + iOff++; + } + } + if( (pBuf->n + pPgidx->n)>=pgsz ){ + fts5WriteFlushLeaf(p, &writer); } - } - if( (pBuf->n + pPgidx->n)>=pgsz ){ - fts5WriteFlushLeaf(p, &writer); - } - }else{ - int bDummy; - int nPos; - int nCopy = fts5GetPoslistSize(&pDoclist[iOff], &nPos, &bDummy); - nCopy += nPos; - if( (pBuf->n + pPgidx->n + nCopy) <= pgsz ){ - /* The entire poslist will fit on the current leaf. So copy - ** it in one go. */ - fts5BufferSafeAppendBlob(pBuf, &pDoclist[iOff], nCopy); }else{ - /* The entire poslist will not fit on this leaf. So it needs - ** to be broken into sections. The only qualification being - ** that each varint must be stored contiguously. */ - const u8 *pPoslist = &pDoclist[iOff]; - int iPos = 0; - while( p->rc==SQLITE_OK ){ - int nSpace = pgsz - pBuf->n - pPgidx->n; - int n = 0; - if( (nCopy - iPos)<=nSpace ){ - n = nCopy - iPos; - }else{ - n = fts5PoslistPrefix(&pPoslist[iPos], nSpace); + int bDummy; + int nPos; + int nCopy = fts5GetPoslistSize(&pDoclist[iOff], &nPos, &bDummy); + nCopy += nPos; + if( (pBuf->n + pPgidx->n + nCopy) <= pgsz ){ + /* The entire poslist will fit on the current leaf. So copy + ** it in one go. */ + fts5BufferSafeAppendBlob(pBuf, &pDoclist[iOff], nCopy); + }else{ + /* The entire poslist will not fit on this leaf. So it needs + ** to be broken into sections. The only qualification being + ** that each varint must be stored contiguously. */ + const u8 *pPoslist = &pDoclist[iOff]; + int iPos = 0; + while( p->rc==SQLITE_OK ){ + int nSpace = pgsz - pBuf->n - pPgidx->n; + int n = 0; + if( (nCopy - iPos)<=nSpace ){ + n = nCopy - iPos; + }else{ + n = fts5PoslistPrefix(&pPoslist[iPos], nSpace); + } + assert( n>0 ); + fts5BufferSafeAppendBlob(pBuf, &pPoslist[iPos], n); + iPos += n; + if( (pBuf->n + pPgidx->n)>=pgsz ){ + fts5WriteFlushLeaf(p, &writer); + } + if( iPos>=nCopy ) break; } - assert( n>0 ); - fts5BufferSafeAppendBlob(pBuf, &pPoslist[iPos], n); - iPos += n; - if( (pBuf->n + pPgidx->n)>=pgsz ){ - fts5WriteFlushLeaf(p, &writer); - } - if( iPos>=nCopy ) break; } + iOff += nCopy; } - iOff += nCopy; } } - } - /* TODO2: Doclist terminator written here. */ - /* pBuf->p[pBuf->n++] = '\0'; */ - assert( pBuf->n<=pBuf->nSpace ); - if( p->rc==SQLITE_OK ) sqlite3Fts5HashScanNext(pHash); - } - sqlite3Fts5HashClear(pHash); - fts5WriteFinish(p, &writer, &pgnoLast); + /* TODO2: Doclist terminator written here. */ + /* pBuf->p[pBuf->n++] = '\0'; */ + assert( pBuf->n<=pBuf->nSpace ); + if( p->rc==SQLITE_OK ) sqlite3Fts5HashScanNext(pHash); + } + sqlite3Fts5HashClear(pHash); + fts5WriteFinish(p, &writer, &pgnoLast); - assert( p->rc!=SQLITE_OK || bSecureDelete || pgnoLast>0 ); - if( pgnoLast>0 ){ - /* Update the Fts5Structure. It is written back to the database by the - ** fts5StructureRelease() call below. */ - if( pStruct->nLevel==0 ){ - fts5StructureAddLevel(&p->rc, &pStruct); + assert( p->rc!=SQLITE_OK || bSecureDelete || pgnoLast>0 ); + if( pgnoLast>0 ){ + /* Update the Fts5Structure. It is written back to the database by the + ** fts5StructureRelease() call below. */ + if( pStruct->nLevel==0 ){ + fts5StructureAddLevel(&p->rc, &pStruct); + } + fts5StructureExtendLevel(&p->rc, pStruct, 0, 1, 0); + if( p->rc==SQLITE_OK ){ + pSeg = &pStruct->aLevel[0].aSeg[ pStruct->aLevel[0].nSeg++ ]; + pSeg->iSegid = iSegid; + pSeg->pgnoFirst = 1; + pSeg->pgnoLast = pgnoLast; + if( pStruct->nOriginCntr>0 ){ + pSeg->iOrigin1 = pStruct->nOriginCntr; + pSeg->iOrigin2 = pStruct->nOriginCntr; + pSeg->nEntry = p->nPendingRow; + pStruct->nOriginCntr++; + } + pStruct->nSegment++; + } + fts5StructurePromote(p, 0, pStruct); } - fts5StructureExtendLevel(&p->rc, pStruct, 0, 1, 0); - if( p->rc==SQLITE_OK ){ - pSeg = &pStruct->aLevel[0].aSeg[ pStruct->aLevel[0].nSeg++ ]; - pSeg->iSegid = iSegid; - pSeg->pgnoFirst = 1; - pSeg->pgnoLast = pgnoLast; - pStruct->nSegment++; - } - fts5StructurePromote(p, 0, pStruct); } } - fts5IndexAutomerge(p, &pStruct, pgnoLast); + fts5IndexAutomerge(p, &pStruct, pgnoLast + p->nContentlessDelete); fts5IndexCrisismerge(p, &pStruct); fts5StructureWrite(p, pStruct); fts5StructureRelease(pStruct); + p->nContentlessDelete = 0; } /* @@ -237704,10 +240145,11 @@ static void fts5FlushOneHash(Fts5Index *p){ */ static void fts5IndexFlush(Fts5Index *p){ /* Unless it is empty, flush the hash table to disk */ - if( p->nPendingData ){ + if( p->nPendingData || p->nContentlessDelete ){ assert( p->pHash ); - p->nPendingData = 0; fts5FlushOneHash(p); + p->nPendingData = 0; + p->nPendingRow = 0; } } @@ -237723,17 +240165,22 @@ static Fts5Structure *fts5IndexOptimizeStruct( /* Figure out if this structure requires optimization. A structure does ** not require optimization if either: ** - ** + it consists of fewer than two segments, or - ** + all segments are on the same level, or - ** + all segments except one are currently inputs to a merge operation. + ** 1. it consists of fewer than two segments, or + ** 2. all segments are on the same level, or + ** 3. all segments except one are currently inputs to a merge operation. ** - ** In the first case, return NULL. In the second, increment the ref-count - ** on *pStruct and return a copy of the pointer to it. + ** In the first case, if there are no tombstone hash pages, return NULL. In + ** the second, increment the ref-count on *pStruct and return a copy of the + ** pointer to it. */ - if( nSeg<2 ) return 0; + if( nSeg==0 ) return 0; for(i=0; inLevel; i++){ int nThis = pStruct->aLevel[i].nSeg; - if( nThis==nSeg || (nThis==nSeg-1 && pStruct->aLevel[i].nMerge==nThis) ){ + int nMerge = pStruct->aLevel[i].nMerge; + if( nThis>0 && (nThis==nSeg || (nThis==nSeg-1 && nMerge==nThis)) ){ + if( nSeg==1 && nThis==1 && pStruct->aLevel[i].aSeg[0].nPgTombstone==0 ){ + return 0; + } fts5StructureRef(pStruct); return pStruct; } @@ -237749,6 +240196,7 @@ static Fts5Structure *fts5IndexOptimizeStruct( pNew->nLevel = MIN(pStruct->nLevel+1, FTS5_MAX_LEVEL); pNew->nRef = 1; pNew->nWriteCounter = pStruct->nWriteCounter; + pNew->nOriginCntr = pStruct->nOriginCntr; pLvl = &pNew->aLevel[pNew->nLevel-1]; pLvl->aSeg = (Fts5StructureSegment*)sqlite3Fts5MallocZero(&p->rc, nByte); if( pLvl->aSeg ){ @@ -237779,6 +240227,7 @@ static int sqlite3Fts5IndexOptimize(Fts5Index *p){ assert( p->rc==SQLITE_OK ); fts5IndexFlush(p); + assert( p->nContentlessDelete==0 ); pStruct = fts5StructureRead(p); fts5StructureInvalidate(p); @@ -237808,7 +240257,10 @@ static int sqlite3Fts5IndexOptimize(Fts5Index *p){ ** INSERT command. */ static int sqlite3Fts5IndexMerge(Fts5Index *p, int nMerge){ - Fts5Structure *pStruct = fts5StructureRead(p); + Fts5Structure *pStruct = 0; + + fts5IndexFlush(p); + pStruct = fts5StructureRead(p); if( pStruct ){ int nMin = p->pConfig->nUsermerge; fts5StructureInvalidate(p); @@ -237816,7 +240268,7 @@ static int sqlite3Fts5IndexMerge(Fts5Index *p, int nMerge){ Fts5Structure *pNew = fts5IndexOptimizeStruct(p, pStruct); fts5StructureRelease(pStruct); pStruct = pNew; - nMin = 2; + nMin = 1; nMerge = nMerge*-1; } if( pStruct && pStruct->nLevel ){ @@ -238330,6 +240782,9 @@ static int sqlite3Fts5IndexBeginWrite(Fts5Index *p, int bDelete, i64 iRowid){ p->iWriteRowid = iRowid; p->bDelete = bDelete; + if( bDelete==0 ){ + p->nPendingRow++; + } return fts5IndexReturn(p); } @@ -238367,6 +240822,9 @@ static int sqlite3Fts5IndexReinit(Fts5Index *p){ fts5StructureInvalidate(p); fts5IndexDiscardData(p); memset(&s, 0, sizeof(Fts5Structure)); + if( p->pConfig->bContentlessDelete ){ + s.nOriginCntr = 1; + } fts5DataWrite(p, FTS5_AVERAGES_ROWID, (const u8*)"", 0); fts5StructureWrite(p, &s); return fts5IndexReturn(p); @@ -238758,6 +241216,347 @@ static int sqlite3Fts5IndexLoadConfig(Fts5Index *p){ return fts5IndexReturn(p); } +/* +** Retrieve the origin value that will be used for the segment currently +** being accumulated in the in-memory hash table when it is flushed to +** disk. If successful, SQLITE_OK is returned and (*piOrigin) set to +** the queried value. Or, if an error occurs, an error code is returned +** and the final value of (*piOrigin) is undefined. +*/ +static int sqlite3Fts5IndexGetOrigin(Fts5Index *p, i64 *piOrigin){ + Fts5Structure *pStruct; + pStruct = fts5StructureRead(p); + if( pStruct ){ + *piOrigin = pStruct->nOriginCntr; + fts5StructureRelease(pStruct); + } + return fts5IndexReturn(p); +} + +/* +** Buffer pPg contains a page of a tombstone hash table - one of nPg pages +** associated with the same segment. This function adds rowid iRowid to +** the hash table. The caller is required to guarantee that there is at +** least one free slot on the page. +** +** If parameter bForce is false and the hash table is deemed to be full +** (more than half of the slots are occupied), then non-zero is returned +** and iRowid not inserted. Or, if bForce is true or if the hash table page +** is not full, iRowid is inserted and zero returned. +*/ +static int fts5IndexTombstoneAddToPage( + Fts5Data *pPg, + int bForce, + int nPg, + u64 iRowid +){ + const int szKey = TOMBSTONE_KEYSIZE(pPg); + const int nSlot = TOMBSTONE_NSLOT(pPg); + const int nElem = fts5GetU32(&pPg->p[4]); + int iSlot = (iRowid / nPg) % nSlot; + int nCollide = nSlot; + + if( szKey==4 && iRowid>0xFFFFFFFF ) return 2; + if( iRowid==0 ){ + pPg->p[1] = 0x01; + return 0; + } + + if( bForce==0 && nElem>=(nSlot/2) ){ + return 1; + } + + fts5PutU32(&pPg->p[4], nElem+1); + if( szKey==4 ){ + u32 *aSlot = (u32*)&pPg->p[8]; + while( aSlot[iSlot] ){ + iSlot = (iSlot + 1) % nSlot; + if( nCollide--==0 ) return 0; + } + fts5PutU32((u8*)&aSlot[iSlot], (u32)iRowid); + }else{ + u64 *aSlot = (u64*)&pPg->p[8]; + while( aSlot[iSlot] ){ + iSlot = (iSlot + 1) % nSlot; + if( nCollide--==0 ) return 0; + } + fts5PutU64((u8*)&aSlot[iSlot], iRowid); + } + + return 0; +} + +/* +** This function attempts to build a new hash containing all the keys +** currently in the tombstone hash table for segment pSeg. The new +** hash will be stored in the nOut buffers passed in array apOut[]. +** All pages of the new hash use key-size szKey (4 or 8). +** +** Return 0 if the hash is successfully rebuilt into the nOut pages. +** Or non-zero if it is not (because one page became overfull). In this +** case the caller should retry with a larger nOut parameter. +** +** Parameter pData1 is page iPg1 of the hash table being rebuilt. +*/ +static int fts5IndexTombstoneRehash( + Fts5Index *p, + Fts5StructureSegment *pSeg, /* Segment to rebuild hash of */ + Fts5Data *pData1, /* One page of current hash - or NULL */ + int iPg1, /* Which page of the current hash is pData1 */ + int szKey, /* 4 or 8, the keysize */ + int nOut, /* Number of output pages */ + Fts5Data **apOut /* Array of output hash pages */ +){ + int ii; + int res = 0; + + /* Initialize the headers of all the output pages */ + for(ii=0; iip[0] = szKey; + fts5PutU32(&apOut[ii]->p[4], 0); + } + + /* Loop through the current pages of the hash table. */ + for(ii=0; res==0 && iinPgTombstone; ii++){ + Fts5Data *pData = 0; /* Page ii of the current hash table */ + Fts5Data *pFree = 0; /* Free this at the end of the loop */ + + if( iPg1==ii ){ + pData = pData1; + }else{ + pFree = pData = fts5DataRead(p, FTS5_TOMBSTONE_ROWID(pSeg->iSegid, ii)); + } + + if( pData ){ + int szKeyIn = TOMBSTONE_KEYSIZE(pData); + int nSlotIn = (pData->nn - 8) / szKeyIn; + int iIn; + for(iIn=0; iInp[8]; + if( aSlot[iIn] ) iVal = fts5GetU32((u8*)&aSlot[iIn]); + }else{ + u64 *aSlot = (u64*)&pData->p[8]; + if( aSlot[iIn] ) iVal = fts5GetU64((u8*)&aSlot[iIn]); + } + + /* If iVal is not 0 at this point, insert it into the new hash table */ + if( iVal ){ + Fts5Data *pPg = apOut[(iVal % nOut)]; + res = fts5IndexTombstoneAddToPage(pPg, 0, nOut, iVal); + if( res ) break; + } + } + + /* If this is page 0 of the old hash, copy the rowid-0-flag from the + ** old hash to the new. */ + if( ii==0 ){ + apOut[0]->p[1] = pData->p[1]; + } + } + fts5DataRelease(pFree); + } + + return res; +} + +/* +** This is called to rebuild the hash table belonging to segment pSeg. +** If parameter pData1 is not NULL, then one page of the existing hash table +** has already been loaded - pData1, which is page iPg1. The key-size for +** the new hash table is szKey (4 or 8). +** +** If successful, the new hash table is not written to disk. Instead, +** output parameter (*pnOut) is set to the number of pages in the new +** hash table, and (*papOut) to point to an array of buffers containing +** the new page data. +** +** If an error occurs, an error code is left in the Fts5Index object and +** both output parameters set to 0 before returning. +*/ +static void fts5IndexTombstoneRebuild( + Fts5Index *p, + Fts5StructureSegment *pSeg, /* Segment to rebuild hash of */ + Fts5Data *pData1, /* One page of current hash - or NULL */ + int iPg1, /* Which page of the current hash is pData1 */ + int szKey, /* 4 or 8, the keysize */ + int *pnOut, /* OUT: Number of output pages */ + Fts5Data ***papOut /* OUT: Output hash pages */ +){ + const int MINSLOT = 32; + int nSlotPerPage = MAX(MINSLOT, (p->pConfig->pgsz - 8) / szKey); + int nSlot = 0; /* Number of slots in each output page */ + int nOut = 0; + + /* Figure out how many output pages (nOut) and how many slots per + ** page (nSlot). There are three possibilities: + ** + ** 1. The hash table does not yet exist. In this case the new hash + ** table will consist of a single page with MINSLOT slots. + ** + ** 2. The hash table exists but is currently a single page. In this + ** case an attempt is made to grow the page to accommodate the new + ** entry. The page is allowed to grow up to nSlotPerPage (see above) + ** slots. + ** + ** 3. The hash table already consists of more than one page, or of + ** a single page already so large that it cannot be grown. In this + ** case the new hash consists of (nPg*2+1) pages of nSlotPerPage + ** slots each, where nPg is the current number of pages in the + ** hash table. + */ + if( pSeg->nPgTombstone==0 ){ + /* Case 1. */ + nOut = 1; + nSlot = MINSLOT; + }else if( pSeg->nPgTombstone==1 ){ + /* Case 2. */ + int nElem = (int)fts5GetU32(&pData1->p[4]); + assert( pData1 && iPg1==0 ); + nOut = 1; + nSlot = MAX(nElem*4, MINSLOT); + if( nSlot>nSlotPerPage ) nOut = 0; + } + if( nOut==0 ){ + /* Case 3. */ + nOut = (pSeg->nPgTombstone * 2 + 1); + nSlot = nSlotPerPage; + } + + /* Allocate the required array and output pages */ + while( 1 ){ + int res = 0; + int ii = 0; + int szPage = 0; + Fts5Data **apOut = 0; + + /* Allocate space for the new hash table */ + assert( nSlot>=MINSLOT ); + apOut = (Fts5Data**)sqlite3Fts5MallocZero(&p->rc, sizeof(Fts5Data*) * nOut); + szPage = 8 + nSlot*szKey; + for(ii=0; iirc, + sizeof(Fts5Data)+szPage + ); + if( pNew ){ + pNew->nn = szPage; + pNew->p = (u8*)&pNew[1]; + apOut[ii] = pNew; + } + } + + /* Rebuild the hash table. */ + if( p->rc==SQLITE_OK ){ + res = fts5IndexTombstoneRehash(p, pSeg, pData1, iPg1, szKey, nOut, apOut); + } + if( res==0 ){ + if( p->rc ){ + fts5IndexFreeArray(apOut, nOut); + apOut = 0; + nOut = 0; + } + *pnOut = nOut; + *papOut = apOut; + break; + } + + /* If control flows to here, it was not possible to rebuild the hash + ** table. Free all buffers and then try again with more pages. */ + assert( p->rc==SQLITE_OK ); + fts5IndexFreeArray(apOut, nOut); + nSlot = nSlotPerPage; + nOut = nOut*2 + 1; + } +} + + +/* +** Add a tombstone for rowid iRowid to segment pSeg. +*/ +static void fts5IndexTombstoneAdd( + Fts5Index *p, + Fts5StructureSegment *pSeg, + u64 iRowid +){ + Fts5Data *pPg = 0; + int iPg = -1; + int szKey = 0; + int nHash = 0; + Fts5Data **apHash = 0; + + p->nContentlessDelete++; + + if( pSeg->nPgTombstone>0 ){ + iPg = iRowid % pSeg->nPgTombstone; + pPg = fts5DataRead(p, FTS5_TOMBSTONE_ROWID(pSeg->iSegid,iPg)); + if( pPg==0 ){ + assert( p->rc!=SQLITE_OK ); + return; + } + + if( 0==fts5IndexTombstoneAddToPage(pPg, 0, pSeg->nPgTombstone, iRowid) ){ + fts5DataWrite(p, FTS5_TOMBSTONE_ROWID(pSeg->iSegid,iPg), pPg->p, pPg->nn); + fts5DataRelease(pPg); + return; + } + } + + /* Have to rebuild the hash table. First figure out the key-size (4 or 8). */ + szKey = pPg ? TOMBSTONE_KEYSIZE(pPg) : 4; + if( iRowid>0xFFFFFFFF ) szKey = 8; + + /* Rebuild the hash table */ + fts5IndexTombstoneRebuild(p, pSeg, pPg, iPg, szKey, &nHash, &apHash); + assert( p->rc==SQLITE_OK || (nHash==0 && apHash==0) ); + + /* If all has succeeded, write the new rowid into one of the new hash + ** table pages, then write them all out to disk. */ + if( nHash ){ + int ii = 0; + fts5IndexTombstoneAddToPage(apHash[iRowid % nHash], 1, nHash, iRowid); + for(ii=0; iiiSegid, ii); + fts5DataWrite(p, iTombstoneRowid, apHash[ii]->p, apHash[ii]->nn); + } + pSeg->nPgTombstone = nHash; + fts5StructureWrite(p, p->pStruct); + } + + fts5DataRelease(pPg); + fts5IndexFreeArray(apHash, nHash); +} + +/* +** Add iRowid to the tombstone list of the segment or segments that contain +** rows from origin iOrigin. Return SQLITE_OK if successful, or an SQLite +** error code otherwise. +*/ +static int sqlite3Fts5IndexContentlessDelete(Fts5Index *p, i64 iOrigin, i64 iRowid){ + Fts5Structure *pStruct; + pStruct = fts5StructureRead(p); + if( pStruct ){ + int bFound = 0; /* True after pSeg->nEntryTombstone incr. */ + int iLvl; + for(iLvl=pStruct->nLevel-1; iLvl>=0; iLvl--){ + int iSeg; + for(iSeg=pStruct->aLevel[iLvl].nSeg-1; iSeg>=0; iSeg--){ + Fts5StructureSegment *pSeg = &pStruct->aLevel[iLvl].aSeg[iSeg]; + if( pSeg->iOrigin1<=(u64)iOrigin && pSeg->iOrigin2>=(u64)iOrigin ){ + if( bFound==0 ){ + pSeg->nEntryTombstone++; + bFound = 1; + } + fts5IndexTombstoneAdd(p, pSeg, iRowid); + } + } + } + fts5StructureRelease(pStruct); + } + return fts5IndexReturn(p); +} /************************************************************************* ************************************************************************** @@ -239309,13 +242108,14 @@ static int sqlite3Fts5IndexIntegrityCheck(Fts5Index *p, u64 cksum, int bUseCksum ** function only. */ -#ifdef SQLITE_TEST +#if defined(SQLITE_TEST) || defined(SQLITE_FTS5_DEBUG) /* ** Decode a segment-data rowid from the %_data table. This function is ** the opposite of macro FTS5_SEGMENT_ROWID(). */ static void fts5DecodeRowid( i64 iRowid, /* Rowid from %_data table */ + int *pbTombstone, /* OUT: Tombstone hash flag */ int *piSegid, /* OUT: Segment id */ int *pbDlidx, /* OUT: Dlidx flag */ int *piHeight, /* OUT: Height */ @@ -239331,13 +242131,16 @@ static void fts5DecodeRowid( iRowid >>= FTS5_DATA_DLI_B; *piSegid = (int)(iRowid & (((i64)1 << FTS5_DATA_ID_B) - 1)); -} -#endif /* SQLITE_TEST */ + iRowid >>= FTS5_DATA_ID_B; -#ifdef SQLITE_TEST + *pbTombstone = (int)(iRowid & 0x0001); +} +#endif /* SQLITE_TEST || SQLITE_FTS5_DEBUG */ + +#if defined(SQLITE_TEST) || defined(SQLITE_FTS5_DEBUG) static void fts5DebugRowid(int *pRc, Fts5Buffer *pBuf, i64 iKey){ - int iSegid, iHeight, iPgno, bDlidx; /* Rowid compenents */ - fts5DecodeRowid(iKey, &iSegid, &bDlidx, &iHeight, &iPgno); + int iSegid, iHeight, iPgno, bDlidx, bTomb; /* Rowid compenents */ + fts5DecodeRowid(iKey, &bTomb, &iSegid, &bDlidx, &iHeight, &iPgno); if( iSegid==0 ){ if( iKey==FTS5_AVERAGES_ROWID ){ @@ -239347,14 +242150,16 @@ static void fts5DebugRowid(int *pRc, Fts5Buffer *pBuf, i64 iKey){ } } else{ - sqlite3Fts5BufferAppendPrintf(pRc, pBuf, "{%ssegid=%d h=%d pgno=%d}", - bDlidx ? "dlidx " : "", iSegid, iHeight, iPgno + sqlite3Fts5BufferAppendPrintf(pRc, pBuf, "{%s%ssegid=%d h=%d pgno=%d}", + bDlidx ? "dlidx " : "", + bTomb ? "tombstone " : "", + iSegid, iHeight, iPgno ); } } -#endif /* SQLITE_TEST */ +#endif /* SQLITE_TEST || SQLITE_FTS5_DEBUG */ -#ifdef SQLITE_TEST +#if defined(SQLITE_TEST) || defined(SQLITE_FTS5_DEBUG) static void fts5DebugStructure( int *pRc, /* IN/OUT: error code */ Fts5Buffer *pBuf, @@ -239369,16 +242174,22 @@ static void fts5DebugStructure( ); for(iSeg=0; iSegnSeg; iSeg++){ Fts5StructureSegment *pSeg = &pLvl->aSeg[iSeg]; - sqlite3Fts5BufferAppendPrintf(pRc, pBuf, " {id=%d leaves=%d..%d}", + sqlite3Fts5BufferAppendPrintf(pRc, pBuf, " {id=%d leaves=%d..%d", pSeg->iSegid, pSeg->pgnoFirst, pSeg->pgnoLast ); + if( pSeg->iOrigin1>0 ){ + sqlite3Fts5BufferAppendPrintf(pRc, pBuf, " origin=%lld..%lld", + pSeg->iOrigin1, pSeg->iOrigin2 + ); + } + sqlite3Fts5BufferAppendPrintf(pRc, pBuf, "}"); } sqlite3Fts5BufferAppendPrintf(pRc, pBuf, "}"); } } -#endif /* SQLITE_TEST */ +#endif /* SQLITE_TEST || SQLITE_FTS5_DEBUG */ -#ifdef SQLITE_TEST +#if defined(SQLITE_TEST) || defined(SQLITE_FTS5_DEBUG) /* ** This is part of the fts5_decode() debugging aid. ** @@ -239403,9 +242214,9 @@ static void fts5DecodeStructure( fts5DebugStructure(pRc, pBuf, p); fts5StructureRelease(p); } -#endif /* SQLITE_TEST */ +#endif /* SQLITE_TEST || SQLITE_FTS5_DEBUG */ -#ifdef SQLITE_TEST +#if defined(SQLITE_TEST) || defined(SQLITE_FTS5_DEBUG) /* ** This is part of the fts5_decode() debugging aid. ** @@ -239428,9 +242239,9 @@ static void fts5DecodeAverages( zSpace = " "; } } -#endif /* SQLITE_TEST */ +#endif /* SQLITE_TEST || SQLITE_FTS5_DEBUG */ -#ifdef SQLITE_TEST +#if defined(SQLITE_TEST) || defined(SQLITE_FTS5_DEBUG) /* ** Buffer (a/n) is assumed to contain a list of serialized varints. Read ** each varint and append its string representation to buffer pBuf. Return @@ -239447,9 +242258,9 @@ static int fts5DecodePoslist(int *pRc, Fts5Buffer *pBuf, const u8 *a, int n){ } return iOff; } -#endif /* SQLITE_TEST */ +#endif /* SQLITE_TEST || SQLITE_FTS5_DEBUG */ -#ifdef SQLITE_TEST +#if defined(SQLITE_TEST) || defined(SQLITE_FTS5_DEBUG) /* ** The start of buffer (a/n) contains the start of a doclist. The doclist ** may or may not finish within the buffer. This function appends a text @@ -239482,9 +242293,9 @@ static int fts5DecodeDoclist(int *pRc, Fts5Buffer *pBuf, const u8 *a, int n){ return iOff; } -#endif /* SQLITE_TEST */ +#endif /* SQLITE_TEST || SQLITE_FTS5_DEBUG */ -#ifdef SQLITE_TEST +#if defined(SQLITE_TEST) || defined(SQLITE_FTS5_DEBUG) /* ** This function is part of the fts5_decode() debugging function. It is ** only ever used with detail=none tables. @@ -239525,9 +242336,9 @@ static void fts5DecodeRowidList( sqlite3Fts5BufferAppendPrintf(pRc, pBuf, " %lld%s", iRowid, zApp); } } -#endif /* SQLITE_TEST */ +#endif /* SQLITE_TEST || SQLITE_FTS5_DEBUG */ -#ifdef SQLITE_TEST +#if defined(SQLITE_TEST) || defined(SQLITE_FTS5_DEBUG) /* ** The implementation of user-defined scalar function fts5_decode(). */ @@ -239538,6 +242349,7 @@ static void fts5DecodeFunction( ){ i64 iRowid; /* Rowid for record being decoded */ int iSegid,iHeight,iPgno,bDlidx;/* Rowid components */ + int bTomb; const u8 *aBlob; int n; /* Record to decode */ u8 *a = 0; Fts5Buffer s; /* Build up text to return here */ @@ -239560,7 +242372,7 @@ static void fts5DecodeFunction( if( a==0 ) goto decode_out; if( n>0 ) memcpy(a, aBlob, n); - fts5DecodeRowid(iRowid, &iSegid, &bDlidx, &iHeight, &iPgno); + fts5DecodeRowid(iRowid, &bTomb, &iSegid, &bDlidx, &iHeight, &iPgno); fts5DebugRowid(&rc, &s, iRowid); if( bDlidx ){ @@ -239579,6 +242391,28 @@ static void fts5DecodeFunction( " %d(%lld)", lvl.iLeafPgno, lvl.iRowid ); } + }else if( bTomb ){ + u32 nElem = fts5GetU32(&a[4]); + int szKey = (aBlob[0]==4 || aBlob[0]==8) ? aBlob[0] : 8; + int nSlot = (n - 8) / szKey; + int ii; + sqlite3Fts5BufferAppendPrintf(&rc, &s, " nElem=%d", (int)nElem); + if( aBlob[1] ){ + sqlite3Fts5BufferAppendPrintf(&rc, &s, " 0"); + } + for(ii=0; iiszLeaf ){ + rc = FTS5_CORRUPT; + }else{ + fts5DecodeRowidList(&rc, &s, &a[iOff], iTermOff-iOff); + } iOff = iTermOff; if( iOffestimatedCost = (double)100; + pIdxInfo->estimatedRows = 100; + pIdxInfo->idxNum = 0; + for(i=0, p=pIdxInfo->aConstraint; inConstraint; i++, p++){ + if( p->usable==0 ) continue; + if( p->op==SQLITE_INDEX_CONSTRAINT_EQ && p->iColumn==11 ){ + rc = SQLITE_OK; + pIdxInfo->aConstraintUsage[i].omit = 1; + pIdxInfo->aConstraintUsage[i].argvIndex = 1; + break; + } + } + return rc; +} + +/* +** This method is the destructor for bytecodevtab objects. +*/ +static int fts5structDisconnectMethod(sqlite3_vtab *pVtab){ + Fts5StructVtab *p = (Fts5StructVtab*)pVtab; + sqlite3_free(p); + return SQLITE_OK; +} + +/* +** Constructor for a new bytecodevtab_cursor object. +*/ +static int fts5structOpenMethod(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCsr){ + int rc = SQLITE_OK; + Fts5StructVcsr *pNew = 0; + + pNew = sqlite3Fts5MallocZero(&rc, sizeof(*pNew)); + *ppCsr = (sqlite3_vtab_cursor*)pNew; + + return SQLITE_OK; +} + +/* +** Destructor for a bytecodevtab_cursor. +*/ +static int fts5structCloseMethod(sqlite3_vtab_cursor *cur){ + Fts5StructVcsr *pCsr = (Fts5StructVcsr*)cur; + fts5StructureRelease(pCsr->pStruct); + sqlite3_free(pCsr); + return SQLITE_OK; +} + + +/* +** Advance a bytecodevtab_cursor to its next row of output. +*/ +static int fts5structNextMethod(sqlite3_vtab_cursor *cur){ + Fts5StructVcsr *pCsr = (Fts5StructVcsr*)cur; + Fts5Structure *p = pCsr->pStruct; + + assert( pCsr->pStruct ); + pCsr->iSeg++; + pCsr->iRowid++; + while( pCsr->iLevelnLevel && pCsr->iSeg>=p->aLevel[pCsr->iLevel].nSeg ){ + pCsr->iLevel++; + pCsr->iSeg = 0; + } + if( pCsr->iLevel>=p->nLevel ){ + fts5StructureRelease(pCsr->pStruct); + pCsr->pStruct = 0; + } + return SQLITE_OK; +} + +/* +** Return TRUE if the cursor has been moved off of the last +** row of output. +*/ +static int fts5structEofMethod(sqlite3_vtab_cursor *cur){ + Fts5StructVcsr *pCsr = (Fts5StructVcsr*)cur; + return pCsr->pStruct==0; +} + +static int fts5structRowidMethod( + sqlite3_vtab_cursor *cur, + sqlite_int64 *piRowid +){ + Fts5StructVcsr *pCsr = (Fts5StructVcsr*)cur; + *piRowid = pCsr->iRowid; + return SQLITE_OK; +} + +/* +** Return values of columns for the row at which the bytecodevtab_cursor +** is currently pointing. +*/ +static int fts5structColumnMethod( + sqlite3_vtab_cursor *cur, /* The cursor */ + sqlite3_context *ctx, /* First argument to sqlite3_result_...() */ + int i /* Which column to return */ +){ + Fts5StructVcsr *pCsr = (Fts5StructVcsr*)cur; + Fts5Structure *p = pCsr->pStruct; + Fts5StructureSegment *pSeg = &p->aLevel[pCsr->iLevel].aSeg[pCsr->iSeg]; + + switch( i ){ + case 0: /* level */ + sqlite3_result_int(ctx, pCsr->iLevel); + break; + case 1: /* segment */ + sqlite3_result_int(ctx, pCsr->iSeg); + break; + case 2: /* merge */ + sqlite3_result_int(ctx, pCsr->iSeg < p->aLevel[pCsr->iLevel].nMerge); + break; + case 3: /* segid */ + sqlite3_result_int(ctx, pSeg->iSegid); + break; + case 4: /* leaf1 */ + sqlite3_result_int(ctx, pSeg->pgnoFirst); + break; + case 5: /* leaf2 */ + sqlite3_result_int(ctx, pSeg->pgnoLast); + break; + case 6: /* origin1 */ + sqlite3_result_int64(ctx, pSeg->iOrigin1); + break; + case 7: /* origin2 */ + sqlite3_result_int64(ctx, pSeg->iOrigin2); + break; + case 8: /* npgtombstone */ + sqlite3_result_int(ctx, pSeg->nPgTombstone); + break; + case 9: /* nentrytombstone */ + sqlite3_result_int64(ctx, pSeg->nEntryTombstone); + break; + case 10: /* nentry */ + sqlite3_result_int64(ctx, pSeg->nEntry); + break; + } + return SQLITE_OK; +} + +/* +** Initialize a cursor. +** +** idxNum==0 means show all subprograms +** idxNum==1 means show only the main bytecode and omit subprograms. +*/ +static int fts5structFilterMethod( + sqlite3_vtab_cursor *pVtabCursor, + int idxNum, const char *idxStr, + int argc, sqlite3_value **argv +){ + Fts5StructVcsr *pCsr = (Fts5StructVcsr *)pVtabCursor; + int rc = SQLITE_OK; + + const u8 *aBlob = 0; + int nBlob = 0; + + assert( argc==1 ); + fts5StructureRelease(pCsr->pStruct); + pCsr->pStruct = 0; + + nBlob = sqlite3_value_bytes(argv[0]); + aBlob = (const u8*)sqlite3_value_blob(argv[0]); + rc = fts5StructureDecode(aBlob, nBlob, 0, &pCsr->pStruct); + if( rc==SQLITE_OK ){ + pCsr->iLevel = 0; + pCsr->iRowid = 0; + pCsr->iSeg = -1; + rc = fts5structNextMethod(pVtabCursor); + } + + return rc; +} + +#endif /* SQLITE_TEST || SQLITE_FTS5_DEBUG */ /* ** This is called as part of registering the FTS5 module with database @@ -239783,7 +242848,7 @@ static void fts5RowidFunction( ** SQLite error code is returned instead. */ static int sqlite3Fts5IndexInit(sqlite3 *db){ -#ifdef SQLITE_TEST +#if defined(SQLITE_TEST) || defined(SQLITE_FTS5_DEBUG) int rc = sqlite3_create_function( db, "fts5_decode", 2, SQLITE_UTF8, 0, fts5DecodeFunction, 0, 0 ); @@ -239800,6 +242865,36 @@ static int sqlite3Fts5IndexInit(sqlite3 *db){ db, "fts5_rowid", -1, SQLITE_UTF8, 0, fts5RowidFunction, 0, 0 ); } + + if( rc==SQLITE_OK ){ + static const sqlite3_module fts5structure_module = { + 0, /* iVersion */ + 0, /* xCreate */ + fts5structConnectMethod, /* xConnect */ + fts5structBestIndexMethod, /* xBestIndex */ + fts5structDisconnectMethod, /* xDisconnect */ + 0, /* xDestroy */ + fts5structOpenMethod, /* xOpen */ + fts5structCloseMethod, /* xClose */ + fts5structFilterMethod, /* xFilter */ + fts5structNextMethod, /* xNext */ + fts5structEofMethod, /* xEof */ + fts5structColumnMethod, /* xColumn */ + fts5structRowidMethod, /* xRowid */ + 0, /* xUpdate */ + 0, /* xBegin */ + 0, /* xSync */ + 0, /* xCommit */ + 0, /* xRollback */ + 0, /* xFindFunction */ + 0, /* xRename */ + 0, /* xSavepoint */ + 0, /* xRelease */ + 0, /* xRollbackTo */ + 0 /* xShadowName */ + }; + rc = sqlite3_create_module(db, "fts5_structure", &fts5structure_module, 0); + } return rc; #else return SQLITE_OK; @@ -241443,7 +244538,6 @@ static int fts5UpdateMethod( int rc = SQLITE_OK; /* Return code */ int bUpdateOrDelete = 0; - /* A transaction must be open when this is called. */ assert( pTab->ts.eState==1 || pTab->ts.eState==2 ); @@ -241472,7 +244566,14 @@ static int fts5UpdateMethod( if( pConfig->eContent!=FTS5_CONTENT_NORMAL && 0==sqlite3_stricmp("delete", z) ){ - rc = fts5SpecialDelete(pTab, apVal); + if( pConfig->bContentlessDelete ){ + fts5SetVtabError(pTab, + "'delete' may not be used with a contentless_delete=1 table" + ); + rc = SQLITE_ERROR; + }else{ + rc = fts5SpecialDelete(pTab, apVal); + } }else{ rc = fts5SpecialInsert(pTab, z, apVal[2 + pConfig->nCol + 1]); } @@ -241489,7 +244590,7 @@ static int fts5UpdateMethod( ** Cases 3 and 4 may violate the rowid constraint. */ int eConflict = SQLITE_ABORT; - if( pConfig->eContent==FTS5_CONTENT_NORMAL ){ + if( pConfig->eContent==FTS5_CONTENT_NORMAL || pConfig->bContentlessDelete ){ eConflict = sqlite3_vtab_on_conflict(pConfig->db); } @@ -241497,8 +244598,12 @@ static int fts5UpdateMethod( assert( nArg!=1 || eType0==SQLITE_INTEGER ); /* Filter out attempts to run UPDATE or DELETE on contentless tables. - ** This is not suported. */ - if( eType0==SQLITE_INTEGER && fts5IsContentless(pTab) ){ + ** This is not suported. Except - DELETE is supported if the CREATE + ** VIRTUAL TABLE statement contained "contentless_delete=1". */ + if( eType0==SQLITE_INTEGER + && pConfig->eContent==FTS5_CONTENT_NONE + && pConfig->bContentlessDelete==0 + ){ pTab->p.base.zErrMsg = sqlite3_mprintf( "cannot %s contentless fts5 table: %s", (nArg>1 ? "UPDATE" : "DELETE from"), pConfig->zName @@ -241585,8 +244690,7 @@ static int fts5SyncMethod(sqlite3_vtab *pVtab){ Fts5FullTable *pTab = (Fts5FullTable*)pVtab; fts5CheckTransactionState(pTab, FTS5_SYNC, 0); pTab->p.pConfig->pzErrmsg = &pTab->p.base.zErrMsg; - fts5TripCursors(pTab); - rc = sqlite3Fts5StorageSync(pTab->pStorage); + rc = sqlite3Fts5FlushToDisk(&pTab->p); pTab->p.pConfig->pzErrmsg = 0; return rc; } @@ -242353,6 +245457,12 @@ static int fts5ColumnMethod( sqlite3_result_value(pCtx, sqlite3_column_value(pCsr->pStmt, iCol+1)); } pConfig->pzErrmsg = 0; + }else if( pConfig->bContentlessDelete && sqlite3_vtab_nochange(pCtx) ){ + char *zErr = sqlite3_mprintf("cannot UPDATE a subset of " + "columns on fts5 contentless-delete table: %s", pConfig->zName + ); + sqlite3_result_error(pCtx, zErr, -1); + sqlite3_free(zErr); } return rc; } @@ -242635,7 +245745,7 @@ static void fts5SourceIdFunc( ){ assert( nArg==0 ); UNUSED_PARAM2(nArg, apUnused); - sqlite3_result_text(pCtx, "fts5: 2023-05-16 12:36:15 831d0fb2836b71c9bc51067c49fee4b8f18047814f2ff22d817d25195cf350b0", -1, SQLITE_TRANSIENT); + sqlite3_result_text(pCtx, "fts5: 2023-08-24 12:36:59 0f80b798b3f4b81a7bb4233c58294edd0f1156f36b6ecf5ab8e83631d468778c", -1, SQLITE_TRANSIENT); } /* @@ -242848,10 +245958,10 @@ static int fts5StorageGetStmt( "INSERT INTO %Q.'%q_content' VALUES(%s)", /* INSERT_CONTENT */ "REPLACE INTO %Q.'%q_content' VALUES(%s)", /* REPLACE_CONTENT */ "DELETE FROM %Q.'%q_content' WHERE id=?", /* DELETE_CONTENT */ - "REPLACE INTO %Q.'%q_docsize' VALUES(?,?)", /* REPLACE_DOCSIZE */ + "REPLACE INTO %Q.'%q_docsize' VALUES(?,?%s)", /* REPLACE_DOCSIZE */ "DELETE FROM %Q.'%q_docsize' WHERE id=?", /* DELETE_DOCSIZE */ - "SELECT sz FROM %Q.'%q_docsize' WHERE id=?", /* LOOKUP_DOCSIZE */ + "SELECT sz%s FROM %Q.'%q_docsize' WHERE id=?", /* LOOKUP_DOCSIZE */ "REPLACE INTO %Q.'%q_config' VALUES(?,?)", /* REPLACE_CONFIG */ "SELECT %s FROM %s AS T", /* SCAN */ @@ -242899,6 +246009,19 @@ static int fts5StorageGetStmt( break; } + case FTS5_STMT_REPLACE_DOCSIZE: + zSql = sqlite3_mprintf(azStmt[eStmt], pC->zDb, pC->zName, + (pC->bContentlessDelete ? ",?" : "") + ); + break; + + case FTS5_STMT_LOOKUP_DOCSIZE: + zSql = sqlite3_mprintf(azStmt[eStmt], + (pC->bContentlessDelete ? ",origin" : ""), + pC->zDb, pC->zName + ); + break; + default: zSql = sqlite3_mprintf(azStmt[eStmt], pC->zDb, pC->zName); break; @@ -243088,9 +246211,11 @@ static int sqlite3Fts5StorageOpen( } if( rc==SQLITE_OK && pConfig->bColumnsize ){ - rc = sqlite3Fts5CreateTable( - pConfig, "docsize", "id INTEGER PRIMARY KEY, sz BLOB", 0, pzErr - ); + const char *zCols = "id INTEGER PRIMARY KEY, sz BLOB"; + if( pConfig->bContentlessDelete ){ + zCols = "id INTEGER PRIMARY KEY, sz BLOB, origin INTEGER"; + } + rc = sqlite3Fts5CreateTable(pConfig, "docsize", zCols, 0, pzErr); } if( rc==SQLITE_OK ){ rc = sqlite3Fts5CreateTable( @@ -243167,7 +246292,7 @@ static int fts5StorageDeleteFromIndex( ){ Fts5Config *pConfig = p->pConfig; sqlite3_stmt *pSeek = 0; /* SELECT to read row iDel from %_data */ - int rc; /* Return code */ + int rc = SQLITE_OK; /* Return code */ int rc2; /* sqlite3_reset() return code */ int iCol; Fts5InsertCtx ctx; @@ -243183,7 +246308,6 @@ static int fts5StorageDeleteFromIndex( ctx.pStorage = p; ctx.iCol = -1; - rc = sqlite3Fts5IndexBeginWrite(p->pIndex, 1, iDel); for(iCol=1; rc==SQLITE_OK && iCol<=pConfig->nCol; iCol++){ if( pConfig->abUnindexed[iCol-1]==0 ){ const char *zText; @@ -243220,6 +246344,37 @@ static int fts5StorageDeleteFromIndex( return rc; } +/* +** This function is called to process a DELETE on a contentless_delete=1 +** table. It adds the tombstone required to delete the entry with rowid +** iDel. If successful, SQLITE_OK is returned. Or, if an error occurs, +** an SQLite error code. +*/ +static int fts5StorageContentlessDelete(Fts5Storage *p, i64 iDel){ + i64 iOrigin = 0; + sqlite3_stmt *pLookup = 0; + int rc = SQLITE_OK; + + assert( p->pConfig->bContentlessDelete ); + assert( p->pConfig->eContent==FTS5_CONTENT_NONE ); + + /* Look up the origin of the document in the %_docsize table. Store + ** this in stack variable iOrigin. */ + rc = fts5StorageGetStmt(p, FTS5_STMT_LOOKUP_DOCSIZE, &pLookup, 0); + if( rc==SQLITE_OK ){ + sqlite3_bind_int64(pLookup, 1, iDel); + if( SQLITE_ROW==sqlite3_step(pLookup) ){ + iOrigin = sqlite3_column_int64(pLookup, 1); + } + rc = sqlite3_reset(pLookup); + } + + if( rc==SQLITE_OK && iOrigin!=0 ){ + rc = sqlite3Fts5IndexContentlessDelete(p->pIndex, iOrigin, iDel); + } + + return rc; +} /* ** Insert a record into the %_docsize table. Specifically, do: @@ -243240,10 +246395,17 @@ static int fts5StorageInsertDocsize( rc = fts5StorageGetStmt(p, FTS5_STMT_REPLACE_DOCSIZE, &pReplace, 0); if( rc==SQLITE_OK ){ sqlite3_bind_int64(pReplace, 1, iRowid); - sqlite3_bind_blob(pReplace, 2, pBuf->p, pBuf->n, SQLITE_STATIC); - sqlite3_step(pReplace); - rc = sqlite3_reset(pReplace); - sqlite3_bind_null(pReplace, 2); + if( p->pConfig->bContentlessDelete ){ + i64 iOrigin = 0; + rc = sqlite3Fts5IndexGetOrigin(p->pIndex, &iOrigin); + sqlite3_bind_int64(pReplace, 3, iOrigin); + } + if( rc==SQLITE_OK ){ + sqlite3_bind_blob(pReplace, 2, pBuf->p, pBuf->n, SQLITE_STATIC); + sqlite3_step(pReplace); + rc = sqlite3_reset(pReplace); + sqlite3_bind_null(pReplace, 2); + } } } return rc; @@ -243307,7 +246469,15 @@ static int sqlite3Fts5StorageDelete(Fts5Storage *p, i64 iDel, sqlite3_value **ap /* Delete the index records */ if( rc==SQLITE_OK ){ - rc = fts5StorageDeleteFromIndex(p, iDel, apVal); + rc = sqlite3Fts5IndexBeginWrite(p->pIndex, 1, iDel); + } + + if( rc==SQLITE_OK ){ + if( p->pConfig->bContentlessDelete ){ + rc = fts5StorageContentlessDelete(p, iDel); + }else{ + rc = fts5StorageDeleteFromIndex(p, iDel, apVal); + } } /* Delete the %_docsize record */ diff --git a/libsqlite3-sys/sqlite3/sqlite3.h b/libsqlite3-sys/sqlite3/sqlite3.h index 48effe2..ec451a5 100644 --- a/libsqlite3-sys/sqlite3/sqlite3.h +++ b/libsqlite3-sys/sqlite3/sqlite3.h @@ -146,9 +146,9 @@ extern "C" { ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ -#define SQLITE_VERSION "3.42.0" -#define SQLITE_VERSION_NUMBER 3042000 -#define SQLITE_SOURCE_ID "2023-05-16 12:36:15 831d0fb2836b71c9bc51067c49fee4b8f18047814f2ff22d817d25195cf350b0" +#define SQLITE_VERSION "3.43.0" +#define SQLITE_VERSION_NUMBER 3043000 +#define SQLITE_SOURCE_ID "2023-08-24 12:36:59 0f80b798b3f4b81a7bb4233c58294edd0f1156f36b6ecf5ab8e83631d468778c" /* ** CAPI3REF: Run-Time Library Version Numbers @@ -528,6 +528,7 @@ SQLITE_API int sqlite3_exec( #define SQLITE_IOERR_ROLLBACK_ATOMIC (SQLITE_IOERR | (31<<8)) #define SQLITE_IOERR_DATA (SQLITE_IOERR | (32<<8)) #define SQLITE_IOERR_CORRUPTFS (SQLITE_IOERR | (33<<8)) +#define SQLITE_IOERR_IN_PAGE (SQLITE_IOERR | (34<<8)) #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8)) #define SQLITE_LOCKED_VTAB (SQLITE_LOCKED | (2<<8)) #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8)) @@ -1190,7 +1191,7 @@ struct sqlite3_io_methods { ** by clients within the current process, only within other processes. ** **
    4. [[SQLITE_FCNTL_CKSM_FILE]] -** The [SQLITE_FCNTL_CKSM_FILE] opcode is for use interally by the +** The [SQLITE_FCNTL_CKSM_FILE] opcode is for use internally by the ** [checksum VFS shim] only. ** **
    5. [[SQLITE_FCNTL_RESET_CACHE]] @@ -2454,7 +2455,7 @@ struct sqlite3_mem_methods { ** the [VACUUM] command will fail with an obscure error when attempting to ** process a table with generated columns and a descending index. This is ** not considered a bug since SQLite versions 3.3.0 and earlier do not support -** either generated columns or decending indexes. +** either generated columns or descending indexes. ** ** ** [[SQLITE_DBCONFIG_STMT_SCANSTATUS]] @@ -2735,6 +2736,7 @@ SQLITE_API sqlite3_int64 sqlite3_total_changes64(sqlite3*); ** ** ^The [sqlite3_is_interrupted(D)] interface can be used to determine whether ** or not an interrupt is currently in effect for [database connection] D. +** It returns 1 if an interrupt is currently in effect, or 0 otherwise. */ SQLITE_API void sqlite3_interrupt(sqlite3*); SQLITE_API int sqlite3_is_interrupted(sqlite3*); @@ -3388,8 +3390,10 @@ SQLITE_API SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*, ** M argument should be the bitwise OR-ed combination of ** zero or more [SQLITE_TRACE] constants. ** -** ^Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides -** (cancels) any prior calls to sqlite3_trace() or sqlite3_trace_v2(). +** ^Each call to either sqlite3_trace(D,X,P) or sqlite3_trace_v2(D,M,X,P) +** overrides (cancels) all prior calls to sqlite3_trace(D,X,P) or +** sqlite3_trace_v2(D,M,X,P) for the [database connection] D. Each +** database connection may have at most one trace callback. ** ** ^The X callback is invoked whenever any of the events identified by ** mask M occur. ^The integer return value from the callback is currently @@ -3758,7 +3762,7 @@ SQLITE_API int sqlite3_open_v2( ** as F) must be one of: **
        **
      • A database filename pointer created by the SQLite core and -** passed into the xOpen() method of a VFS implemention, or +** passed into the xOpen() method of a VFS implementation, or **
      • A filename obtained from [sqlite3_db_filename()], or **
      • A new filename constructed using [sqlite3_create_filename()]. **
      @@ -3871,7 +3875,7 @@ SQLITE_API sqlite3_file *sqlite3_database_file_object(const char*); /* ** CAPI3REF: Create and Destroy VFS Filenames ** -** These interfces are provided for use by [VFS shim] implementations and +** These interfaces are provided for use by [VFS shim] implementations and ** are not useful outside of that context. ** ** The sqlite3_create_filename(D,J,W,N,P) allocates memory to hold a version of @@ -4418,6 +4422,41 @@ SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); */ SQLITE_API int sqlite3_stmt_isexplain(sqlite3_stmt *pStmt); +/* +** CAPI3REF: Change The EXPLAIN Setting For A Prepared Statement +** METHOD: sqlite3_stmt +** +** The sqlite3_stmt_explain(S,E) interface changes the EXPLAIN +** setting for [prepared statement] S. If E is zero, then S becomes +** a normal prepared statement. If E is 1, then S behaves as if +** its SQL text began with "[EXPLAIN]". If E is 2, then S behaves as if +** its SQL text began with "[EXPLAIN QUERY PLAN]". +** +** Calling sqlite3_stmt_explain(S,E) might cause S to be reprepared. +** SQLite tries to avoid a reprepare, but a reprepare might be necessary +** on the first transition into EXPLAIN or EXPLAIN QUERY PLAN mode. +** +** Because of the potential need to reprepare, a call to +** sqlite3_stmt_explain(S,E) will fail with SQLITE_ERROR if S cannot be +** reprepared because it was created using [sqlite3_prepare()] instead of +** the newer [sqlite3_prepare_v2()] or [sqlite3_prepare_v3()] interfaces and +** hence has no saved SQL text with which to reprepare. +** +** Changing the explain setting for a prepared statement does not change +** the original SQL text for the statement. Hence, if the SQL text originally +** began with EXPLAIN or EXPLAIN QUERY PLAN, but sqlite3_stmt_explain(S,0) +** is called to convert the statement into an ordinary statement, the EXPLAIN +** or EXPLAIN QUERY PLAN keywords will still appear in the sqlite3_sql(S) +** output, even though the statement now acts like a normal SQL statement. +** +** This routine returns SQLITE_OK if the explain mode is successfully +** changed, or an error code if the explain mode could not be changed. +** The explain mode cannot be changed while a statement is active. +** Hence, it is good practice to call [sqlite3_reset(S)] +** immediately prior to calling sqlite3_stmt_explain(S,E). +*/ +SQLITE_API int sqlite3_stmt_explain(sqlite3_stmt *pStmt, int eMode); + /* ** CAPI3REF: Determine If A Prepared Statement Has Been Reset ** METHOD: sqlite3_stmt @@ -4581,7 +4620,7 @@ typedef struct sqlite3_context sqlite3_context; ** with it may be passed. ^It is called to dispose of the BLOB or string even ** if the call to the bind API fails, except the destructor is not called if ** the third parameter is a NULL pointer or the fourth parameter is negative. -** ^ (2) The special constant, [SQLITE_STATIC], may be passsed to indicate that +** ^ (2) The special constant, [SQLITE_STATIC], may be passed to indicate that ** the application remains responsible for disposing of the object. ^In this ** case, the object and the provided pointer to it must remain valid until ** either the prepared statement is finalized or the same SQL parameter is @@ -5260,14 +5299,26 @@ SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt); ** ^The [sqlite3_reset(S)] interface resets the [prepared statement] S ** back to the beginning of its program. ** -** ^If the most recent call to [sqlite3_step(S)] for the -** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE], -** or if [sqlite3_step(S)] has never before been called on S, -** then [sqlite3_reset(S)] returns [SQLITE_OK]. +** ^The return code from [sqlite3_reset(S)] indicates whether or not +** the previous evaluation of prepared statement S completed successfully. +** ^If [sqlite3_step(S)] has never before been called on S or if +** [sqlite3_step(S)] has not been called since the previous call +** to [sqlite3_reset(S)], then [sqlite3_reset(S)] will return +** [SQLITE_OK]. ** ** ^If the most recent call to [sqlite3_step(S)] for the ** [prepared statement] S indicated an error, then ** [sqlite3_reset(S)] returns an appropriate [error code]. +** ^The [sqlite3_reset(S)] interface might also return an [error code] +** if there were no prior errors but the process of resetting +** the prepared statement caused a new error. ^For example, if an +** [INSERT] statement with a [RETURNING] clause is only stepped one time, +** that one call to [sqlite3_step(S)] might return SQLITE_ROW but +** the overall statement might still fail and the [sqlite3_reset(S)] call +** might return SQLITE_BUSY if locking constraints prevent the +** database change from committing. Therefore, it is important that +** applications check the return code from [sqlite3_reset(S)] even if +** no prior call to [sqlite3_step(S)] indicated a problem. ** ** ^The [sqlite3_reset(S)] interface does not change the values ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S. @@ -5484,7 +5535,7 @@ SQLITE_API int sqlite3_create_window_function( ** [application-defined SQL function] ** that has side-effects or that could potentially leak sensitive information. ** This will prevent attacks in which an application is tricked -** into using a database file that has had its schema surreptiously +** into using a database file that has had its schema surreptitiously ** modified to invoke the application-defined function in ways that are ** harmful. **

      @@ -8161,7 +8212,8 @@ SQLITE_API int sqlite3_test_control(int op, ...); #define SQLITE_TESTCTRL_TRACEFLAGS 31 #define SQLITE_TESTCTRL_TUNE 32 #define SQLITE_TESTCTRL_LOGEST 33 -#define SQLITE_TESTCTRL_LAST 33 /* Largest TESTCTRL */ +#define SQLITE_TESTCTRL_USELONGDOUBLE 34 +#define SQLITE_TESTCTRL_LAST 34 /* Largest TESTCTRL */ /* ** CAPI3REF: SQL Keyword Checking @@ -9193,8 +9245,8 @@ SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p); ** blocked connection already has a registered unlock-notify callback, ** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is ** called with a NULL pointer as its second argument, then any existing -** unlock-notify callback is canceled. ^The blocked connections -** unlock-notify callback may also be canceled by closing the blocked +** unlock-notify callback is cancelled. ^The blocked connections +** unlock-notify callback may also be cancelled by closing the blocked ** connection using [sqlite3_close()]. ** ** The unlock-notify callback is not reentrant. If an application invokes @@ -9617,7 +9669,7 @@ SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...); ** [[SQLITE_VTAB_DIRECTONLY]]

      SQLITE_VTAB_DIRECTONLY
      **
      Calls of the form ** [sqlite3_vtab_config](db,SQLITE_VTAB_DIRECTONLY) from within the -** the [xConnect] or [xCreate] methods of a [virtual table] implmentation +** the [xConnect] or [xCreate] methods of a [virtual table] implementation ** prohibits that virtual table from being used from within triggers and ** views. **
      @@ -9807,7 +9859,7 @@ SQLITE_API int sqlite3_vtab_distinct(sqlite3_index_info*); ** communicated to the xBestIndex method as a ** [SQLITE_INDEX_CONSTRAINT_EQ] constraint.)^ If xBestIndex wants to use ** this constraint, it must set the corresponding -** aConstraintUsage[].argvIndex to a postive integer. ^(Then, under +** aConstraintUsage[].argvIndex to a positive integer. ^(Then, under ** the usual mode of handling IN operators, SQLite generates [bytecode] ** that invokes the [xFilter|xFilter() method] once for each value ** on the right-hand side of the IN operator.)^ Thus the virtual table @@ -10236,7 +10288,7 @@ SQLITE_API int sqlite3_db_cacheflush(sqlite3*); ** When the [sqlite3_blob_write()] API is used to update a blob column, ** the pre-update hook is invoked with SQLITE_DELETE. This is because the ** in this case the new values are not available. In this case, when a -** callback made with op==SQLITE_DELETE is actuall a write using the +** callback made with op==SQLITE_DELETE is actually a write using the ** sqlite3_blob_write() API, the [sqlite3_preupdate_blobwrite()] returns ** the index of the column being written. In other cases, where the ** pre-update hook is being invoked for some other reason, including a @@ -12754,7 +12806,7 @@ struct Fts5PhraseIter { ** See xPhraseFirstColumn above. */ struct Fts5ExtensionApi { - int iVersion; /* Currently always set to 3 */ + int iVersion; /* Currently always set to 2 */ void *(*xUserData)(Fts5Context*); @@ -12983,8 +13035,8 @@ struct Fts5ExtensionApi { ** as separate queries of the FTS index are required for each synonym. ** ** When using methods (2) or (3), it is important that the tokenizer only -** provide synonyms when tokenizing document text (method (2)) or query -** text (method (3)), not both. Doing so will not cause any errors, but is +** provide synonyms when tokenizing document text (method (3)) or query +** text (method (2)), not both. Doing so will not cause any errors, but is ** inefficient. */ typedef struct Fts5Tokenizer Fts5Tokenizer; @@ -13032,7 +13084,7 @@ struct fts5_api { int (*xCreateTokenizer)( fts5_api *pApi, const char *zName, - void *pContext, + void *pUserData, fts5_tokenizer *pTokenizer, void (*xDestroy)(void*) ); @@ -13041,7 +13093,7 @@ struct fts5_api { int (*xFindTokenizer)( fts5_api *pApi, const char *zName, - void **ppContext, + void **ppUserData, fts5_tokenizer *pTokenizer ); @@ -13049,7 +13101,7 @@ struct fts5_api { int (*xCreateFunction)( fts5_api *pApi, const char *zName, - void *pContext, + void *pUserData, fts5_extension_function xFunction, void (*xDestroy)(void*) ); diff --git a/libsqlite3-sys/sqlite3/sqlite3ext.h b/libsqlite3-sys/sqlite3/sqlite3ext.h index 19e0300..7116380 100644 --- a/libsqlite3-sys/sqlite3/sqlite3ext.h +++ b/libsqlite3-sys/sqlite3/sqlite3ext.h @@ -361,6 +361,8 @@ struct sqlite3_api_routines { int (*value_encoding)(sqlite3_value*); /* Version 3.41.0 and later */ int (*is_interrupted)(sqlite3*); + /* Version 3.43.0 and later */ + int (*stmt_explain)(sqlite3_stmt*,int); }; /* @@ -689,6 +691,8 @@ typedef int (*sqlite3_loadext_entry)( #define sqlite3_value_encoding sqlite3_api->value_encoding /* Version 3.41.0 and later */ #define sqlite3_is_interrupted sqlite3_api->is_interrupted +/* Version 3.43.0 and later */ +#define sqlite3_stmt_explain sqlite3_api->stmt_explain #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) diff --git a/libsqlite3-sys/upgrade.sh b/libsqlite3-sys/upgrade.sh index 17e505a..62a8164 100755 --- a/libsqlite3-sys/upgrade.sh +++ b/libsqlite3-sys/upgrade.sh @@ -9,7 +9,7 @@ export SQLITE3_LIB_DIR="$SCRIPT_DIR/sqlite3" export SQLITE3_INCLUDE_DIR="$SQLITE3_LIB_DIR" # Download and extract amalgamation -SQLITE=sqlite-amalgamation-3420000 +SQLITE=sqlite-amalgamation-3430000 curl -O https://sqlite.org/2023/$SQLITE.zip unzip -p "$SQLITE.zip" "$SQLITE/sqlite3.c" > "$SQLITE3_LIB_DIR/sqlite3.c" unzip -p "$SQLITE.zip" "$SQLITE/sqlite3.h" > "$SQLITE3_LIB_DIR/sqlite3.h" From 36f24593931bbb52ee4f2c1826c12aa744a79093 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 26 Aug 2023 10:58:58 +0000 Subject: [PATCH 22/63] Rustfmt --- src/serialize.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/serialize.rs b/src/serialize.rs index e482af4..a20a942 100644 --- a/src/serialize.rs +++ b/src/serialize.rs @@ -142,7 +142,9 @@ mod test { let db = Connection::open_in_memory()?; db.execute_batch("CREATE TABLE x AS SELECT 'data'")?; let data = db.serialize(DatabaseName::Main)?; - let Data::Owned(data) = data else { panic!("expected OwnedData")}; + let Data::Owned(data) = data else { + panic!("expected OwnedData") + }; assert!(data.sz > 0); Ok(()) } @@ -152,7 +154,9 @@ mod test { let src = Connection::open_in_memory()?; src.execute_batch("CREATE TABLE x AS SELECT 'data'")?; let data = src.serialize(DatabaseName::Main)?; - let Data::Owned(data) = data else { panic!("expected OwnedData")}; + let Data::Owned(data) = data else { + panic!("expected OwnedData") + }; let mut dst = Connection::open_in_memory()?; dst.deserialize(DatabaseName::Main, data, false)?; From e2e47de8630e5007c36bccf666a4307f4c3e4cc3 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sun, 3 Sep 2023 10:46:12 +0200 Subject: [PATCH 23/63] Fix some clipy warnings --- src/column.rs | 2 ++ src/error.rs | 7 +++---- src/lib.rs | 6 +++--- src/pragma.rs | 1 - src/row.rs | 8 ++++---- src/serialize.rs | 7 ++++--- src/session.rs | 2 +- src/statement.rs | 8 ++++++-- src/transaction.rs | 11 +++++------ src/types/value_ref.rs | 20 +++++++------------- src/version.rs | 4 ++++ 11 files changed, 39 insertions(+), 37 deletions(-) diff --git a/src/column.rs b/src/column.rs index 66d0e76..590a986 100644 --- a/src/column.rs +++ b/src/column.rs @@ -90,6 +90,8 @@ impl Statement<'_> { /// Returns an `Error::InvalidColumnIndex` if `idx` is outside the valid /// column range for this row. /// + /// # Panics + /// /// Panics when column name is not valid UTF-8. #[inline] pub fn column_name(&self, col: usize) -> Result<&str> { diff --git a/src/error.rs b/src/error.rs index a1e8c45..fbdae21 100644 --- a/src/error.rs +++ b/src/error.rs @@ -367,6 +367,7 @@ impl error::Error for Error { impl Error { /// Returns the underlying SQLite error if this is [`Error::SqliteFailure`]. #[inline] + #[must_use] pub fn sqlite_error(&self) -> Option<&ffi::Error> { match self { Self::SqliteFailure(error, _) => Some(error), @@ -377,6 +378,7 @@ impl Error { /// Returns the underlying SQLite error code if this is /// [`Error::SqliteFailure`]. #[inline] + #[must_use] pub fn sqlite_error_code(&self) -> Option { self.sqlite_error().map(|error| error.code) } @@ -439,10 +441,7 @@ pub fn check(code: c_int) -> Result<()> { /// Transform Rust error to SQLite error (message and code). /// # Safety /// This function is unsafe because it uses raw pointer -pub unsafe fn to_sqlite_error( - e: &Error, - err_msg: *mut *mut std::os::raw::c_char, -) -> std::os::raw::c_int { +pub unsafe fn to_sqlite_error(e: &Error, err_msg: *mut *mut std::os::raw::c_char) -> c_int { use crate::util::alloc; match e { Error::SqliteFailure(err, s) => { diff --git a/src/lib.rs b/src/lib.rs index 146e5da..8374e63 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -568,7 +568,7 @@ impl Connection { #[inline] pub fn execute(&self, sql: &str, params: P) -> Result { self.prepare(sql) - .and_then(|mut stmt| stmt.check_no_tail().and_then(|_| stmt.execute(params))) + .and_then(|mut stmt| stmt.check_no_tail().and_then(|()| stmt.execute(params))) } /// Returns the path to the database file, if one exists and is known. @@ -651,7 +651,7 @@ impl Connection { // https://sqlite.org/tclsqlite.html#onecolumn #[cfg(test)] - pub(crate) fn one_column(&self, sql: &str) -> Result { + pub(crate) fn one_column(&self, sql: &str) -> Result { self.query_row(sql, [], |r| r.get(0)) } @@ -912,7 +912,7 @@ impl Connection { /// This function is unsafe because improper use may impact the Connection. /// In particular, it should only be called on connections created /// and owned by the caller, e.g. as a result of calling - /// ffi::sqlite3_open(). + /// `ffi::sqlite3_open`(). #[inline] pub unsafe fn from_handle_owned(db: *mut ffi::sqlite3) -> Result { let db = InnerConnection::new(db, true); diff --git a/src/pragma.rs b/src/pragma.rs index d5a2cb4..46bbde1 100644 --- a/src/pragma.rs +++ b/src/pragma.rs @@ -384,7 +384,6 @@ mod test { let mut rows = table_info.query(["sqlite_master"])?; while let Some(row) = rows.next()? { - let row = row; let column: String = row.get(1)?; columns.push(column); } diff --git a/src/row.rs b/src/row.rs index d8edcb1..2d25900 100644 --- a/src/row.rs +++ b/src/row.rs @@ -29,8 +29,8 @@ impl<'stmt> Rows<'stmt> { /// This interface is not compatible with Rust's `Iterator` trait, because /// the lifetime of the returned row is tied to the lifetime of `self`. /// This is a fallible "streaming iterator". For a more natural interface, - /// consider using [`query_map`](crate::Statement::query_map) or - /// [`query_and_then`](crate::Statement::query_and_then) instead, which + /// consider using [`query_map`](Statement::query_map) or + /// [`query_and_then`](Statement::query_and_then) instead, which /// return types that implement `Iterator`. #[allow(clippy::should_implement_trait)] // cannot implement Iterator #[inline] @@ -247,7 +247,7 @@ pub struct Row<'stmt> { impl<'stmt> Row<'stmt> { /// Get the value of a particular column of the result row. /// - /// ## Failure + /// # Panics /// /// Panics if calling [`row.get(idx)`](Row::get) would return an error, /// including: @@ -330,7 +330,7 @@ impl<'stmt> Row<'stmt> { /// it can be difficult to use, and most callers will be better served by /// [`get`](Row::get) or [`get_unwrap`](Row::get_unwrap). /// - /// ## Failure + /// # Panics /// /// Panics if calling [`row.get_ref(idx)`](Row::get_ref) would return an /// error, including: diff --git a/src/serialize.rs b/src/serialize.rs index a20a942..6852761 100644 --- a/src/serialize.rs +++ b/src/serialize.rs @@ -22,8 +22,9 @@ pub struct OwnedData { } impl OwnedData { - /// SAFETY: Caller must be certain that `ptr` is allocated by - /// `sqlite3_malloc`. + /// # Safety + /// + /// Caller must be certain that `ptr` is allocated by `sqlite3_malloc`. pub unsafe fn from_raw_nonnull(ptr: NonNull, sz: usize) -> Self { Self { ptr, sz } } @@ -65,7 +66,7 @@ impl<'conn> Deref for Data<'conn> { impl Connection { /// Serialize a database. - pub fn serialize<'conn>(&'conn self, schema: DatabaseName<'_>) -> Result> { + pub fn serialize(&self, schema: DatabaseName) -> Result { let schema = schema.as_cstring()?; let mut sz = 0; let mut ptr: *mut u8 = unsafe { diff --git a/src/session.rs b/src/session.rs index c42bbd6..0169a1c 100644 --- a/src/session.rs +++ b/src/session.rs @@ -405,7 +405,7 @@ impl Drop for ChangesetIter<'_> { } /// An item passed to a conflict-handler by -/// [`Connection::apply`](crate::Connection::apply), or an item generated by +/// [`Connection::apply`](Connection::apply), or an item generated by /// [`ChangesetIter::next`](ChangesetIter::next). // TODO enum ? Delete, Insert, Update, ... pub struct ChangesetItem { diff --git a/src/statement.rs b/src/statement.rs index bdd453d..d39cc1f 100644 --- a/src/statement.rs +++ b/src/statement.rs @@ -435,6 +435,10 @@ impl Statement<'_> { /// /// Will return `None` if the column index is out of bounds or if the /// parameter is positional. + /// + /// # Panics + /// + /// Panics when parameter name is not valid UTF-8. #[inline] pub fn parameter_name(&self, index: usize) -> Option<&'_ str> { self.stmt.bind_parameter_name(index as i32).map(|name| { @@ -450,7 +454,7 @@ impl Statement<'_> { { let expected = self.stmt.bind_parameter_count(); let mut index = 0; - for p in params.into_iter() { + for p in params { index += 1; // The leftmost SQL parameter has an index of 1. if index > expected { break; @@ -744,7 +748,7 @@ impl Statement<'_> { /// Reset all bindings pub fn clear_bindings(&mut self) { - self.stmt.clear_bindings() + self.stmt.clear_bindings(); } } diff --git a/src/transaction.rs b/src/transaction.rs index e4613aa..2e90528 100644 --- a/src/transaction.rs +++ b/src/transaction.rs @@ -122,7 +122,7 @@ impl Transaction<'_> { TransactionBehavior::Immediate => "BEGIN IMMEDIATE", TransactionBehavior::Exclusive => "BEGIN EXCLUSIVE", }; - conn.execute_batch(query).map(move |_| Transaction { + conn.execute_batch(query).map(move |()| Transaction { conn, drop_behavior: DropBehavior::Rollback, }) @@ -251,7 +251,7 @@ impl Savepoint<'_> { fn with_name_>(conn: &Connection, name: T) -> Result> { let name = name.into(); conn.execute_batch(&format!("SAVEPOINT {name}")) - .map(|_| Savepoint { + .map(|()| Savepoint { conn, name, drop_behavior: DropBehavior::Rollback, @@ -346,8 +346,8 @@ impl Savepoint<'_> { match self.drop_behavior() { DropBehavior::Commit => self .commit_() - .or_else(|_| self.rollback().and_then(|_| self.commit_())), - DropBehavior::Rollback => self.rollback().and_then(|_| self.commit_()), + .or_else(|_| self.rollback().and_then(|()| self.commit_())), + DropBehavior::Rollback => self.rollback().and_then(|()| self.commit_()), DropBehavior::Ignore => Ok(()), DropBehavior::Panic => panic!("Savepoint dropped unexpectedly."), } @@ -471,8 +471,7 @@ impl Connection { /// /// The savepoint defaults to rolling back when it is dropped. If you want /// the savepoint to commit, you must call [`commit`](Savepoint::commit) or - /// [`set_drop_behavior(DropBehavior::Commit)`](Savepoint:: - /// set_drop_behavior). + /// [`set_drop_behavior(DropBehavior::Commit)`](Savepoint::set_drop_behavior). /// /// ## Example /// diff --git a/src/types/value_ref.rs b/src/types/value_ref.rs index 07aa51b..aa062f8 100644 --- a/src/types/value_ref.rs +++ b/src/types/value_ref.rs @@ -36,8 +36,7 @@ impl ValueRef<'_> { impl<'a> ValueRef<'a> { /// If `self` is case `Integer`, returns the integral value. Otherwise, - /// returns [`Err(Error::InvalidColumnType)`](crate::Error:: - /// InvalidColumnType). + /// returns [`Err(Error::InvalidColumnType)`](crate::Error::InvalidColumnType). #[inline] pub fn as_i64(&self) -> FromSqlResult { match *self { @@ -48,8 +47,7 @@ impl<'a> ValueRef<'a> { /// If `self` is case `Null` returns None. /// If `self` is case `Integer`, returns the integral value. - /// Otherwise returns [`Err(Error::InvalidColumnType)`](crate::Error:: - /// InvalidColumnType). + /// Otherwise returns [`Err(Error::InvalidColumnType)`](crate::Error::InvalidColumnType). #[inline] pub fn as_i64_or_null(&self) -> FromSqlResult> { match *self { @@ -60,8 +58,7 @@ impl<'a> ValueRef<'a> { } /// If `self` is case `Real`, returns the floating point value. Otherwise, - /// returns [`Err(Error::InvalidColumnType)`](crate::Error:: - /// InvalidColumnType). + /// returns [`Err(Error::InvalidColumnType)`](crate::Error::InvalidColumnType). #[inline] pub fn as_f64(&self) -> FromSqlResult { match *self { @@ -72,8 +69,7 @@ impl<'a> ValueRef<'a> { /// If `self` is case `Null` returns None. /// If `self` is case `Real`, returns the floating point value. - /// Otherwise returns [`Err(Error::InvalidColumnType)`](crate::Error:: - /// InvalidColumnType). + /// Otherwise returns [`Err(Error::InvalidColumnType)`](crate::Error::InvalidColumnType). #[inline] pub fn as_f64_or_null(&self) -> FromSqlResult> { match *self { @@ -97,8 +93,7 @@ impl<'a> ValueRef<'a> { /// If `self` is case `Null` returns None. /// If `self` is case `Text`, returns the string value. - /// Otherwise returns [`Err(Error::InvalidColumnType)`](crate::Error:: - /// InvalidColumnType). + /// Otherwise returns [`Err(Error::InvalidColumnType)`](crate::Error::InvalidColumnType). #[inline] pub fn as_str_or_null(&self) -> FromSqlResult> { match *self { @@ -122,8 +117,7 @@ impl<'a> ValueRef<'a> { /// If `self` is case `Null` returns None. /// If `self` is case `Blob`, returns the byte slice. - /// Otherwise returns [`Err(Error::InvalidColumnType)`](crate::Error:: - /// InvalidColumnType). + /// Otherwise returns [`Err(Error::InvalidColumnType)`](crate::Error::InvalidColumnType). #[inline] pub fn as_blob_or_null(&self) -> FromSqlResult> { match *self { @@ -133,7 +127,7 @@ impl<'a> ValueRef<'a> { } } - /// Returns the byte slice that makes up this ValueRef if it's either + /// Returns the byte slice that makes up this `ValueRef` if it's either /// [`ValueRef::Blob`] or [`ValueRef::Text`]. #[inline] pub fn as_bytes(&self) -> FromSqlResult<&'a [u8]> { diff --git a/src/version.rs b/src/version.rs index d70af7e..44053b7 100644 --- a/src/version.rs +++ b/src/version.rs @@ -14,6 +14,10 @@ pub fn version_number() -> i32 { /// Returns the SQLite version as a string; e.g., `"3.16.2"` for version 3.16.2. /// /// See [`sqlite3_libversion()`](https://www.sqlite.org/c3ref/libversion.html). +/// +/// # Panics +/// +/// Panics when version is not valid UTF-8. #[inline] #[must_use] pub fn version() -> &'static str { From 8a3af637ddf051a8a9dde795823945b58db70db7 Mon Sep 17 00:00:00 2001 From: gwenn <45554+gwenn@users.noreply.github.com> Date: Sun, 3 Sep 2023 15:47:10 +0200 Subject: [PATCH 24/63] Fix visibility of TransactionState (#1384) Fix visibility of TransactionState --- src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 8374e63..0661883 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -82,6 +82,8 @@ pub use crate::load_extension_guard::LoadExtensionGuard; pub use crate::params::{params_from_iter, Params, ParamsFromIter}; pub use crate::row::{AndThenRows, Map, MappedRows, Row, RowIndex, Rows}; pub use crate::statement::{Statement, StatementStatus}; +#[cfg(feature = "modern_sqlite")] +pub use crate::transaction::TransactionState; pub use crate::transaction::{DropBehavior, Savepoint, Transaction, TransactionBehavior}; pub use crate::types::ToSql; pub use crate::version::*; From fb7774c6f5175263d1fca7221c3342ba682c92e8 Mon Sep 17 00:00:00 2001 From: gwenn <45554+gwenn@users.noreply.github.com> Date: Mon, 4 Sep 2023 20:59:28 +0200 Subject: [PATCH 25/63] Column is used only with column_decltype feature (#1385) --- src/column.rs | 4 ++++ src/lib.rs | 1 + 2 files changed, 5 insertions(+) diff --git a/src/column.rs b/src/column.rs index 590a986..b18eb8a 100644 --- a/src/column.rs +++ b/src/column.rs @@ -3,12 +3,16 @@ use std::str; use crate::{Error, Result, Statement}; /// Information about a column of a SQLite query. +#[cfg(feature = "column_decltype")] +#[cfg_attr(docsrs, doc(cfg(feature = "column_decltype")))] #[derive(Debug)] pub struct Column<'stmt> { name: &'stmt str, decl_type: Option<&'stmt str>, } +#[cfg(feature = "column_decltype")] +#[cfg_attr(docsrs, doc(cfg(feature = "column_decltype")))] impl Column<'_> { /// Returns the name of the column. #[inline] diff --git a/src/lib.rs b/src/lib.rs index 0661883..6424308 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -74,6 +74,7 @@ use crate::raw_statement::RawStatement; use crate::types::ValueRef; pub use crate::cache::CachedStatement; +#[cfg(feature = "column_decltype")] pub use crate::column::Column; pub use crate::error::{to_sqlite_error, Error}; pub use crate::ffi::ErrorCode; From 6b4cc6d2ccfc9fab0c8e15dc0a81d3db9fe7d311 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Sep 2023 04:42:00 +0000 Subject: [PATCH 26/63] Update bindgen requirement from 0.66 to 0.68 Updates the requirements on [bindgen](https://github.com/rust-lang/rust-bindgen) to permit the latest version. - [Release notes](https://github.com/rust-lang/rust-bindgen/releases) - [Changelog](https://github.com/rust-lang/rust-bindgen/blob/main/CHANGELOG.md) - [Commits](https://github.com/rust-lang/rust-bindgen/compare/v0.66.0...v0.68.1) --- updated-dependencies: - dependency-name: bindgen dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- libsqlite3-sys/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsqlite3-sys/Cargo.toml b/libsqlite3-sys/Cargo.toml index e926668..3a84ce0 100644 --- a/libsqlite3-sys/Cargo.toml +++ b/libsqlite3-sys/Cargo.toml @@ -44,7 +44,7 @@ winsqlite3 = [] openssl-sys = { version = "0.9", optional = true } [build-dependencies] -bindgen = { version = "0.66", optional = true, default-features = false, features = ["runtime"] } +bindgen = { version = "0.68", optional = true, default-features = false, features = ["runtime"] } pkg-config = { version = "0.3.19", optional = true } cc = { version = "1.0", optional = true } vcpkg = { version = "0.2", optional = true } From 7a5c3d5d4fc70cfccc95d48b2921c20a763ed9fc Mon Sep 17 00:00:00 2001 From: gwenn Date: Wed, 13 Sep 2023 16:23:40 +0000 Subject: [PATCH 27/63] Bump bundled SQLite version to 3.43.1 --- .../sqlite3/bindgen_bundled_version.rs | 8 +- libsqlite3-sys/sqlite3/sqlite3.c | 187 +++++++++--------- libsqlite3-sys/sqlite3/sqlite3.h | 6 +- libsqlite3-sys/upgrade.sh | 2 +- 4 files changed, 106 insertions(+), 97 deletions(-) diff --git a/libsqlite3-sys/sqlite3/bindgen_bundled_version.rs b/libsqlite3-sys/sqlite3/bindgen_bundled_version.rs index 032403b..5327a3a 100644 --- a/libsqlite3-sys/sqlite3/bindgen_bundled_version.rs +++ b/libsqlite3-sys/sqlite3/bindgen_bundled_version.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.66.1 */ +/* automatically generated by rust-bindgen 0.68.1 */ extern "C" { pub fn sqlite3_auto_extension( @@ -23,10 +23,10 @@ extern "C" { ) -> ::std::os::raw::c_int; } -pub const SQLITE_VERSION: &[u8; 7] = b"3.43.0\0"; -pub const SQLITE_VERSION_NUMBER: i32 = 3043000; +pub const SQLITE_VERSION: &[u8; 7] = b"3.43.1\0"; +pub const SQLITE_VERSION_NUMBER: i32 = 3043001; pub const SQLITE_SOURCE_ID: &[u8; 85] = - b"2023-08-24 12:36:59 0f80b798b3f4b81a7bb4233c58294edd0f1156f36b6ecf5ab8e83631d468778c\0"; + b"2023-09-11 12:01:27 2d3a40c05c49e1a49264912b1a05bc2143ac0e7c3df588276ce80a4cbc9bd1b0\0"; pub const SQLITE_OK: i32 = 0; pub const SQLITE_ERROR: i32 = 1; pub const SQLITE_INTERNAL: i32 = 2; diff --git a/libsqlite3-sys/sqlite3/sqlite3.c b/libsqlite3-sys/sqlite3/sqlite3.c index 310583f..1884b08 100644 --- a/libsqlite3-sys/sqlite3/sqlite3.c +++ b/libsqlite3-sys/sqlite3/sqlite3.c @@ -1,6 +1,6 @@ /****************************************************************************** ** This file is an amalgamation of many separate C source files from SQLite -** version 3.43.0. By combining all the individual C code files into this +** version 3.43.1. By combining all the individual C code files into this ** single large file, the entire code can be compiled as a single translation ** unit. This allows many compilers to do optimizations that would not be ** possible if the files were compiled separately. Performance improvements @@ -18,7 +18,7 @@ ** separate file. This file contains only code for the core SQLite library. ** ** The content in this amalgamation comes from Fossil check-in -** f80b798b3f4b81a7bb4233c58294edd0f11. +** d3a40c05c49e1a49264912b1a05bc2143ac. */ #define SQLITE_CORE 1 #define SQLITE_AMALGAMATION 1 @@ -459,9 +459,9 @@ extern "C" { ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ -#define SQLITE_VERSION "3.43.0" -#define SQLITE_VERSION_NUMBER 3043000 -#define SQLITE_SOURCE_ID "2023-08-24 12:36:59 0f80b798b3f4b81a7bb4233c58294edd0f1156f36b6ecf5ab8e83631d468778c" +#define SQLITE_VERSION "3.43.1" +#define SQLITE_VERSION_NUMBER 3043001 +#define SQLITE_SOURCE_ID "2023-09-11 12:01:27 2d3a40c05c49e1a49264912b1a05bc2143ac0e7c3df588276ce80a4cbc9bd1b0" /* ** CAPI3REF: Run-Time Library Version Numbers @@ -128461,8 +128461,10 @@ static void sumFinalize(sqlite3_context *context){ if( p->approx ){ if( p->ovrfl ){ sqlite3_result_error(context,"integer overflow",-1); - }else{ + }else if( !sqlite3IsNaN(p->rErr) ){ sqlite3_result_double(context, p->rSum+p->rErr); + }else{ + sqlite3_result_double(context, p->rSum); } }else{ sqlite3_result_int64(context, p->iSum); @@ -128475,7 +128477,8 @@ static void avgFinalize(sqlite3_context *context){ if( p && p->cnt>0 ){ double r; if( p->approx ){ - r = p->rSum+p->rErr; + r = p->rSum; + if( !sqlite3IsNaN(p->rErr) ) r += p->rErr; }else{ r = (double)(p->iSum); } @@ -128488,7 +128491,8 @@ static void totalFinalize(sqlite3_context *context){ p = sqlite3_aggregate_context(context, 0); if( p ){ if( p->approx ){ - r = p->rSum+p->rErr; + r = p->rSum; + if( !sqlite3IsNaN(p->rErr) ) r += p->rErr; }else{ r = (double)(p->iSum); } @@ -145691,12 +145695,12 @@ static int disableUnusedSubqueryResultColumns(SrcItem *pItem){ assert( pItem->pSelect!=0 ); pSub = pItem->pSelect; assert( pSub->pEList->nExpr==pTab->nCol ); - if( (pSub->selFlags & (SF_Distinct|SF_Aggregate))!=0 ){ - testcase( pSub->selFlags & SF_Distinct ); - testcase( pSub->selFlags & SF_Aggregate ); - return 0; - } for(pX=pSub; pX; pX=pX->pPrior){ + if( (pX->selFlags & (SF_Distinct|SF_Aggregate))!=0 ){ + testcase( pX->selFlags & SF_Distinct ); + testcase( pX->selFlags & SF_Aggregate ); + return 0; + } if( pX->pPrior && pX->op!=TK_ALL ){ /* This optimization does not work for compound subqueries that ** use UNION, INTERSECT, or EXCEPT. Only UNION ALL is allowed. */ @@ -198084,7 +198088,7 @@ static u64 fts3ChecksumIndex( int rc; u64 cksum = 0; - assert( *pRc==SQLITE_OK ); + if( *pRc ) return 0; memset(&filter, 0, sizeof(filter)); memset(&csr, 0, sizeof(csr)); @@ -203714,7 +203718,9 @@ static void jsonArrayLengthFunc( } if( pNode->eType==JSON_ARRAY ){ while( 1 /*exit-by-break*/ ){ - for(i=1; i<=pNode->n; n++){ + i = 1; + while( i<=pNode->n ){ + if( (pNode[i].jnFlags & JNODE_REMOVE)==0 ) n++; i += jsonNodeSize(&pNode[i]); } if( (pNode->jnFlags & JNODE_APPEND)==0 ) break; @@ -222986,15 +222992,19 @@ static int sessionReadRecord( } } if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){ - sqlite3_int64 v = sessionGetI64(aVal); - if( eType==SQLITE_INTEGER ){ - sqlite3VdbeMemSetInt64(apOut[i], v); + if( (pIn->nData-pIn->iNext)<8 ){ + rc = SQLITE_CORRUPT_BKPT; }else{ - double d; - memcpy(&d, &v, 8); - sqlite3VdbeMemSetDouble(apOut[i], d); + sqlite3_int64 v = sessionGetI64(aVal); + if( eType==SQLITE_INTEGER ){ + sqlite3VdbeMemSetInt64(apOut[i], v); + }else{ + double d; + memcpy(&d, &v, 8); + sqlite3VdbeMemSetDouble(apOut[i], d); + } + pIn->iNext += 8; } - pIn->iNext += 8; } } } @@ -239820,80 +239830,79 @@ static void fts5DoSecureDelete( } } }else if( iStart==4 ){ - int iPgno; + int iPgno; - assert_nc( pSeg->iLeafPgno>pSeg->iTermLeafPgno ); - /* The entry being removed may be the only position list in - ** its doclist. */ - for(iPgno=pSeg->iLeafPgno-1; iPgno>pSeg->iTermLeafPgno; iPgno-- ){ - Fts5Data *pPg = fts5DataRead(p, FTS5_SEGMENT_ROWID(iSegid, iPgno)); - int bEmpty = (pPg && pPg->nn==4); - fts5DataRelease(pPg); - if( bEmpty==0 ) break; - } + assert_nc( pSeg->iLeafPgno>pSeg->iTermLeafPgno ); + /* The entry being removed may be the only position list in + ** its doclist. */ + for(iPgno=pSeg->iLeafPgno-1; iPgno>pSeg->iTermLeafPgno; iPgno-- ){ + Fts5Data *pPg = fts5DataRead(p, FTS5_SEGMENT_ROWID(iSegid, iPgno)); + int bEmpty = (pPg && pPg->nn==4); + fts5DataRelease(pPg); + if( bEmpty==0 ) break; + } - if( iPgno==pSeg->iTermLeafPgno ){ - i64 iId = FTS5_SEGMENT_ROWID(iSegid, pSeg->iTermLeafPgno); - Fts5Data *pTerm = fts5DataRead(p, iId); - if( pTerm && pTerm->szLeaf==pSeg->iTermLeafOffset ){ - u8 *aTermIdx = &pTerm->p[pTerm->szLeaf]; - int nTermIdx = pTerm->nn - pTerm->szLeaf; - int iTermIdx = 0; - int iTermOff = 0; + if( iPgno==pSeg->iTermLeafPgno ){ + i64 iId = FTS5_SEGMENT_ROWID(iSegid, pSeg->iTermLeafPgno); + Fts5Data *pTerm = fts5DataRead(p, iId); + if( pTerm && pTerm->szLeaf==pSeg->iTermLeafOffset ){ + u8 *aTermIdx = &pTerm->p[pTerm->szLeaf]; + int nTermIdx = pTerm->nn - pTerm->szLeaf; + int iTermIdx = 0; + int iTermOff = 0; - while( 1 ){ - u32 iVal = 0; - int nByte = fts5GetVarint32(&aTermIdx[iTermIdx], iVal); - iTermOff += iVal; - if( (iTermIdx+nByte)>=nTermIdx ) break; - iTermIdx += nByte; - } - nTermIdx = iTermIdx; - - memmove(&pTerm->p[iTermOff], &pTerm->p[pTerm->szLeaf], nTermIdx); - fts5PutU16(&pTerm->p[2], iTermOff); - - fts5DataWrite(p, iId, pTerm->p, iTermOff+nTermIdx); - if( nTermIdx==0 ){ - fts5SecureDeleteIdxEntry(p, iSegid, pSeg->iTermLeafPgno); - } + while( 1 ){ + u32 iVal = 0; + int nByte = fts5GetVarint32(&aTermIdx[iTermIdx], iVal); + iTermOff += iVal; + if( (iTermIdx+nByte)>=nTermIdx ) break; + iTermIdx += nByte; } - fts5DataRelease(pTerm); + nTermIdx = iTermIdx; + + memmove(&pTerm->p[iTermOff], &pTerm->p[pTerm->szLeaf], nTermIdx); + fts5PutU16(&pTerm->p[2], iTermOff); + + fts5DataWrite(p, iId, pTerm->p, iTermOff+nTermIdx); + if( nTermIdx==0 ){ + fts5SecureDeleteIdxEntry(p, iSegid, pSeg->iTermLeafPgno); + } + } + fts5DataRelease(pTerm); + } + } + + if( p->rc==SQLITE_OK ){ + const int nMove = nPg - iNextOff; /* Number of bytes to move */ + int nShift = iNextOff - iOff; /* Distance to move them */ + + int iPrevKeyOut = 0; + int iKeyIn = 0; + + memmove(&aPg[iOff], &aPg[iNextOff], nMove); + iPgIdx -= nShift; + nPg = iPgIdx; + fts5PutU16(&aPg[2], iPgIdx); + + for(iIdx=0; iIdxiOff ? nShift : 0)); + nPg += sqlite3Fts5PutVarint(&aPg[nPg], iKeyOut - iPrevKeyOut); + iPrevKeyOut = iKeyOut; } } - if( p->rc==SQLITE_OK ){ - const int nMove = nPg - iNextOff; - int nShift = 0; - - memmove(&aPg[iOff], &aPg[iNextOff], nMove); - iPgIdx -= (iNextOff - iOff); - nPg = iPgIdx; - fts5PutU16(&aPg[2], iPgIdx); - - nShift = iNextOff - iOff; - for(iIdx=0, iKeyOff=0, iPrevKeyOff=0; iIdxiOff ){ - iKeyOff -= nShift; - nShift = 0; - } - nPg += sqlite3Fts5PutVarint(&aPg[nPg], iKeyOff - iPrevKeyOff); - iPrevKeyOff = iKeyOff; - } - } - - if( iPgIdx==nPg && nIdx>0 && pSeg->iLeafPgno!=1 ){ - fts5SecureDeleteIdxEntry(p, iSegid, pSeg->iLeafPgno); - } - - assert_nc( nPg>4 || fts5GetU16(aPg)==0 ); - fts5DataWrite(p, FTS5_SEGMENT_ROWID(iSegid,pSeg->iLeafPgno), aPg,nPg); + if( iPgIdx==nPg && nIdx>0 && pSeg->iLeafPgno!=1 ){ + fts5SecureDeleteIdxEntry(p, iSegid, pSeg->iLeafPgno); } - sqlite3_free(aIdx); + + assert_nc( nPg>4 || fts5GetU16(aPg)==0 ); + fts5DataWrite(p, FTS5_SEGMENT_ROWID(iSegid,pSeg->iLeafPgno), aPg, nPg); + } + sqlite3_free(aIdx); } /* @@ -245745,7 +245754,7 @@ static void fts5SourceIdFunc( ){ assert( nArg==0 ); UNUSED_PARAM2(nArg, apUnused); - sqlite3_result_text(pCtx, "fts5: 2023-08-24 12:36:59 0f80b798b3f4b81a7bb4233c58294edd0f1156f36b6ecf5ab8e83631d468778c", -1, SQLITE_TRANSIENT); + sqlite3_result_text(pCtx, "fts5: 2023-09-11 12:01:27 2d3a40c05c49e1a49264912b1a05bc2143ac0e7c3df588276ce80a4cbc9bd1b0", -1, SQLITE_TRANSIENT); } /* diff --git a/libsqlite3-sys/sqlite3/sqlite3.h b/libsqlite3-sys/sqlite3/sqlite3.h index ec451a5..b9d0692 100644 --- a/libsqlite3-sys/sqlite3/sqlite3.h +++ b/libsqlite3-sys/sqlite3/sqlite3.h @@ -146,9 +146,9 @@ extern "C" { ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ -#define SQLITE_VERSION "3.43.0" -#define SQLITE_VERSION_NUMBER 3043000 -#define SQLITE_SOURCE_ID "2023-08-24 12:36:59 0f80b798b3f4b81a7bb4233c58294edd0f1156f36b6ecf5ab8e83631d468778c" +#define SQLITE_VERSION "3.43.1" +#define SQLITE_VERSION_NUMBER 3043001 +#define SQLITE_SOURCE_ID "2023-09-11 12:01:27 2d3a40c05c49e1a49264912b1a05bc2143ac0e7c3df588276ce80a4cbc9bd1b0" /* ** CAPI3REF: Run-Time Library Version Numbers diff --git a/libsqlite3-sys/upgrade.sh b/libsqlite3-sys/upgrade.sh index 62a8164..6101133 100755 --- a/libsqlite3-sys/upgrade.sh +++ b/libsqlite3-sys/upgrade.sh @@ -9,7 +9,7 @@ export SQLITE3_LIB_DIR="$SCRIPT_DIR/sqlite3" export SQLITE3_INCLUDE_DIR="$SQLITE3_LIB_DIR" # Download and extract amalgamation -SQLITE=sqlite-amalgamation-3430000 +SQLITE=sqlite-amalgamation-3430100 curl -O https://sqlite.org/2023/$SQLITE.zip unzip -p "$SQLITE.zip" "$SQLITE/sqlite3.c" > "$SQLITE3_LIB_DIR/sqlite3.c" unzip -p "$SQLITE.zip" "$SQLITE/sqlite3.h" > "$SQLITE3_LIB_DIR/sqlite3.h" From abbf3291ef8a966f3d250627b9c6a38e51188c8d Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Fri, 6 Oct 2023 21:31:50 -0400 Subject: [PATCH 28/63] Use proper var names in trait definition The underscores are too confusing, plus IDE automatically copies them into the implementation, and the `_` is not what most people would expect. --- src/functions.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/functions.rs b/src/functions.rs index 7d9eeb7..6dfcb88 100644 --- a/src/functions.rs +++ b/src/functions.rs @@ -272,11 +272,11 @@ where /// call to [`step()`](Aggregate::step) to set up the context for an /// invocation of the function. (Note: `init()` will not be called if /// there are no rows.) - fn init(&self, _: &mut Context<'_>) -> Result; + fn init(&self, ctx: &mut Context<'_>) -> Result; /// "step" function called once for each row in an aggregate group. May be /// called 0 times if there are no rows. - fn step(&self, _: &mut Context<'_>, _: &mut A) -> Result<()>; + fn step(&self, ctx: &mut Context<'_>, acc: &mut A) -> Result<()>; /// Computes and returns the final result. Will be called exactly once for /// each invocation of the function. If [`step()`](Aggregate::step) was @@ -287,7 +287,7 @@ where /// given `None`. /// /// The passed context will have no arguments. - fn finalize(&self, _: &mut Context<'_>, _: Option) -> Result; + fn finalize(&self, ctx: &mut Context<'_>, acc: Option) -> Result; } /// `WindowAggregate` is the callback interface for @@ -301,10 +301,10 @@ where { /// Returns the current value of the aggregate. Unlike xFinal, the /// implementation should not delete any context. - fn value(&self, _: Option<&A>) -> Result; + fn value(&self, acc: Option<&A>) -> Result; /// Removes a row from the current window. - fn inverse(&self, _: &mut Context<'_>, _: &mut A) -> Result<()>; + fn inverse(&self, ctx: &mut Context<'_>, acc: &mut A) -> Result<()>; } bitflags::bitflags! { From c1eea9be00d134f5fc0da3c2f6b8122154e38c11 Mon Sep 17 00:00:00 2001 From: gwenn Date: Wed, 11 Oct 2023 18:30:34 +0200 Subject: [PATCH 29/63] Fix clippy warning: arc_with_non_send_sync - interrupt_lock --- src/inner_connection.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/inner_connection.rs b/src/inner_connection.rs index a7487a8..2e535df 100644 --- a/src/inner_connection.rs +++ b/src/inner_connection.rs @@ -40,7 +40,7 @@ pub struct InnerConnection { unsafe impl Send for InnerConnection {} impl InnerConnection { - #[allow(clippy::mutex_atomic)] + #[allow(clippy::mutex_atomic, clippy::arc_with_non_send_sync)] // See unsafe impl Send / Sync for InterruptHandle #[inline] pub unsafe fn new(db: *mut ffi::sqlite3, owned: bool) -> InnerConnection { InnerConnection { From 845761e498d3fdf7f65a64f43c7f2d300c46dbea Mon Sep 17 00:00:00 2001 From: gwenn Date: Wed, 11 Oct 2023 18:49:27 +0200 Subject: [PATCH 30/63] Fix clippy warning redundant_guards --- src/hooks.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/hooks.rs b/src/hooks.rs index a069686..52a53a3 100644 --- a/src/hooks.rs +++ b/src/hooks.rs @@ -776,9 +776,10 @@ mod test { .unwrap(); let authorizer = move |ctx: AuthContext<'_>| match ctx.action { - AuthAction::Read { column_name, .. } if column_name == "private" => { - Authorization::Ignore - } + AuthAction::Read { + column_name: "private", + .. + } => Authorization::Ignore, AuthAction::DropTable { .. } => Authorization::Deny, AuthAction::Pragma { .. } => panic!("shouldn't be called"), _ => Authorization::Allow, From 94bba92ba04c0f77d2b58694fa535d665c025980 Mon Sep 17 00:00:00 2001 From: gwenn Date: Wed, 11 Oct 2023 19:01:31 +0200 Subject: [PATCH 31/63] Fix clippy warning unnecessary_cast --- src/functions.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/functions.rs b/src/functions.rs index 6dfcb88..8f34f31 100644 --- a/src/functions.rs +++ b/src/functions.rs @@ -638,6 +638,7 @@ unsafe extern "C" fn call_boxed_step( args: slice::from_raw_parts(argv, argc as usize), }; + #[allow(clippy::unnecessary_cast)] if (*pac as *mut A).is_null() { *pac = Box::into_raw(Box::new((*boxed_aggr).init(&mut ctx)?)); } @@ -708,7 +709,9 @@ where // Within the xFinal callback, it is customary to set N=0 in calls to // sqlite3_aggregate_context(C,N) so that no pointless memory allocations occur. let a: Option = match aggregate_context(ctx, 0) { - Some(pac) => { + Some(pac) => + { + #[allow(clippy::unnecessary_cast)] if (*pac as *mut A).is_null() { None } else { @@ -753,7 +756,9 @@ where // Within the xValue callback, it is customary to set N=0 in calls to // sqlite3_aggregate_context(C,N) so that no pointless memory allocations occur. let a: Option<&A> = match aggregate_context(ctx, 0) { - Some(pac) => { + Some(pac) => + { + #[allow(clippy::unnecessary_cast)] if (*pac as *mut A).is_null() { None } else { From 0953cbebd879ef8b8b6805dccdb6ec54ed4b8405 Mon Sep 17 00:00:00 2001 From: gwenn Date: Thu, 12 Oct 2023 18:37:26 +0200 Subject: [PATCH 32/63] Bump bundled SQLite version to 3.43.2 --- .../sqlite3/bindgen_bundled_version.rs | 6 +-- libsqlite3-sys/sqlite3/sqlite3.c | 45 +++++++++++-------- libsqlite3-sys/sqlite3/sqlite3.h | 6 +-- libsqlite3-sys/upgrade.sh | 2 +- 4 files changed, 33 insertions(+), 26 deletions(-) diff --git a/libsqlite3-sys/sqlite3/bindgen_bundled_version.rs b/libsqlite3-sys/sqlite3/bindgen_bundled_version.rs index 5327a3a..c05987b 100644 --- a/libsqlite3-sys/sqlite3/bindgen_bundled_version.rs +++ b/libsqlite3-sys/sqlite3/bindgen_bundled_version.rs @@ -23,10 +23,10 @@ extern "C" { ) -> ::std::os::raw::c_int; } -pub const SQLITE_VERSION: &[u8; 7] = b"3.43.1\0"; -pub const SQLITE_VERSION_NUMBER: i32 = 3043001; +pub const SQLITE_VERSION: &[u8; 7] = b"3.43.2\0"; +pub const SQLITE_VERSION_NUMBER: i32 = 3043002; pub const SQLITE_SOURCE_ID: &[u8; 85] = - b"2023-09-11 12:01:27 2d3a40c05c49e1a49264912b1a05bc2143ac0e7c3df588276ce80a4cbc9bd1b0\0"; + b"2023-10-10 12:14:04 4310099cce5a487035fa535dd3002c59ac7f1d1bec68d7cf317fd3e769484790\0"; pub const SQLITE_OK: i32 = 0; pub const SQLITE_ERROR: i32 = 1; pub const SQLITE_INTERNAL: i32 = 2; diff --git a/libsqlite3-sys/sqlite3/sqlite3.c b/libsqlite3-sys/sqlite3/sqlite3.c index 1884b08..a1fbd60 100644 --- a/libsqlite3-sys/sqlite3/sqlite3.c +++ b/libsqlite3-sys/sqlite3/sqlite3.c @@ -1,6 +1,6 @@ /****************************************************************************** ** This file is an amalgamation of many separate C source files from SQLite -** version 3.43.1. By combining all the individual C code files into this +** version 3.43.2. By combining all the individual C code files into this ** single large file, the entire code can be compiled as a single translation ** unit. This allows many compilers to do optimizations that would not be ** possible if the files were compiled separately. Performance improvements @@ -18,7 +18,7 @@ ** separate file. This file contains only code for the core SQLite library. ** ** The content in this amalgamation comes from Fossil check-in -** d3a40c05c49e1a49264912b1a05bc2143ac. +** 310099cce5a487035fa535dd3002c59ac7f. */ #define SQLITE_CORE 1 #define SQLITE_AMALGAMATION 1 @@ -459,9 +459,9 @@ extern "C" { ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ -#define SQLITE_VERSION "3.43.1" -#define SQLITE_VERSION_NUMBER 3043001 -#define SQLITE_SOURCE_ID "2023-09-11 12:01:27 2d3a40c05c49e1a49264912b1a05bc2143ac0e7c3df588276ce80a4cbc9bd1b0" +#define SQLITE_VERSION "3.43.2" +#define SQLITE_VERSION_NUMBER 3043002 +#define SQLITE_SOURCE_ID "2023-10-10 12:14:04 4310099cce5a487035fa535dd3002c59ac7f1d1bec68d7cf317fd3e769484790" /* ** CAPI3REF: Run-Time Library Version Numbers @@ -35185,29 +35185,29 @@ SQLITE_PRIVATE void sqlite3FpDecode(FpDecode *p, double r, int iRound, int mxRou double rr[2]; rr[0] = r; rr[1] = 0.0; - if( rr[0]>1.84e+19 ){ - while( rr[0]>1.84e+119 ){ + if( rr[0]>9.223372036854774784e+18 ){ + while( rr[0]>9.223372036854774784e+118 ){ exp += 100; dekkerMul2(rr, 1.0e-100, -1.99918998026028836196e-117); } - while( rr[0]>1.84e+29 ){ + while( rr[0]>9.223372036854774784e+28 ){ exp += 10; dekkerMul2(rr, 1.0e-10, -3.6432197315497741579e-27); } - while( rr[0]>1.84e+19 ){ + while( rr[0]>9.223372036854774784e+18 ){ exp += 1; dekkerMul2(rr, 1.0e-01, -5.5511151231257827021e-18); } }else{ - while( rr[0]<1.84e-82 ){ + while( rr[0]<9.223372036854774784e-83 ){ exp -= 100; dekkerMul2(rr, 1.0e+100, -1.5902891109759918046e+83); } - while( rr[0]<1.84e+08 ){ + while( rr[0]<9.223372036854774784e+07 ){ exp -= 10; dekkerMul2(rr, 1.0e+10, 0.0); } - while( rr[0]<1.84e+18 ){ + while( rr[0]<9.22337203685477478e+17 ){ exp -= 1; dekkerMul2(rr, 1.0e+01, 0.0); } @@ -77024,6 +77024,7 @@ static int rebuildPage( int k; /* Current slot in pCArray->apEnd[] */ u8 *pSrcEnd; /* Current pCArray->apEnd[k] value */ + assert( nCell>0 ); assert( i(u32)usableSize) ){ j = 0; } @@ -77330,6 +77331,7 @@ static int editPage( return SQLITE_OK; editpage_fail: /* Unable to edit this page. Rebuild it from scratch instead. */ + if( nNew<1 ) return SQLITE_CORRUPT_BKPT; populateCellCache(pCArray, iNew, nNew); return rebuildPage(pCArray, iNew, nNew, pPg); } @@ -100833,8 +100835,7 @@ static int blobSeekToRow(Incrblob *p, sqlite3_int64 iRow, char **pzErr){ /* Set the value of register r[1] in the SQL statement to integer iRow. ** This is done directly as a performance optimization */ - v->aMem[1].flags = MEM_Int; - v->aMem[1].u.i = iRow; + sqlite3VdbeMemSetInt64(&v->aMem[1], iRow); /* If the statement has been run before (and is paused at the OP_ResultRow) ** then back it up to the point where it does the OP_NotExists. This could @@ -204136,6 +204137,7 @@ static void jsonReplaceFunc( } pParse = jsonParseCached(ctx, argv[0], ctx, argc>1); if( pParse==0 ) return; + pParse->nJPRef++; for(i=1; i<(u32)argc; i+=2){ zPath = (const char*)sqlite3_value_text(argv[i]); pParse->useMod = 1; @@ -204148,6 +204150,7 @@ static void jsonReplaceFunc( jsonReturnJson(pParse, pParse->aNode, ctx, 1); replace_err: jsonDebugPrintParse(pParse); + jsonParseFree(pParse); } @@ -204182,6 +204185,7 @@ static void jsonSetFunc( } pParse = jsonParseCached(ctx, argv[0], ctx, argc>1); if( pParse==0 ) return; + pParse->nJPRef++; for(i=1; i<(u32)argc; i+=2){ zPath = (const char*)sqlite3_value_text(argv[i]); bApnd = 0; @@ -204198,9 +204202,8 @@ static void jsonSetFunc( } jsonDebugPrintParse(pParse); jsonReturnJson(pParse, pParse->aNode, ctx, 1); - jsonSetDone: - /* no cleanup required */; + jsonParseFree(pParse); } /* @@ -239689,7 +239692,6 @@ static void fts5DoSecureDelete( int iIdx = 0; int iStart = 0; int iKeyOff = 0; - int iPrevKeyOff = 0; int iDelKeyOff = 0; /* Offset of deleted key, if any */ nIdx = nPg-iPgIdx; @@ -244251,6 +244253,9 @@ static int fts5FilterMethod( pCsr->iFirstRowid = fts5GetRowidLimit(pRowidGe, SMALLEST_INT64); } + rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex); + if( rc!=SQLITE_OK ) goto filter_out; + if( pTab->pSortCsr ){ /* If pSortCsr is non-NULL, then this call is being made as part of ** processing for a "... MATCH ORDER BY rank" query (ePlan is @@ -244273,7 +244278,9 @@ static int fts5FilterMethod( pCsr->pExpr = pTab->pSortCsr->pExpr; rc = fts5CursorFirst(pTab, pCsr, bDesc); }else if( pCsr->pExpr ){ - rc = fts5CursorParseRank(pConfig, pCsr, pRank); + if( rc==SQLITE_OK ){ + rc = fts5CursorParseRank(pConfig, pCsr, pRank); + } if( rc==SQLITE_OK ){ if( bOrderByRank ){ pCsr->ePlan = FTS5_PLAN_SORTED_MATCH; @@ -245754,7 +245761,7 @@ static void fts5SourceIdFunc( ){ assert( nArg==0 ); UNUSED_PARAM2(nArg, apUnused); - sqlite3_result_text(pCtx, "fts5: 2023-09-11 12:01:27 2d3a40c05c49e1a49264912b1a05bc2143ac0e7c3df588276ce80a4cbc9bd1b0", -1, SQLITE_TRANSIENT); + sqlite3_result_text(pCtx, "fts5: 2023-10-10 12:14:04 4310099cce5a487035fa535dd3002c59ac7f1d1bec68d7cf317fd3e769484790", -1, SQLITE_TRANSIENT); } /* diff --git a/libsqlite3-sys/sqlite3/sqlite3.h b/libsqlite3-sys/sqlite3/sqlite3.h index b9d0692..0376113 100644 --- a/libsqlite3-sys/sqlite3/sqlite3.h +++ b/libsqlite3-sys/sqlite3/sqlite3.h @@ -146,9 +146,9 @@ extern "C" { ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ -#define SQLITE_VERSION "3.43.1" -#define SQLITE_VERSION_NUMBER 3043001 -#define SQLITE_SOURCE_ID "2023-09-11 12:01:27 2d3a40c05c49e1a49264912b1a05bc2143ac0e7c3df588276ce80a4cbc9bd1b0" +#define SQLITE_VERSION "3.43.2" +#define SQLITE_VERSION_NUMBER 3043002 +#define SQLITE_SOURCE_ID "2023-10-10 12:14:04 4310099cce5a487035fa535dd3002c59ac7f1d1bec68d7cf317fd3e769484790" /* ** CAPI3REF: Run-Time Library Version Numbers diff --git a/libsqlite3-sys/upgrade.sh b/libsqlite3-sys/upgrade.sh index 6101133..882fb73 100755 --- a/libsqlite3-sys/upgrade.sh +++ b/libsqlite3-sys/upgrade.sh @@ -9,7 +9,7 @@ export SQLITE3_LIB_DIR="$SCRIPT_DIR/sqlite3" export SQLITE3_INCLUDE_DIR="$SQLITE3_LIB_DIR" # Download and extract amalgamation -SQLITE=sqlite-amalgamation-3430100 +SQLITE=sqlite-amalgamation-3430200 curl -O https://sqlite.org/2023/$SQLITE.zip unzip -p "$SQLITE.zip" "$SQLITE/sqlite3.c" > "$SQLITE3_LIB_DIR/sqlite3.c" unzip -p "$SQLITE.zip" "$SQLITE/sqlite3.h" > "$SQLITE3_LIB_DIR/sqlite3.h" From d8c7ad32027b7e7d6258d2ea2d7925780e42dd79 Mon Sep 17 00:00:00 2001 From: gwenn Date: Mon, 16 Oct 2023 19:00:55 +0200 Subject: [PATCH 33/63] Regenerate bindgen_bundled_version_ext.rs for version 3.43.2 --- .../sqlite3/bindgen_bundled_version_ext.rs | 43 +++++++++++++++---- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs b/libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs index 0028a4b..ed7fc5c 100644 --- a/libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs +++ b/libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs @@ -1,9 +1,9 @@ -/* automatically generated by rust-bindgen 0.66.1 */ +/* automatically generated by rust-bindgen 0.68.1 */ -pub const SQLITE_VERSION: &[u8; 7] = b"3.42.0\0"; -pub const SQLITE_VERSION_NUMBER: i32 = 3042000; +pub const SQLITE_VERSION: &[u8; 7] = b"3.43.2\0"; +pub const SQLITE_VERSION_NUMBER: i32 = 3043002; pub const SQLITE_SOURCE_ID: &[u8; 85] = - b"2023-05-16 12:36:15 831d0fb2836b71c9bc51067c49fee4b8f18047814f2ff22d817d25195cf350b0\0"; + b"2023-10-10 12:14:04 4310099cce5a487035fa535dd3002c59ac7f1d1bec68d7cf317fd3e769484790\0"; pub const SQLITE_OK: i32 = 0; pub const SQLITE_ERROR: i32 = 1; pub const SQLITE_INTERNAL: i32 = 2; @@ -71,6 +71,7 @@ pub const SQLITE_IOERR_COMMIT_ATOMIC: i32 = 7690; pub const SQLITE_IOERR_ROLLBACK_ATOMIC: i32 = 7946; pub const SQLITE_IOERR_DATA: i32 = 8202; pub const SQLITE_IOERR_CORRUPTFS: i32 = 8458; +pub const SQLITE_IOERR_IN_PAGE: i32 = 8714; pub const SQLITE_LOCKED_SHAREDCACHE: i32 = 262; pub const SQLITE_LOCKED_VTAB: i32 = 518; pub const SQLITE_BUSY_RECOVERY: i32 = 261; @@ -401,7 +402,8 @@ pub const SQLITE_TESTCTRL_SEEK_COUNT: i32 = 30; pub const SQLITE_TESTCTRL_TRACEFLAGS: i32 = 31; pub const SQLITE_TESTCTRL_TUNE: i32 = 32; pub const SQLITE_TESTCTRL_LOGEST: i32 = 33; -pub const SQLITE_TESTCTRL_LAST: i32 = 33; +pub const SQLITE_TESTCTRL_USELONGDOUBLE: i32 = 34; +pub const SQLITE_TESTCTRL_LAST: i32 = 34; pub const SQLITE_STATUS_MEMORY_USED: i32 = 0; pub const SQLITE_STATUS_PAGECACHE_USED: i32 = 1; pub const SQLITE_STATUS_PAGECACHE_OVERFLOW: i32 = 2; @@ -1346,7 +1348,7 @@ pub struct fts5_api { unsafe extern "C" fn( pApi: *mut fts5_api, zName: *const ::std::os::raw::c_char, - pContext: *mut ::std::os::raw::c_void, + pUserData: *mut ::std::os::raw::c_void, pTokenizer: *mut fts5_tokenizer, xDestroy: ::std::option::Option, ) -> ::std::os::raw::c_int, @@ -1355,7 +1357,7 @@ pub struct fts5_api { unsafe extern "C" fn( pApi: *mut fts5_api, zName: *const ::std::os::raw::c_char, - ppContext: *mut *mut ::std::os::raw::c_void, + ppUserData: *mut *mut ::std::os::raw::c_void, pTokenizer: *mut fts5_tokenizer, ) -> ::std::os::raw::c_int, >, @@ -1363,7 +1365,7 @@ pub struct fts5_api { unsafe extern "C" fn( pApi: *mut fts5_api, zName: *const ::std::os::raw::c_char, - pContext: *mut ::std::os::raw::c_void, + pUserData: *mut ::std::os::raw::c_void, xFunction: fts5_extension_function, xDestroy: ::std::option::Option, ) -> ::std::os::raw::c_int, @@ -2864,6 +2866,12 @@ pub struct sqlite3_api_routines { >, pub is_interrupted: ::std::option::Option ::std::os::raw::c_int>, + pub stmt_explain: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, } pub type sqlite3_loadext_entry = ::std::option::Option< unsafe extern "C" fn( @@ -7399,6 +7407,24 @@ pub unsafe fn sqlite3_is_interrupted(arg1: *mut sqlite3) -> ::std::os::raw::c_in (fun)(arg1) } +static __SQLITE3_STMT_EXPLAIN: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_stmt_explain( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_STMT_EXPLAIN + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + /// Like SQLITE_EXTENSION_INIT2 macro pub unsafe fn rusqlite_extension_init2( p_api: *mut sqlite3_api_routines, @@ -7730,6 +7756,7 @@ pub unsafe fn rusqlite_extension_init2( __SQLITE3_DB_NAME.store((*p_api).db_name, ::atomic::Ordering::Release); __SQLITE3_VALUE_ENCODING.store((*p_api).value_encoding, ::atomic::Ordering::Release); __SQLITE3_IS_INTERRUPTED.store((*p_api).is_interrupted, ::atomic::Ordering::Release); + __SQLITE3_STMT_EXPLAIN.store((*p_api).stmt_explain, ::atomic::Ordering::Release); Ok(()) } From 3b70307a9462b25ba7cb27b27d234587822ed287 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Fri, 6 Oct 2023 17:21:19 -0400 Subject: [PATCH 34/63] Make WindowAggregate::value pass mutable value ref --- src/functions.rs | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/functions.rs b/src/functions.rs index 8f34f31..522f116 100644 --- a/src/functions.rs +++ b/src/functions.rs @@ -301,7 +301,7 @@ where { /// Returns the current value of the aggregate. Unlike xFinal, the /// implementation should not delete any context. - fn value(&self, acc: Option<&A>) -> Result; + fn value(&self, acc: Option<&mut A>) -> Result; /// Removes a row from the current window. fn inverse(&self, ctx: &mut Context<'_>, acc: &mut A) -> Result<()>; @@ -755,19 +755,10 @@ where { // Within the xValue callback, it is customary to set N=0 in calls to // sqlite3_aggregate_context(C,N) so that no pointless memory allocations occur. - let a: Option<&A> = match aggregate_context(ctx, 0) { - Some(pac) => - { - #[allow(clippy::unnecessary_cast)] - if (*pac as *mut A).is_null() { - None - } else { - let a = &**pac; - Some(a) - } - } - None => None, - }; + let pac = aggregate_context(ctx, 0).filter(|&pac| { + #[allow(clippy::unnecessary_cast)] + !(*pac as *mut A).is_null() + }); let r = catch_unwind(|| { let boxed_aggr: *mut W = ffi::sqlite3_user_data(ctx).cast::(); @@ -775,7 +766,7 @@ where !boxed_aggr.is_null(), "Internal error - null aggregate pointer" ); - (*boxed_aggr).value(a) + (*boxed_aggr).value(pac.map(|pac| &mut **pac)) }); let t = match r { Err(_) => { @@ -1030,7 +1021,7 @@ mod test { Ok(()) } - fn value(&self, sum: Option<&i64>) -> Result> { + fn value(&self, sum: Option<&mut i64>) -> Result> { Ok(sum.copied()) } } From 0438d7606f806f19f20c49758b8716584ca2a9db Mon Sep 17 00:00:00 2001 From: gwenn <45554+gwenn@users.noreply.github.com> Date: Sat, 21 Oct 2023 08:37:12 +0200 Subject: [PATCH 35/63] Add new constants introduced by SQLite 3.43.0 --- libsqlite3-sys/src/error.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libsqlite3-sys/src/error.rs b/libsqlite3-sys/src/error.rs index 6de7184..5c28fde 100644 --- a/libsqlite3-sys/src/error.rs +++ b/libsqlite3-sys/src/error.rs @@ -132,6 +132,8 @@ const SQLITE_IOERR_BEGIN_ATOMIC: c_int = super::SQLITE_IOERR | (29 << 8); const SQLITE_IOERR_COMMIT_ATOMIC: c_int = super::SQLITE_IOERR | (30 << 8); const SQLITE_IOERR_ROLLBACK_ATOMIC: c_int = super::SQLITE_IOERR | (31 << 8); const SQLITE_IOERR_DATA: c_int = super::SQLITE_IOERR | (32 << 8); +const SQLITE_IOERR_CORRUPTFS: c_int = super::SQLITE_IOERR | (33 << 8); +const SQLITE_IOERR_IN_PAGE: c_int = super::SQLITE_IOERR | (34 << 8); const SQLITE_LOCKED_VTAB: c_int = super::SQLITE_LOCKED | (2 << 8); From 7185c01f96a126eef01731b7f5498f2994fd37d4 Mon Sep 17 00:00:00 2001 From: gwenn <45554+gwenn@users.noreply.github.com> Date: Sat, 21 Oct 2023 08:46:42 +0200 Subject: [PATCH 36/63] Add new constants introduced by SQLite 3.43.0 --- libsqlite3-sys/src/error.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libsqlite3-sys/src/error.rs b/libsqlite3-sys/src/error.rs index 5c28fde..2f46b93 100644 --- a/libsqlite3-sys/src/error.rs +++ b/libsqlite3-sys/src/error.rs @@ -221,6 +221,8 @@ pub fn code_to_str(code: c_int) -> &'static str { SQLITE_IOERR_COMMIT_ATOMIC => "SQLITE_IOERR_COMMIT_ATOMIC", SQLITE_IOERR_ROLLBACK_ATOMIC => "SQLITE_IOERR_ROLLBACK_ATOMIC", SQLITE_IOERR_DATA => "SQLITE_IOERR_DATA", + SQLITE_IOERR_CORRUPTFS => "SQLITE_IOERR_CORRUPTFS", + SQLITE_IOERR_IN_PAGE => "SQLITE_IOERR_IN_PAGE", super::SQLITE_LOCKED_SHAREDCACHE => "Locking conflict due to another connection with a shared cache", SQLITE_LOCKED_VTAB => "SQLITE_LOCKED_VTAB", From 97051f25de9255607f016dccd3ad9f67d062e12f Mon Sep 17 00:00:00 2001 From: gwenn Date: Fri, 3 Nov 2023 19:28:08 +0100 Subject: [PATCH 37/63] Bump bundled SQLite version to 3.44.0 --- .../sqlite3/bindgen_bundled_version.rs | 48 +- libsqlite3-sys/sqlite3/sqlite3.c | 6460 +++++++++++------ libsqlite3-sys/sqlite3/sqlite3.h | 199 +- libsqlite3-sys/sqlite3/sqlite3ext.h | 6 + libsqlite3-sys/upgrade.sh | 2 +- 5 files changed, 4348 insertions(+), 2367 deletions(-) diff --git a/libsqlite3-sys/sqlite3/bindgen_bundled_version.rs b/libsqlite3-sys/sqlite3/bindgen_bundled_version.rs index c05987b..76eea10 100644 --- a/libsqlite3-sys/sqlite3/bindgen_bundled_version.rs +++ b/libsqlite3-sys/sqlite3/bindgen_bundled_version.rs @@ -23,10 +23,10 @@ extern "C" { ) -> ::std::os::raw::c_int; } -pub const SQLITE_VERSION: &[u8; 7] = b"3.43.2\0"; -pub const SQLITE_VERSION_NUMBER: i32 = 3043002; +pub const SQLITE_VERSION: &[u8; 7] = b"3.44.0\0"; +pub const SQLITE_VERSION_NUMBER: i32 = 3044000; pub const SQLITE_SOURCE_ID: &[u8; 85] = - b"2023-10-10 12:14:04 4310099cce5a487035fa535dd3002c59ac7f1d1bec68d7cf317fd3e769484790\0"; + b"2023-11-01 11:23:50 17129ba1ff7f0daf37100ee82d507aef7827cf38de1866e2633096ae6ad81301\0"; pub const SQLITE_OK: i32 = 0; pub const SQLITE_ERROR: i32 = 1; pub const SQLITE_INTERNAL: i32 = 2; @@ -397,6 +397,7 @@ pub const SQLITE_TESTCTRL_FIRST: i32 = 5; pub const SQLITE_TESTCTRL_PRNG_SAVE: i32 = 5; pub const SQLITE_TESTCTRL_PRNG_RESTORE: i32 = 6; pub const SQLITE_TESTCTRL_PRNG_RESET: i32 = 7; +pub const SQLITE_TESTCTRL_FK_NO_ACTION: i32 = 7; pub const SQLITE_TESTCTRL_BITVEC_TEST: i32 = 8; pub const SQLITE_TESTCTRL_FAULT_INSTALL: i32 = 9; pub const SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS: i32 = 10; @@ -493,6 +494,7 @@ pub const SQLITE_CHANGESETSTART_INVERT: i32 = 2; pub const SQLITE_CHANGESETAPPLY_NOSAVEPOINT: i32 = 1; pub const SQLITE_CHANGESETAPPLY_INVERT: i32 = 2; pub const SQLITE_CHANGESETAPPLY_IGNORENOOP: i32 = 4; +pub const SQLITE_CHANGESETAPPLY_FKNOACTION: i32 = 8; pub const SQLITE_CHANGESET_DATA: i32 = 1; pub const SQLITE_CHANGESET_NOTFOUND: i32 = 2; pub const SQLITE_CHANGESET_CONFLICT: i32 = 3; @@ -1695,6 +1697,20 @@ extern "C" { arg3: ::std::option::Option, ); } +extern "C" { + pub fn sqlite3_get_clientdata( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + ) -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub fn sqlite3_set_clientdata( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *mut ::std::os::raw::c_void, + arg4: ::std::option::Option, + ) -> ::std::os::raw::c_int; +} pub type sqlite3_destructor_type = ::std::option::Option; extern "C" { @@ -2182,6 +2198,15 @@ pub struct sqlite3_module { pub xShadowName: ::std::option::Option< unsafe extern "C" fn(arg1: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int, >, + pub xIntegrity: ::std::option::Option< + unsafe extern "C" fn( + pVTab: *mut sqlite3_vtab, + zSchema: *const ::std::os::raw::c_char, + zTabName: *const ::std::os::raw::c_char, + mFlags: ::std::os::raw::c_int, + pzErr: *mut *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, } #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -3079,6 +3104,16 @@ extern "C" { ppOut: *mut *mut ::std::os::raw::c_void, ) -> ::std::os::raw::c_int; } +extern "C" { + pub fn sqlite3changeset_upgrade( + db: *mut sqlite3, + zDb: *const ::std::os::raw::c_char, + nIn: ::std::os::raw::c_int, + pIn: *const ::std::os::raw::c_void, + pnOut: *mut ::std::os::raw::c_int, + ppOut: *mut *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int; +} #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct sqlite3_changegroup { @@ -3087,6 +3122,13 @@ pub struct sqlite3_changegroup { extern "C" { pub fn sqlite3changegroup_new(pp: *mut *mut sqlite3_changegroup) -> ::std::os::raw::c_int; } +extern "C" { + pub fn sqlite3changegroup_schema( + arg1: *mut sqlite3_changegroup, + arg2: *mut sqlite3, + zDb: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int; +} extern "C" { pub fn sqlite3changegroup_add( arg1: *mut sqlite3_changegroup, diff --git a/libsqlite3-sys/sqlite3/sqlite3.c b/libsqlite3-sys/sqlite3/sqlite3.c index a1fbd60..8f9309a 100644 --- a/libsqlite3-sys/sqlite3/sqlite3.c +++ b/libsqlite3-sys/sqlite3/sqlite3.c @@ -1,6 +1,6 @@ /****************************************************************************** ** This file is an amalgamation of many separate C source files from SQLite -** version 3.43.2. By combining all the individual C code files into this +** version 3.44.0. By combining all the individual C code files into this ** single large file, the entire code can be compiled as a single translation ** unit. This allows many compilers to do optimizations that would not be ** possible if the files were compiled separately. Performance improvements @@ -18,7 +18,7 @@ ** separate file. This file contains only code for the core SQLite library. ** ** The content in this amalgamation comes from Fossil check-in -** 310099cce5a487035fa535dd3002c59ac7f. +** 17129ba1ff7f0daf37100ee82d507aef7827. */ #define SQLITE_CORE 1 #define SQLITE_AMALGAMATION 1 @@ -459,9 +459,9 @@ extern "C" { ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ -#define SQLITE_VERSION "3.43.2" -#define SQLITE_VERSION_NUMBER 3043002 -#define SQLITE_SOURCE_ID "2023-10-10 12:14:04 4310099cce5a487035fa535dd3002c59ac7f1d1bec68d7cf317fd3e769484790" +#define SQLITE_VERSION "3.44.0" +#define SQLITE_VERSION_NUMBER 3044000 +#define SQLITE_SOURCE_ID "2023-11-01 11:23:50 17129ba1ff7f0daf37100ee82d507aef7827cf38de1866e2633096ae6ad81301" /* ** CAPI3REF: Run-Time Library Version Numbers @@ -2440,7 +2440,7 @@ struct sqlite3_mem_methods { ** is stored in each sorted record and the required column values loaded ** from the database as records are returned in sorted order. The default ** value for this option is to never use this optimization. Specifying a -** negative value for this option restores the default behaviour. +** negative value for this option restores the default behavior. ** This option is only available if SQLite is compiled with the ** [SQLITE_ENABLE_SORTER_REFERENCES] compile-time option. ** @@ -2615,7 +2615,7 @@ struct sqlite3_mem_methods { ** database handle, SQLite checks if this will mean that there are now no ** connections at all to the database. If so, it performs a checkpoint ** operation before closing the connection. This option may be used to -** override this behaviour. The first parameter passed to this operation +** override this behavior. The first parameter passed to this operation ** is an integer - positive to disable checkpoints-on-close, or zero (the ** default) to enable them, and negative to leave the setting unchanged. ** The second parameter is a pointer to an integer @@ -4268,6 +4268,7 @@ SQLITE_API void sqlite3_free_filename(sqlite3_filename); ** ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language ** text that describes the error, as either UTF-8 or UTF-16 respectively. +** (See how SQLite handles [invalid UTF] for exceptions to this rule.) ** ^(Memory to hold the error message string is managed internally. ** The application does not need to worry about freeing the result. ** However, the error string might be overwritten or deallocated by @@ -5638,6 +5639,7 @@ SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt); */ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); + /* ** CAPI3REF: Create Or Redefine SQL Functions ** KEYWORDS: {function creation routines} @@ -6192,32 +6194,32 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*); ** METHOD: sqlite3_context ** ** These functions may be used by (non-aggregate) SQL functions to -** associate metadata with argument values. If the same value is passed to -** multiple invocations of the same SQL function during query execution, under -** some circumstances the associated metadata may be preserved. An example -** of where this might be useful is in a regular-expression matching -** function. The compiled version of the regular expression can be stored as -** metadata associated with the pattern string. +** associate auxiliary data with argument values. If the same argument +** value is passed to multiple invocations of the same SQL function during +** query execution, under some circumstances the associated auxiliary data +** might be preserved. An example of where this might be useful is in a +** regular-expression matching function. The compiled version of the regular +** expression can be stored as auxiliary data associated with the pattern string. ** Then as long as the pattern string remains the same, ** the compiled regular expression can be reused on multiple ** invocations of the same function. ** -** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the metadata +** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the auxiliary data ** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument ** value to the application-defined function. ^N is zero for the left-most -** function argument. ^If there is no metadata +** function argument. ^If there is no auxiliary data ** associated with the function argument, the sqlite3_get_auxdata(C,N) interface ** returns a NULL pointer. ** -** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th -** argument of the application-defined function. ^Subsequent +** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as auxiliary data for the +** N-th argument of the application-defined function. ^Subsequent ** calls to sqlite3_get_auxdata(C,N) return P from the most recent -** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or -** NULL if the metadata has been discarded. +** sqlite3_set_auxdata(C,N,P,X) call if the auxiliary data is still valid or +** NULL if the auxiliary data has been discarded. ** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL, ** SQLite will invoke the destructor function X with parameter P exactly -** once, when the metadata is discarded. -** SQLite is free to discard the metadata at any time, including:
        +** once, when the auxiliary data is discarded. +** SQLite is free to discard the auxiliary data at any time, including:
          **
        • ^(when the corresponding function parameter changes)^, or **
        • ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the ** SQL statement)^, or @@ -6233,7 +6235,7 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*); ** function implementation should not make any use of P after ** sqlite3_set_auxdata() has been called. ** -** ^(In practice, metadata is preserved between function calls for +** ^(In practice, auxiliary data is preserved between function calls for ** function parameters that are compile-time constants, including literal ** values and [parameters] and expressions composed from the same.)^ ** @@ -6243,10 +6245,67 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*); ** ** These routines must be called from the same thread in which ** the SQL function is running. +** +** See also: [sqlite3_get_clientdata()] and [sqlite3_set_clientdata()]. */ SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N); SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*)); +/* +** CAPI3REF: Database Connection Client Data +** METHOD: sqlite3 +** +** These functions are used to associate one or more named pointers +** with a [database connection]. +** A call to sqlite3_set_clientdata(D,N,P,X) causes the pointer P +** to be attached to [database connection] D using name N. Subsequent +** calls to sqlite3_get_clientdata(D,N) will return a copy of pointer P +** or a NULL pointer if there were no prior calls to +** sqlite3_set_clientdata() with the same values of D and N. +** Names are compared using strcmp() and are thus case sensitive. +** +** If P and X are both non-NULL, then the destructor X is invoked with +** argument P on the first of the following occurrences: +**
            +**
          • An out-of-memory error occurs during the call to +** sqlite3_set_clientdata() which attempts to register pointer P. +**
          • A subsequent call to sqlite3_set_clientdata(D,N,P,X) is made +** with the same D and N parameters. +**
          • The database connection closes. SQLite does not make any guarantees +** about the order in which destructors are called, only that all +** destructors will be called exactly once at some point during the +** database connection closing process. +**
          +** +** SQLite does not do anything with client data other than invoke +** destructors on the client data at the appropriate time. The intended +** use for client data is to provide a mechanism for wrapper libraries +** to store additional information about an SQLite database connection. +** +** There is no limit (other than available memory) on the number of different +** client data pointers (with different names) that can be attached to a +** single database connection. However, the implementation is optimized +** for the case of having only one or two different client data names. +** Applications and wrapper libraries are discouraged from using more than +** one client data name each. +** +** There is no way to enumerate the client data pointers +** associated with a database connection. The N parameter can be thought +** of as a secret key such that only code that knows the secret key is able +** to access the associated data. +** +** Security Warning: These interfaces should not be exposed in scripting +** languages or in other circumstances where it might be possible for an +** an attacker to invoke them. Any agent that can invoke these interfaces +** can probably also take control of the process. +** +** Database connection client data is only available for SQLite +** version 3.44.0 ([dateof:3.44.0]) and later. +** +** See also: [sqlite3_set_auxdata()] and [sqlite3_get_auxdata()]. +*/ +SQLITE_API void *sqlite3_get_clientdata(sqlite3*,const char*); +SQLITE_API int sqlite3_set_clientdata(sqlite3*, const char*, void*, void(*)(void*)); /* ** CAPI3REF: Constants Defining Special Destructor Behavior @@ -6879,7 +6938,7 @@ SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName); SQLITE_API int sqlite3_txn_state(sqlite3*,const char *zSchema); /* -** CAPI3REF: Allowed return values from [sqlite3_txn_state()] +** CAPI3REF: Allowed return values from sqlite3_txn_state() ** KEYWORDS: {transaction state} ** ** These constants define the current transaction state of a database file. @@ -7011,7 +7070,7 @@ SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*); ** ^Each call to the sqlite3_autovacuum_pages() interface overrides all ** previous invocations for that database connection. ^If the callback ** argument (C) to sqlite3_autovacuum_pages(D,C,P,X) is a NULL pointer, -** then the autovacuum steps callback is cancelled. The return value +** then the autovacuum steps callback is canceled. The return value ** from sqlite3_autovacuum_pages() is normally SQLITE_OK, but might ** be some other error code if something goes wrong. The current ** implementation will only return SQLITE_OK or SQLITE_MISUSE, but other @@ -7530,6 +7589,10 @@ struct sqlite3_module { /* The methods above are in versions 1 and 2 of the sqlite_module object. ** Those below are for version 3 and greater. */ int (*xShadowName)(const char*); + /* The methods above are in versions 1 through 3 of the sqlite_module object. + ** Those below are for version 4 and greater. */ + int (*xIntegrity)(sqlite3_vtab *pVTab, const char *zSchema, + const char *zTabName, int mFlags, char **pzErr); }; /* @@ -8017,7 +8080,7 @@ SQLITE_API int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64); ** code is returned and the transaction rolled back. ** ** Calling this function with an argument that is not a NULL pointer or an -** open blob handle results in undefined behaviour. ^Calling this routine +** open blob handle results in undefined behavior. ^Calling this routine ** with a null pointer (such as would be returned by a failed call to ** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function ** is passed a valid open blob handle, the values returned by the @@ -8497,6 +8560,7 @@ SQLITE_API int sqlite3_test_control(int op, ...); #define SQLITE_TESTCTRL_PRNG_SAVE 5 #define SQLITE_TESTCTRL_PRNG_RESTORE 6 #define SQLITE_TESTCTRL_PRNG_RESET 7 /* NOT USED */ +#define SQLITE_TESTCTRL_FK_NO_ACTION 7 #define SQLITE_TESTCTRL_BITVEC_TEST 8 #define SQLITE_TESTCTRL_FAULT_INSTALL 9 #define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 @@ -9558,8 +9622,8 @@ SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p); ** blocked connection already has a registered unlock-notify callback, ** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is ** called with a NULL pointer as its second argument, then any existing -** unlock-notify callback is cancelled. ^The blocked connections -** unlock-notify callback may also be cancelled by closing the blocked +** unlock-notify callback is canceled. ^The blocked connections +** unlock-notify callback may also be canceled by closing the blocked ** connection using [sqlite3_close()]. ** ** The unlock-notify callback is not reentrant. If an application invokes @@ -10862,6 +10926,13 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const c ** SQLITE_SERIALIZE_NOCOPY bit is set but no contiguous copy ** of the database exists. ** +** After the call, if the SQLITE_SERIALIZE_NOCOPY bit had been set, +** the returned buffer content will remain accessible and unchanged +** until either the next write operation on the connection or when +** the connection is closed, and applications must not modify the +** buffer. If the bit had been clear, the returned buffer will not +** be accessed by SQLite after the call. +** ** A call to sqlite3_serialize(D,S,P,F) might return NULL even if the ** SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory ** allocation error occurs. @@ -10910,6 +10981,9 @@ SQLITE_API unsigned char *sqlite3_serialize( ** SQLite will try to increase the buffer size using sqlite3_realloc64() ** if writes on the database cause it to grow larger than M bytes. ** +** Applications must not modify the buffer P or invalidate it before +** the database connection D is closed. +** ** The sqlite3_deserialize() interface will fail with SQLITE_BUSY if the ** database is currently in a read transaction or is involved in a backup ** operation. @@ -10918,6 +10992,13 @@ SQLITE_API unsigned char *sqlite3_serialize( ** S argument to sqlite3_deserialize(D,S,P,N,M,F) is "temp" then the ** function returns SQLITE_ERROR. ** +** The deserialized database should not be in [WAL mode]. If the database +** is in WAL mode, then any attempt to use the database file will result +** in an [SQLITE_CANTOPEN] error. The application can set the +** [file format version numbers] (bytes 18 and 19) of the input database P +** to 0x01 prior to invoking sqlite3_deserialize(D,S,P,N,M,F) to force the +** database file into rollback mode and work around this limitation. +** ** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the ** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then ** [sqlite3_free()] is invoked on argument P prior to returning. @@ -11990,6 +12071,18 @@ SQLITE_API int sqlite3changeset_concat( ); +/* +** CAPI3REF: Upgrade the Schema of a Changeset/Patchset +*/ +SQLITE_API int sqlite3changeset_upgrade( + sqlite3 *db, + const char *zDb, + int nIn, const void *pIn, /* Input changeset */ + int *pnOut, void **ppOut /* OUT: Inverse of input */ +); + + + /* ** CAPI3REF: Changegroup Handle ** @@ -12036,6 +12129,38 @@ typedef struct sqlite3_changegroup sqlite3_changegroup; */ SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp); +/* +** CAPI3REF: Add a Schema to a Changegroup +** METHOD: sqlite3_changegroup_schema +** +** This method may be used to optionally enforce the rule that the changesets +** added to the changegroup handle must match the schema of database zDb +** ("main", "temp", or the name of an attached database). If +** sqlite3changegroup_add() is called to add a changeset that is not compatible +** with the configured schema, SQLITE_SCHEMA is returned and the changegroup +** object is left in an undefined state. +** +** A changeset schema is considered compatible with the database schema in +** the same way as for sqlite3changeset_apply(). Specifically, for each +** table in the changeset, there exists a database table with: +** +**
            +**
          • The name identified by the changeset, and +**
          • at least as many columns as recorded in the changeset, and +**
          • the primary key columns in the same position as recorded in +** the changeset. +**
          +** +** The output of the changegroup object always has the same schema as the +** database nominated using this function. In cases where changesets passed +** to sqlite3changegroup_add() have fewer columns than the corresponding table +** in the database schema, these are filled in using the default column +** values from the database schema. This makes it possible to combined +** changesets that have different numbers of columns for a single table +** within a changegroup, provided that they are otherwise compatible. +*/ +SQLITE_API int sqlite3changegroup_schema(sqlite3_changegroup*, sqlite3*, const char *zDb); + /* ** CAPI3REF: Add A Changeset To A Changegroup ** METHOD: sqlite3_changegroup @@ -12104,13 +12229,18 @@ SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp); ** If the new changeset contains changes to a table that is already present ** in the changegroup, then the number of columns and the position of the ** primary key columns for the table must be consistent. If this is not the -** case, this function fails with SQLITE_SCHEMA. If the input changeset -** appears to be corrupt and the corruption is detected, SQLITE_CORRUPT is -** returned. Or, if an out-of-memory condition occurs during processing, this -** function returns SQLITE_NOMEM. In all cases, if an error occurs the state -** of the final contents of the changegroup is undefined. +** case, this function fails with SQLITE_SCHEMA. Except, if the changegroup +** object has been configured with a database schema using the +** sqlite3changegroup_schema() API, then it is possible to combine changesets +** with different numbers of columns for a single table, provided that +** they are otherwise compatible. ** -** If no error occurs, SQLITE_OK is returned. +** If the input changeset appears to be corrupt and the corruption is +** detected, SQLITE_CORRUPT is returned. Or, if an out-of-memory condition +** occurs during processing, this function returns SQLITE_NOMEM. +** +** In all cases, if an error occurs the state of the final contents of the +** changegroup is undefined. If no error occurs, SQLITE_OK is returned. */ SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData); @@ -12375,10 +12505,17 @@ SQLITE_API int sqlite3changeset_apply_v2( **
        • an insert change if all fields of the conflicting row match ** the row being inserted. **
        +** +**
        SQLITE_CHANGESETAPPLY_FKNOACTION
        +** If this flag it set, then all foreign key constraints in the target +** database behave as if they were declared with "ON UPDATE NO ACTION ON +** DELETE NO ACTION", even if they are actually CASCADE, RESTRICT, SET NULL +** or SET DEFAULT. */ #define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001 #define SQLITE_CHANGESETAPPLY_INVERT 0x0002 #define SQLITE_CHANGESETAPPLY_IGNORENOOP 0x0004 +#define SQLITE_CHANGESETAPPLY_FKNOACTION 0x0008 /* ** CAPI3REF: Constants Passed To The Conflict Handler @@ -13769,6 +13906,16 @@ struct fts5_api { # endif #endif +/* +** Enable SQLITE_USE_SEH by default on MSVC builds. Only omit +** SEH support if the -DSQLITE_OMIT_SEH option is given. +*/ +#if defined(_MSC_VER) && !defined(SQLITE_OMIT_SEH) +# define SQLITE_USE_SEH 1 +#else +# undef SQLITE_USE_SEH +#endif + /* ** The SQLITE_THREADSAFE macro must be defined as 0, 1, or 2. ** 0 means mutexes are permanently disable and the library is never @@ -14662,16 +14809,33 @@ typedef INT16_TYPE LogEst; ** using C-preprocessor macros. If that is unsuccessful, or if ** -DSQLITE_BYTEORDER=0 is set, then byte-order is determined ** at run-time. +** +** If you are building SQLite on some obscure platform for which the +** following ifdef magic does not work, you can always include either: +** +** -DSQLITE_BYTEORDER=1234 +** +** or +** +** -DSQLITE_BYTEORDER=4321 +** +** to cause the build to work for little-endian or big-endian processors, +** respectively. */ -#ifndef SQLITE_BYTEORDER -# if defined(i386) || defined(__i386__) || defined(_M_IX86) || \ +#ifndef SQLITE_BYTEORDER /* Replicate changes at tag-20230904a */ +# if defined(__BYTE_ORDER__) && __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ +# define SQLITE_BYTEORDER 4321 +# elif defined(__BYTE_ORDER__) && __BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__ +# define SQLITE_BYTEORDER 1234 +# elif defined(__BIG_ENDIAN__) && __BIG_ENDIAN__==1 +# define SQLITE_BYTEORDER 4321 +# elif defined(i386) || defined(__i386__) || defined(_M_IX86) || \ defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \ defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \ defined(__ARMEL__) || defined(__AARCH64EL__) || defined(_M_ARM64) -# define SQLITE_BYTEORDER 1234 -# elif defined(sparc) || defined(__ppc__) || \ - defined(__ARMEB__) || defined(__AARCH64EB__) -# define SQLITE_BYTEORDER 4321 +# define SQLITE_BYTEORDER 1234 +# elif defined(sparc) || defined(__ARMEB__) || defined(__AARCH64EB__) +# define SQLITE_BYTEORDER 4321 # else # define SQLITE_BYTEORDER 0 # endif @@ -14995,6 +15159,7 @@ typedef struct Column Column; typedef struct Cte Cte; typedef struct CteUse CteUse; typedef struct Db Db; +typedef struct DbClientData DbClientData; typedef struct DbFixer DbFixer; typedef struct Schema Schema; typedef struct Expr Expr; @@ -16435,19 +16600,20 @@ typedef struct VdbeOpList VdbeOpList; #define OP_VCreate 171 #define OP_VDestroy 172 #define OP_VOpen 173 -#define OP_VInitIn 174 /* synopsis: r[P2]=ValueList(P1,P3) */ -#define OP_VColumn 175 /* synopsis: r[P3]=vcolumn(P2) */ -#define OP_VRename 176 -#define OP_Pagecount 177 -#define OP_MaxPgcnt 178 -#define OP_ClrSubtype 179 /* synopsis: r[P1].subtype = 0 */ -#define OP_FilterAdd 180 /* synopsis: filter(P1) += key(P3@P4) */ -#define OP_Trace 181 -#define OP_CursorHint 182 -#define OP_ReleaseReg 183 /* synopsis: release r[P1@P2] mask P3 */ -#define OP_Noop 184 -#define OP_Explain 185 -#define OP_Abortable 186 +#define OP_VCheck 174 +#define OP_VInitIn 175 /* synopsis: r[P2]=ValueList(P1,P3) */ +#define OP_VColumn 176 /* synopsis: r[P3]=vcolumn(P2) */ +#define OP_VRename 177 +#define OP_Pagecount 178 +#define OP_MaxPgcnt 179 +#define OP_ClrSubtype 180 /* synopsis: r[P1].subtype = 0 */ +#define OP_FilterAdd 181 /* synopsis: filter(P1) += key(P3@P4) */ +#define OP_Trace 182 +#define OP_CursorHint 183 +#define OP_ReleaseReg 184 /* synopsis: release r[P1@P2] mask P3 */ +#define OP_Noop 185 +#define OP_Explain 186 +#define OP_Abortable 187 /* Properties such as "out2" or "jump" that are specified in ** comments following the "case" for each opcode in the vdbe.c @@ -16482,9 +16648,9 @@ typedef struct VdbeOpList VdbeOpList; /* 144 */ 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\ /* 152 */ 0x00, 0x10, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04,\ /* 160 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ -/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x50, 0x40,\ -/* 176 */ 0x00, 0x10, 0x10, 0x02, 0x00, 0x00, 0x00, 0x00,\ -/* 184 */ 0x00, 0x00, 0x00,} +/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x10, 0x50,\ +/* 176 */ 0x40, 0x00, 0x10, 0x10, 0x02, 0x00, 0x00, 0x00,\ +/* 184 */ 0x00, 0x00, 0x00, 0x00,} /* The resolve3P2Values() routine is able to run faster if it knows ** the value of the largest JUMP opcode. The smaller the maximum @@ -17393,6 +17559,7 @@ struct sqlite3 { i64 nDeferredCons; /* Net deferred constraints this transaction. */ i64 nDeferredImmCons; /* Net deferred immediate constraints */ int *pnBytesFreed; /* If not NULL, increment this in DbFree() */ + DbClientData *pDbData; /* sqlite3_set_clientdata() content */ #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY /* The following variables are all protected by the STATIC_MAIN ** mutex, not by sqlite3.mutex. They are used by code in notify.c. @@ -17475,6 +17642,7 @@ struct sqlite3 { /* the count using a callback. */ #define SQLITE_CorruptRdOnly HI(0x00002) /* Prohibit writes due to error */ #define SQLITE_ReadUncommit HI(0x00004) /* READ UNCOMMITTED in shared-cache */ +#define SQLITE_FkNoAction HI(0x00008) /* Treat all FK as NO ACTION */ /* Flags used only if debugging */ #ifdef SQLITE_DEBUG @@ -18490,6 +18658,9 @@ struct AggInfo { FuncDef *pFunc; /* The aggregate function implementation */ int iDistinct; /* Ephemeral table used to enforce DISTINCT */ int iDistAddr; /* Address of OP_OpenEphemeral */ + int iOBTab; /* Ephemeral table to implement ORDER BY */ + u8 bOBPayload; /* iOBTab has payload columns separate from key */ + u8 bOBUnique; /* Enforce uniqueness on iOBTab keys */ } *aFunc; int nFunc; /* Number of entries in aFunc[] */ u32 selId; /* Select to which this AggInfo belongs */ @@ -18674,7 +18845,7 @@ struct Expr { #define EP_Reduced 0x004000 /* Expr struct EXPR_REDUCEDSIZE bytes only */ #define EP_Win 0x008000 /* Contains window functions */ #define EP_TokenOnly 0x010000 /* Expr struct EXPR_TOKENONLYSIZE bytes only */ - /* 0x020000 // Available for reuse */ +#define EP_FullSize 0x020000 /* Expr structure must remain full sized */ #define EP_IfNullRow 0x040000 /* The TK_IF_NULL_ROW opcode */ #define EP_Unlikely 0x080000 /* unlikely() or likelihood() function */ #define EP_ConstFunc 0x100000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */ @@ -18704,6 +18875,7 @@ struct Expr { #define ExprClearProperty(E,P) (E)->flags&=~(P) #define ExprAlwaysTrue(E) (((E)->flags&(EP_OuterON|EP_IsTrue))==EP_IsTrue) #define ExprAlwaysFalse(E) (((E)->flags&(EP_OuterON|EP_IsFalse))==EP_IsFalse) +#define ExprIsFullSize(E) (((E)->flags&(EP_Reduced|EP_TokenOnly))==0) /* Macros used to ensure that the correct members of unions are accessed ** in Expr. @@ -18821,6 +18993,7 @@ struct ExprList { #define ENAME_NAME 0 /* The AS clause of a result set */ #define ENAME_SPAN 1 /* Complete text of the result set expression */ #define ENAME_TAB 2 /* "DB.TABLE.NAME" for the result set */ +#define ENAME_ROWID 3 /* "DB.TABLE._rowid_" for * expansion of rowid */ /* ** An instance of this structure can hold a simple list of identifiers, @@ -19429,6 +19602,7 @@ struct Parse { int *aLabel; /* Space to hold the labels */ ExprList *pConstExpr;/* Constant expressions */ IndexedExpr *pIdxEpr;/* List of expressions used by active indexes */ + IndexedExpr *pIdxPartExpr; /* Exprs constrained by index WHERE clauses */ Token constraintName;/* Name of the constraint currently being parsed */ yDbMask writeMask; /* Start a write transaction on these databases */ yDbMask cookieMask; /* Bitmask of schema verified databases */ @@ -19700,6 +19874,7 @@ struct Returning { int iRetCur; /* Transient table holding RETURNING results */ int nRetCol; /* Number of in pReturnEL after expansion */ int iRetReg; /* Register array for holding a row of RETURNING */ + char zName[40]; /* Name of trigger: "sqlite_returning_%p" */ }; /* @@ -20000,6 +20175,16 @@ struct CteUse { }; +/* Client data associated with sqlite3_set_clientdata() and +** sqlite3_get_clientdata(). +*/ +struct DbClientData { + DbClientData *pNext; /* Next in a linked list */ + void *pData; /* The data */ + void (*xDestructor)(void*); /* Destructor. Might be NULL */ + char zName[1]; /* Name of this client data. MUST BE LAST */ +}; + #ifdef SQLITE_DEBUG /* ** An instance of the TreeView object is used for printing the content of @@ -20404,6 +20589,8 @@ SQLITE_PRIVATE void sqlite3PExprAddSelect(Parse*, Expr*, Select*); SQLITE_PRIVATE Expr *sqlite3ExprAnd(Parse*,Expr*, Expr*); SQLITE_PRIVATE Expr *sqlite3ExprSimplifiedAndOr(Expr*); SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse*,ExprList*, const Token*, int); +SQLITE_PRIVATE void sqlite3ExprAddFunctionOrderBy(Parse*,Expr*,ExprList*); +SQLITE_PRIVATE void sqlite3ExprOrderByAggregateError(Parse*,Expr*); SQLITE_PRIVATE void sqlite3ExprFunctionUsable(Parse*,const Expr*,const FuncDef*); SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32); SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*); @@ -20640,6 +20827,7 @@ SQLITE_PRIVATE int sqlite3ExprIsInteger(const Expr*, int*); SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr*); SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char); SQLITE_PRIVATE int sqlite3IsRowid(const char*); +SQLITE_PRIVATE const char *sqlite3RowidAlias(Table *pTab); SQLITE_PRIVATE void sqlite3GenerateRowDelete( Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8,int); SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*, int); @@ -20911,7 +21099,8 @@ SQLITE_PRIVATE int sqlite3MatchEName( const struct ExprList_item*, const char*, const char*, - const char* + const char*, + int* ); SQLITE_PRIVATE Bitmask sqlite3ExprColUsed(Expr*); SQLITE_PRIVATE u8 sqlite3StrIHash(const char*); @@ -20968,7 +21157,7 @@ SQLITE_PRIVATE int sqlite3ApiExit(sqlite3 *db, int); SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *); SQLITE_PRIVATE char *sqlite3RCStrRef(char*); -SQLITE_PRIVATE void sqlite3RCStrUnref(char*); +SQLITE_PRIVATE void sqlite3RCStrUnref(void*); SQLITE_PRIVATE char *sqlite3RCStrNew(u64); SQLITE_PRIVATE char *sqlite3RCStrResize(char*,u64); @@ -21804,6 +21993,9 @@ static const char * const sqlite3azCompileOpt[] = { #ifdef SQLITE_EXPLAIN_ESTIMATED_ROWS "EXPLAIN_ESTIMATED_ROWS", #endif +#ifdef SQLITE_EXTRA_AUTOEXT + "EXTRA_AUTOEXT=" CTIMEOPT_VAL(SQLITE_EXTRA_AUTOEXT), +#endif #ifdef SQLITE_EXTRA_IFNULLROW "EXTRA_IFNULLROW", #endif @@ -22085,6 +22277,9 @@ static const char * const sqlite3azCompileOpt[] = { #ifdef SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS "OMIT_SCHEMA_VERSION_PRAGMAS", #endif +#ifdef SQLITE_OMIT_SEH + "OMIT_SEH", +#endif #ifdef SQLITE_OMIT_SHARED_CACHE "OMIT_SHARED_CACHE", #endif @@ -25044,13 +25239,16 @@ static void strftimeFunc( computeJD(&x); computeYMD_HMS(&x); for(i=j=0; zFmt[i]; i++){ + char cf; if( zFmt[i]!='%' ) continue; if( j12 ) h -= 12; + if( h==0 ) h = 12; + sqlite3_str_appendf(&sRes, cf=='I' ? "%02d" : "%2d", h); break; } case 'W': /* Fall thru */ @@ -25072,7 +25283,7 @@ static void strftimeFunc( y.D = 1; computeJD(&y); nDay = (int)((x.iJD-y.iJD+43200000)/86400000); - if( zFmt[i]=='W' ){ + if( cf=='W' ){ int wd; /* 0=Monday, 1=Tuesday, ... 6=Sunday */ wd = (int)(((x.iJD+43200000)/86400000)%7); sqlite3_str_appendf(&sRes,"%02d",(nDay+7-wd)/7); @@ -25093,6 +25304,19 @@ static void strftimeFunc( sqlite3_str_appendf(&sRes,"%02d",x.m); break; } + case 'p': /* Fall thru */ + case 'P': { + if( x.h>=12 ){ + sqlite3_str_append(&sRes, cf=='p' ? "PM" : "pm", 2); + }else{ + sqlite3_str_append(&sRes, cf=='p' ? "AM" : "am", 2); + } + break; + } + case 'R': { + sqlite3_str_appendf(&sRes, "%02d:%02d", x.h, x.m); + break; + } case 's': { if( x.useSubsec ){ sqlite3_str_appendf(&sRes,"%.3f", @@ -25107,9 +25331,15 @@ static void strftimeFunc( sqlite3_str_appendf(&sRes,"%02d",(int)x.s); break; } + case 'T': { + sqlite3_str_appendf(&sRes,"%02d:%02d:%02d", x.h, x.m, (int)x.s); + break; + } + case 'u': /* Fall thru */ case 'w': { - sqlite3_str_appendchar(&sRes, 1, - (char)(((x.iJD+129600000)/86400000) % 7) + '0'); + char c = (char)(((x.iJD+129600000)/86400000) % 7) + '0'; + if( c=='0' && cf=='u' ) c = '7'; + sqlite3_str_appendchar(&sRes, 1, c); break; } case 'Y': { @@ -28198,7 +28428,7 @@ static void checkMutexFree(sqlite3_mutex *p){ assert( SQLITE_MUTEX_FAST<2 ); assert( SQLITE_MUTEX_WARNONCONTENTION<2 ); -#if SQLITE_ENABLE_API_ARMOR +#ifdef SQLITE_ENABLE_API_ARMOR if( ((CheckMutex*)p)->iType<2 ) #endif { @@ -28870,7 +29100,7 @@ static sqlite3_mutex *pthreadMutexAlloc(int iType){ */ static void pthreadMutexFree(sqlite3_mutex *p){ assert( p->nRef==0 ); -#if SQLITE_ENABLE_API_ARMOR +#ifdef SQLITE_ENABLE_API_ARMOR if( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE ) #endif { @@ -30434,7 +30664,7 @@ SQLITE_PRIVATE int sqlite3ApiExit(sqlite3* db, int rc){ if( db->mallocFailed || rc ){ return apiHandleError(db, rc); } - return rc & db->errMask; + return 0; } /************** End of malloc.c **********************************************/ @@ -31830,7 +32060,7 @@ SQLITE_PRIVATE char *sqlite3RCStrRef(char *z){ ** Decrease the reference count by one. Free the string when the ** reference count reaches zero. */ -SQLITE_PRIVATE void sqlite3RCStrUnref(char *z){ +SQLITE_PRIVATE void sqlite3RCStrUnref(void *z){ RCStr *p = (RCStr*)z; assert( p!=0 ); p--; @@ -32293,6 +32523,7 @@ SQLITE_PRIVATE void sqlite3TreeViewWindow(TreeView *pView, const Window *pWin, u sqlite3TreeViewItem(pView, "FILTER", 1); sqlite3TreeViewExpr(pView, pWin->pFilter, 0); sqlite3TreeViewPop(&pView); + if( pWin->eFrmType==TK_FILTER ) return; } sqlite3TreeViewPush(&pView, more); if( pWin->zName ){ @@ -32302,7 +32533,7 @@ SQLITE_PRIVATE void sqlite3TreeViewWindow(TreeView *pView, const Window *pWin, u } if( pWin->zBase ) nElement++; if( pWin->pOrderBy ) nElement++; - if( pWin->eFrmType ) nElement++; + if( pWin->eFrmType!=0 && pWin->eFrmType!=TK_FILTER ) nElement++; if( pWin->eExclude ) nElement++; if( pWin->zBase ){ sqlite3TreeViewPush(&pView, (--nElement)>0); @@ -32315,7 +32546,7 @@ SQLITE_PRIVATE void sqlite3TreeViewWindow(TreeView *pView, const Window *pWin, u if( pWin->pOrderBy ){ sqlite3TreeViewExprList(pView, pWin->pOrderBy, (--nElement)>0, "ORDER-BY"); } - if( pWin->eFrmType ){ + if( pWin->eFrmType!=0 && pWin->eFrmType!=TK_FILTER ){ char zBuf[30]; const char *zFrmType = "ROWS"; if( pWin->eFrmType==TK_RANGE ) zFrmType = "RANGE"; @@ -32563,7 +32794,7 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m assert( ExprUseXList(pExpr) ); pFarg = pExpr->x.pList; #ifndef SQLITE_OMIT_WINDOWFUNC - pWin = ExprHasProperty(pExpr, EP_WinFunc) ? pExpr->y.pWin : 0; + pWin = IsWindowFunc(pExpr) ? pExpr->y.pWin : 0; #else pWin = 0; #endif @@ -32589,7 +32820,13 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m sqlite3TreeViewLine(pView, "FUNCTION %Q%s", pExpr->u.zToken, zFlgs); } if( pFarg ){ - sqlite3TreeViewExprList(pView, pFarg, pWin!=0, 0); + sqlite3TreeViewExprList(pView, pFarg, pWin!=0 || pExpr->pLeft, 0); + if( pExpr->pLeft ){ + Expr *pOB = pExpr->pLeft; + assert( pOB->op==TK_ORDER ); + assert( ExprUseXList(pOB) ); + sqlite3TreeViewExprList(pView, pOB->x.pList, pWin!=0, "ORDERBY"); + } } #ifndef SQLITE_OMIT_WINDOWFUNC if( pWin ){ @@ -32598,6 +32835,10 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m #endif break; } + case TK_ORDER: { + sqlite3TreeViewExprList(pView, pExpr->x.pList, 0, "ORDERBY"); + break; + } #ifndef SQLITE_OMIT_SUBQUERY case TK_EXISTS: { assert( ExprUseXSelect(pExpr) ); @@ -34362,12 +34603,16 @@ SQLITE_PRIVATE void sqlite3ProgressCheck(Parse *p){ p->rc = SQLITE_INTERRUPT; } #ifndef SQLITE_OMIT_PROGRESS_CALLBACK - if( db->xProgress && (++p->nProgressSteps)>=db->nProgressOps ){ - if( db->xProgress(db->pProgressArg) ){ - p->nErr++; - p->rc = SQLITE_INTERRUPT; + if( db->xProgress ){ + if( p->rc==SQLITE_INTERRUPT ){ + p->nProgressSteps = 0; + }else if( (++p->nProgressSteps)>=db->nProgressOps ){ + if( db->xProgress(db->pProgressArg) ){ + p->nErr++; + p->rc = SQLITE_INTERRUPT; + } + p->nProgressSteps = 0; } - p->nProgressSteps = 0; } #endif } @@ -35523,121 +35768,32 @@ SQLITE_PRIVATE u8 sqlite3GetVarint(const unsigned char *p, u64 *v){ ** this function assumes the single-byte case has already been handled. */ SQLITE_PRIVATE u8 sqlite3GetVarint32(const unsigned char *p, u32 *v){ - u32 a,b; + u64 v64; + u8 n; - /* The 1-byte case. Overwhelmingly the most common. Handled inline - ** by the getVarin32() macro */ - a = *p; - /* a: p0 (unmasked) */ -#ifndef getVarint32 - if (!(a&0x80)) - { - /* Values between 0 and 127 */ - *v = a; - return 1; - } -#endif + /* Assume that the single-byte case has already been handled by + ** the getVarint32() macro */ + assert( (p[0] & 0x80)!=0 ); - /* The 2-byte case */ - p++; - b = *p; - /* b: p1 (unmasked) */ - if (!(b&0x80)) - { - /* Values between 128 and 16383 */ - a &= 0x7f; - a = a<<7; - *v = a | b; + if( (p[1] & 0x80)==0 ){ + /* This is the two-byte case */ + *v = ((p[0]&0x7f)<<7) | p[1]; return 2; } - - /* The 3-byte case */ - p++; - a = a<<14; - a |= *p; - /* a: p0<<14 | p2 (unmasked) */ - if (!(a&0x80)) - { - /* Values between 16384 and 2097151 */ - a &= (0x7f<<14)|(0x7f); - b &= 0x7f; - b = b<<7; - *v = a | b; + if( (p[2] & 0x80)==0 ){ + /* This is the three-byte case */ + *v = ((p[0]&0x7f)<<14) | ((p[1]&0x7f)<<7) | p[2]; return 3; } - - /* A 32-bit varint is used to store size information in btrees. - ** Objects are rarely larger than 2MiB limit of a 3-byte varint. - ** A 3-byte varint is sufficient, for example, to record the size - ** of a 1048569-byte BLOB or string. - ** - ** We only unroll the first 1-, 2-, and 3- byte cases. The very - ** rare larger cases can be handled by the slower 64-bit varint - ** routine. - */ -#if 1 - { - u64 v64; - u8 n; - - n = sqlite3GetVarint(p-2, &v64); - assert( n>3 && n<=9 ); - if( (v64 & SQLITE_MAX_U32)!=v64 ){ - *v = 0xffffffff; - }else{ - *v = (u32)v64; - } - return n; - } - -#else - /* For following code (kept for historical record only) shows an - ** unrolling for the 3- and 4-byte varint cases. This code is - ** slightly faster, but it is also larger and much harder to test. - */ - p++; - b = b<<14; - b |= *p; - /* b: p1<<14 | p3 (unmasked) */ - if (!(b&0x80)) - { - /* Values between 2097152 and 268435455 */ - b &= (0x7f<<14)|(0x7f); - a &= (0x7f<<14)|(0x7f); - a = a<<7; - *v = a | b; - return 4; - } - - p++; - a = a<<14; - a |= *p; - /* a: p0<<28 | p2<<14 | p4 (unmasked) */ - if (!(a&0x80)) - { - /* Values between 268435456 and 34359738367 */ - a &= SLOT_4_2_0; - b &= SLOT_4_2_0; - b = b<<7; - *v = a | b; - return 5; - } - - /* We can only reach this point when reading a corrupt database - ** file. In that case we are not in any hurry. Use the (relatively - ** slow) general-purpose sqlite3GetVarint() routine to extract the - ** value. */ - { - u64 v64; - u8 n; - - p -= 4; - n = sqlite3GetVarint(p, &v64); - assert( n>5 && n<=9 ); + /* four or more bytes */ + n = sqlite3GetVarint(p, &v64); + assert( n>3 && n<=9 ); + if( (v64 & SQLITE_MAX_U32)!=v64 ){ + *v = 0xffffffff; + }else{ *v = (u32)v64; - return n; } -#endif + return n; } /* @@ -36633,19 +36789,20 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){ /* 171 */ "VCreate" OpHelp(""), /* 172 */ "VDestroy" OpHelp(""), /* 173 */ "VOpen" OpHelp(""), - /* 174 */ "VInitIn" OpHelp("r[P2]=ValueList(P1,P3)"), - /* 175 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), - /* 176 */ "VRename" OpHelp(""), - /* 177 */ "Pagecount" OpHelp(""), - /* 178 */ "MaxPgcnt" OpHelp(""), - /* 179 */ "ClrSubtype" OpHelp("r[P1].subtype = 0"), - /* 180 */ "FilterAdd" OpHelp("filter(P1) += key(P3@P4)"), - /* 181 */ "Trace" OpHelp(""), - /* 182 */ "CursorHint" OpHelp(""), - /* 183 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"), - /* 184 */ "Noop" OpHelp(""), - /* 185 */ "Explain" OpHelp(""), - /* 186 */ "Abortable" OpHelp(""), + /* 174 */ "VCheck" OpHelp(""), + /* 175 */ "VInitIn" OpHelp("r[P2]=ValueList(P1,P3)"), + /* 176 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), + /* 177 */ "VRename" OpHelp(""), + /* 178 */ "Pagecount" OpHelp(""), + /* 179 */ "MaxPgcnt" OpHelp(""), + /* 180 */ "ClrSubtype" OpHelp("r[P1].subtype = 0"), + /* 181 */ "FilterAdd" OpHelp("filter(P1) += key(P3@P4)"), + /* 182 */ "Trace" OpHelp(""), + /* 183 */ "CursorHint" OpHelp(""), + /* 184 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"), + /* 185 */ "Noop" OpHelp(""), + /* 186 */ "Explain" OpHelp(""), + /* 187 */ "Abortable" OpHelp(""), }; return azName[i]; } @@ -40787,9 +40944,6 @@ static int afpUnlock(sqlite3_file *id, int eFileLock) { unixInodeInfo *pInode; afpLockingContext *context = (afpLockingContext *) pFile->lockingContext; int skipShared = 0; -#ifdef SQLITE_TEST - int h = pFile->h; -#endif assert( pFile ); OSTRACE(("UNLOCK %d %d was %d(%d,%d) pid=%d (afp)\n", pFile->h, eFileLock, @@ -40805,9 +40959,6 @@ static int afpUnlock(sqlite3_file *id, int eFileLock) { assert( pInode->nShared!=0 ); if( pFile->eFileLock>SHARED_LOCK ){ assert( pInode->eFileLock==pFile->eFileLock ); - SimulateIOErrorBenign(1); - SimulateIOError( h=(-1) ) - SimulateIOErrorBenign(0); #ifdef SQLITE_DEBUG /* When reducing a lock such that other processes can start @@ -40856,9 +41007,6 @@ static int afpUnlock(sqlite3_file *id, int eFileLock) { unsigned long long sharedLockByte = SHARED_FIRST+pInode->sharedByte; pInode->nShared--; if( pInode->nShared==0 ){ - SimulateIOErrorBenign(1); - SimulateIOError( h=(-1) ) - SimulateIOErrorBenign(0); if( !skipShared ){ rc = afpSetLock(context->dbPath, pFile, sharedLockByte, 1, 0); } @@ -57729,9 +57877,32 @@ static int writeJournalHdr(Pager *pPager){ memset(zHeader, 0, sizeof(aJournalMagic)+4); } + + /* The random check-hash initializer */ - sqlite3_randomness(sizeof(pPager->cksumInit), &pPager->cksumInit); + if( pPager->journalMode!=PAGER_JOURNALMODE_MEMORY ){ + sqlite3_randomness(sizeof(pPager->cksumInit), &pPager->cksumInit); + } +#ifdef SQLITE_DEBUG + else{ + /* The Pager.cksumInit variable is usually randomized above to protect + ** against there being existing records in the journal file. This is + ** dangerous, as following a crash they may be mistaken for records + ** written by the current transaction and rolled back into the database + ** file, causing corruption. The following assert statements verify + ** that this is not required in "journal_mode=memory" mode, as in that + ** case the journal file is always 0 bytes in size at this point. + ** It is advantageous to avoid the sqlite3_randomness() call if possible + ** as it takes the global PRNG mutex. */ + i64 sz = 0; + sqlite3OsFileSize(pPager->jfd, &sz); + assert( sz==0 ); + assert( pPager->journalOff==journalHdrOffset(pPager) ); + assert( sqlite3JournalIsInMemory(pPager->jfd) ); + } +#endif put32bits(&zHeader[sizeof(aJournalMagic)+4], pPager->cksumInit); + /* The initial database size */ put32bits(&zHeader[sizeof(aJournalMagic)+8], pPager->dbOrigSize); /* The assumed sector size for this process */ @@ -58375,6 +58546,9 @@ static int pager_end_transaction(Pager *pPager, int hasSuper, int bCommit){ return (rc==SQLITE_OK?rc2:rc); } +/* Forward reference */ +static int pager_playback(Pager *pPager, int isHot); + /* ** Execute a rollback if a transaction is active and unlock the ** database file. @@ -58403,6 +58577,21 @@ static void pagerUnlockAndRollback(Pager *pPager){ assert( pPager->eState==PAGER_READER ); pager_end_transaction(pPager, 0, 0); } + }else if( pPager->eState==PAGER_ERROR + && pPager->journalMode==PAGER_JOURNALMODE_MEMORY + && isOpen(pPager->jfd) + ){ + /* Special case for a ROLLBACK due to I/O error with an in-memory + ** journal: We have to rollback immediately, before the journal is + ** closed, because once it is closed, all content is forgotten. */ + int errCode = pPager->errCode; + u8 eLock = pPager->eLock; + pPager->eState = PAGER_OPEN; + pPager->errCode = SQLITE_OK; + pPager->eLock = EXCLUSIVE_LOCK; + pager_playback(pPager, 1); + pPager->errCode = errCode; + pPager->eLock = eLock; } pager_unlock(pPager); } @@ -61895,8 +62084,20 @@ SQLITE_PRIVATE int sqlite3PagerGet( DbPage **ppPage, /* Write a pointer to the page here */ int flags /* PAGER_GET_XXX flags */ ){ - /* printf("PAGE %u\n", pgno); fflush(stdout); */ +#if 0 /* Trace page fetch by setting to 1 */ + int rc; + printf("PAGE %u\n", pgno); + fflush(stdout); + rc = pPager->xGet(pPager, pgno, ppPage, flags); + if( rc ){ + printf("PAGE %u failed with 0x%02x\n", pgno, rc); + fflush(stdout); + } + return rc; +#else + /* Normal, high-speed version of sqlite3PagerGet() */ return pPager->xGet(pPager, pgno, ppPage, flags); +#endif } /* @@ -62772,6 +62973,13 @@ SQLITE_PRIVATE int sqlite3PagerCommitPhaseOne( rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_BEGIN_ATOMIC_WRITE, 0); if( rc==SQLITE_OK ){ rc = pager_write_pagelist(pPager, pList); + if( rc==SQLITE_OK && pPager->dbSize>pPager->dbFileSize ){ + char *pTmp = pPager->pTmpSpace; + int szPage = (int)pPager->pageSize; + memset(pTmp, 0, szPage); + rc = sqlite3OsWrite(pPager->fd, pTmp, szPage, + ((i64)pPager->dbSize*pPager->pageSize)-szPage); + } if( rc==SQLITE_OK ){ rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_COMMIT_ATOMIC_WRITE, 0); } @@ -63583,7 +63791,7 @@ SQLITE_PRIVATE int sqlite3PagerSetJournalMode(Pager *pPager, int eMode){ } assert( state==pPager->eState ); } - }else if( eMode==PAGER_JOURNALMODE_OFF ){ + }else if( eMode==PAGER_JOURNALMODE_OFF || eMode==PAGER_JOURNALMODE_MEMORY ){ sqlite3OsClose(pPager->jfd); } } @@ -69196,7 +69404,7 @@ struct IntegrityCk { BtShared *pBt; /* The tree being checked out */ Pager *pPager; /* The associated pager. Also accessible by pBt->pPager */ u8 *aPgRef; /* 1 bit per page in the db (see above) */ - Pgno nPage; /* Number of pages in the database */ + Pgno nCkPage; /* Pages in the database. 0 for partial check */ int mxErr; /* Stop accumulating errors when this reaches zero */ int nErr; /* Number of messages written to zErrMsg so far */ int rc; /* SQLITE_OK, SQLITE_NOMEM, or SQLITE_INTERRUPT */ @@ -69529,7 +69737,6 @@ SQLITE_PRIVATE void sqlite3BtreeLeaveCursor(BtCursor *pCur){ /************** End of btmutex.c *********************************************/ /************** Begin file btree.c *******************************************/ - /* ** 2004 April 6 ** @@ -77027,7 +77234,7 @@ static int rebuildPage( assert( nCell>0 ); assert( i(u32)usableSize) ){ j = 0; } + if( j>(u32)usableSize ){ j = 0; } memcpy(&pTmp[j], &aData[j], usableSize - j); for(k=0; ALWAYS(kixNx[k]<=i; k++){} @@ -79991,7 +80198,8 @@ static void checkAppendMsg( ** corresponds to page iPg is already set. */ static int getPageReferenced(IntegrityCk *pCheck, Pgno iPg){ - assert( iPg<=pCheck->nPage && sizeof(pCheck->aPgRef[0])==1 ); + assert( pCheck->aPgRef!=0 ); + assert( iPg<=pCheck->nCkPage && sizeof(pCheck->aPgRef[0])==1 ); return (pCheck->aPgRef[iPg/8] & (1 << (iPg & 0x07))); } @@ -79999,7 +80207,8 @@ static int getPageReferenced(IntegrityCk *pCheck, Pgno iPg){ ** Set the bit in the IntegrityCk.aPgRef[] array that corresponds to page iPg. */ static void setPageReferenced(IntegrityCk *pCheck, Pgno iPg){ - assert( iPg<=pCheck->nPage && sizeof(pCheck->aPgRef[0])==1 ); + assert( pCheck->aPgRef!=0 ); + assert( iPg<=pCheck->nCkPage && sizeof(pCheck->aPgRef[0])==1 ); pCheck->aPgRef[iPg/8] |= (1 << (iPg & 0x07)); } @@ -80013,7 +80222,7 @@ static void setPageReferenced(IntegrityCk *pCheck, Pgno iPg){ ** Also check that the page number is in bounds. */ static int checkRef(IntegrityCk *pCheck, Pgno iPage){ - if( iPage>pCheck->nPage || iPage==0 ){ + if( iPage>pCheck->nCkPage || iPage==0 ){ checkAppendMsg(pCheck, "invalid page number %u", iPage); return 1; } @@ -80240,6 +80449,7 @@ static int checkTreePage( if( (rc = btreeGetPage(pBt, iPage, &pPage, 0))!=0 ){ checkAppendMsg(pCheck, "unable to get the page. error code=%d", rc); + if( rc==SQLITE_IOERR_NOMEM ) pCheck->rc = SQLITE_NOMEM; goto end_of_check; } @@ -80510,15 +80720,15 @@ SQLITE_PRIVATE int sqlite3BtreeIntegrityCheck( sCheck.db = db; sCheck.pBt = pBt; sCheck.pPager = pBt->pPager; - sCheck.nPage = btreePagecount(sCheck.pBt); + sCheck.nCkPage = btreePagecount(sCheck.pBt); sCheck.mxErr = mxErr; sqlite3StrAccumInit(&sCheck.errMsg, 0, zErr, sizeof(zErr), SQLITE_MAX_LENGTH); sCheck.errMsg.printfFlags = SQLITE_PRINTF_INTERNAL; - if( sCheck.nPage==0 ){ + if( sCheck.nCkPage==0 ){ goto integrity_ck_cleanup; } - sCheck.aPgRef = sqlite3MallocZero((sCheck.nPage / 8)+ 1); + sCheck.aPgRef = sqlite3MallocZero((sCheck.nCkPage / 8)+ 1); if( !sCheck.aPgRef ){ checkOom(&sCheck); goto integrity_ck_cleanup; @@ -80530,7 +80740,7 @@ SQLITE_PRIVATE int sqlite3BtreeIntegrityCheck( } i = PENDING_BYTE_PAGE(pBt); - if( i<=sCheck.nPage ) setPageReferenced(&sCheck, i); + if( i<=sCheck.nCkPage ) setPageReferenced(&sCheck, i); /* Check the integrity of the freelist */ @@ -80581,7 +80791,7 @@ SQLITE_PRIVATE int sqlite3BtreeIntegrityCheck( /* Make sure every page in the file is referenced */ if( !bPartial ){ - for(i=1; i<=sCheck.nPage && sCheck.mxErr; i++){ + for(i=1; i<=sCheck.nCkPage && sCheck.mxErr; i++){ #ifdef SQLITE_OMIT_AUTOVACUUM if( getPageReferenced(&sCheck, i)==0 ){ checkAppendMsg(&sCheck, "Page %u: never used", i); @@ -82022,7 +82232,7 @@ SQLITE_PRIVATE void sqlite3VdbeMemZeroTerminateIfAble(Mem *pMem){ pMem->flags |= MEM_Term; return; } - if( pMem->xDel==(void(*)(void*))sqlite3RCStrUnref ){ + if( pMem->xDel==sqlite3RCStrUnref ){ /* Blindly assume that all RCStr objects are zero-terminated */ pMem->flags |= MEM_Term; return; @@ -83402,6 +83612,7 @@ static int valueFromExpr( if( pVal ){ pVal->flags = MEM_Int; pVal->u.i = pExpr->u.zToken[4]==0; + sqlite3ValueApplyAffinity(pVal, affinity, enc); } } @@ -84715,6 +84926,10 @@ SQLITE_PRIVATE void sqlite3VdbeNoJumpsOutsideSubrtn( int iDest = pOp->p2; /* Jump destination */ if( iDest==0 ) continue; if( pOp->opcode==OP_Gosub ) continue; + if( pOp->p3==20230325 && pOp->opcode==OP_NotNull ){ + /* This is a deliberately taken illegal branch. tag-20230325-2 */ + continue; + } if( iDest<0 ){ int j = ADDR(iDest); assert( j>=0 ); @@ -88174,20 +88389,33 @@ SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3BlobCompare(const Mem *pB1, const Mem return n1 - n2; } +/* The following two functions are used only within testcase() to prove +** test coverage. These functions do no exist for production builds. +** We must use separate SQLITE_NOINLINE functions here, since otherwise +** optimizer code movement causes gcov to become very confused. +*/ +#if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_DEBUG) +static int SQLITE_NOINLINE doubleLt(double a, double b){ return a8 ){ + if( sqlite3IsNaN(r) ){ + /* SQLite considers NaN to be a NULL. And all integer values are greater + ** than NULL */ + return 1; + } + if( sqlite3Config.bUseLongDouble ){ LONGDOUBLE_TYPE x = (LONGDOUBLE_TYPE)i; testcase( xr ); testcase( x==r ); - if( xr ) return +1; /*NO_TEST*/ /* work around bugs in gcov */ - return 0; /*NO_TEST*/ /* work around bugs in gcov */ + return (xr); }else{ i64 y; double s; @@ -88197,9 +88425,10 @@ SQLITE_PRIVATE int sqlite3IntFloatCompare(i64 i, double r){ if( iy ) return +1; s = (double)i; - if( sr ) return +1; - return 0; + testcase( doubleLt(s,r) ); + testcase( doubleLt(r,s) ); + testcase( doubleEq(r,s) ); + return (sr); } } @@ -89567,7 +89796,7 @@ SQLITE_API void sqlite3_value_free(sqlite3_value *pOld){ ** is too big or if an OOM occurs. ** ** The invokeValueDestructor(P,X) routine invokes destructor function X() -** on value P is not going to be used and need to be destroyed. +** on value P if P is not going to be used and need to be destroyed. */ static void setResultStrOrError( sqlite3_context *pCtx, /* Function context */ @@ -89597,7 +89826,7 @@ static void setResultStrOrError( static int invokeValueDestructor( const void *p, /* Value to destroy */ void (*xDel)(void*), /* The destructor */ - sqlite3_context *pCtx /* Set a SQLITE_TOOBIG error if no NULL */ + sqlite3_context *pCtx /* Set a SQLITE_TOOBIG error if not NULL */ ){ assert( xDel!=SQLITE_DYNAMIC ); if( xDel==0 ){ @@ -89607,7 +89836,14 @@ static int invokeValueDestructor( }else{ xDel((void*)p); } +#ifdef SQLITE_ENABLE_API_ARMOR + if( pCtx!=0 ){ + sqlite3_result_error_toobig(pCtx); + } +#else + assert( pCtx!=0 ); sqlite3_result_error_toobig(pCtx); +#endif return SQLITE_TOOBIG; } SQLITE_API void sqlite3_result_blob( @@ -89616,6 +89852,12 @@ SQLITE_API void sqlite3_result_blob( int n, void (*xDel)(void *) ){ +#ifdef SQLITE_ENABLE_API_ARMOR + if( pCtx==0 || n<0 ){ + invokeValueDestructor(z, xDel, pCtx); + return; + } +#endif assert( n>=0 ); assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); setResultStrOrError(pCtx, z, n, 0, xDel); @@ -89626,8 +89868,14 @@ SQLITE_API void sqlite3_result_blob64( sqlite3_uint64 n, void (*xDel)(void *) ){ - assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); assert( xDel!=SQLITE_DYNAMIC ); +#ifdef SQLITE_ENABLE_API_ARMOR + if( pCtx==0 ){ + invokeValueDestructor(z, xDel, 0); + return; + } +#endif + assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); if( n>0x7fffffff ){ (void)invokeValueDestructor(z, xDel, pCtx); }else{ @@ -89635,30 +89883,48 @@ SQLITE_API void sqlite3_result_blob64( } } SQLITE_API void sqlite3_result_double(sqlite3_context *pCtx, double rVal){ +#ifdef SQLITE_ENABLE_API_ARMOR + if( pCtx==0 ) return; +#endif assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); sqlite3VdbeMemSetDouble(pCtx->pOut, rVal); } SQLITE_API void sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){ +#ifdef SQLITE_ENABLE_API_ARMOR + if( pCtx==0 ) return; +#endif assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); pCtx->isError = SQLITE_ERROR; sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF8, SQLITE_TRANSIENT); } #ifndef SQLITE_OMIT_UTF16 SQLITE_API void sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){ +#ifdef SQLITE_ENABLE_API_ARMOR + if( pCtx==0 ) return; +#endif assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); pCtx->isError = SQLITE_ERROR; sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF16NATIVE, SQLITE_TRANSIENT); } #endif SQLITE_API void sqlite3_result_int(sqlite3_context *pCtx, int iVal){ +#ifdef SQLITE_ENABLE_API_ARMOR + if( pCtx==0 ) return; +#endif assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); sqlite3VdbeMemSetInt64(pCtx->pOut, (i64)iVal); } SQLITE_API void sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){ +#ifdef SQLITE_ENABLE_API_ARMOR + if( pCtx==0 ) return; +#endif assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); sqlite3VdbeMemSetInt64(pCtx->pOut, iVal); } SQLITE_API void sqlite3_result_null(sqlite3_context *pCtx){ +#ifdef SQLITE_ENABLE_API_ARMOR + if( pCtx==0 ) return; +#endif assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); sqlite3VdbeMemSetNull(pCtx->pOut); } @@ -89668,14 +89934,25 @@ SQLITE_API void sqlite3_result_pointer( const char *zPType, void (*xDestructor)(void*) ){ - Mem *pOut = pCtx->pOut; + Mem *pOut; +#ifdef SQLITE_ENABLE_API_ARMOR + if( pCtx==0 ){ + invokeValueDestructor(pPtr, xDestructor, 0); + return; + } +#endif + pOut = pCtx->pOut; assert( sqlite3_mutex_held(pOut->db->mutex) ); sqlite3VdbeMemRelease(pOut); pOut->flags = MEM_Null; sqlite3VdbeMemSetPointer(pOut, pPtr, zPType, xDestructor); } SQLITE_API void sqlite3_result_subtype(sqlite3_context *pCtx, unsigned int eSubtype){ - Mem *pOut = pCtx->pOut; + Mem *pOut; +#ifdef SQLITE_ENABLE_API_ARMOR + if( pCtx==0 ) return; +#endif + pOut = pCtx->pOut; assert( sqlite3_mutex_held(pOut->db->mutex) ); pOut->eSubtype = eSubtype & 0xff; pOut->flags |= MEM_Subtype; @@ -89686,6 +89963,12 @@ SQLITE_API void sqlite3_result_text( int n, void (*xDel)(void *) ){ +#ifdef SQLITE_ENABLE_API_ARMOR + if( pCtx==0 ){ + invokeValueDestructor(z, xDel, 0); + return; + } +#endif assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); setResultStrOrError(pCtx, z, n, SQLITE_UTF8, xDel); } @@ -89696,6 +89979,12 @@ SQLITE_API void sqlite3_result_text64( void (*xDel)(void *), unsigned char enc ){ +#ifdef SQLITE_ENABLE_API_ARMOR + if( pCtx==0 ){ + invokeValueDestructor(z, xDel, 0); + return; + } +#endif assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); assert( xDel!=SQLITE_DYNAMIC ); if( enc!=SQLITE_UTF8 ){ @@ -89739,7 +90028,16 @@ SQLITE_API void sqlite3_result_text16le( } #endif /* SQLITE_OMIT_UTF16 */ SQLITE_API void sqlite3_result_value(sqlite3_context *pCtx, sqlite3_value *pValue){ - Mem *pOut = pCtx->pOut; + Mem *pOut; + +#ifdef SQLITE_ENABLE_API_ARMOR + if( pCtx==0 ) return; + if( pValue==0 ){ + sqlite3_result_null(pCtx); + return; + } +#endif + pOut = pCtx->pOut; assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); sqlite3VdbeMemCopy(pOut, pValue); sqlite3VdbeChangeEncoding(pOut, pCtx->enc); @@ -89751,7 +90049,12 @@ SQLITE_API void sqlite3_result_zeroblob(sqlite3_context *pCtx, int n){ sqlite3_result_zeroblob64(pCtx, n>0 ? n : 0); } SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context *pCtx, u64 n){ - Mem *pOut = pCtx->pOut; + Mem *pOut; + +#ifdef SQLITE_ENABLE_API_ARMOR + if( pCtx==0 ) return SQLITE_MISUSE_BKPT; +#endif + pOut = pCtx->pOut; assert( sqlite3_mutex_held(pOut->db->mutex) ); if( n>(u64)pOut->db->aLimit[SQLITE_LIMIT_LENGTH] ){ sqlite3_result_error_toobig(pCtx); @@ -89765,6 +90068,9 @@ SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context *pCtx, u64 n){ #endif } SQLITE_API void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){ +#ifdef SQLITE_ENABLE_API_ARMOR + if( pCtx==0 ) return; +#endif pCtx->isError = errCode ? errCode : -1; #ifdef SQLITE_DEBUG if( pCtx->pVdbe ) pCtx->pVdbe->rcApp = errCode; @@ -89777,6 +90083,9 @@ SQLITE_API void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){ /* Force an SQLITE_TOOBIG error. */ SQLITE_API void sqlite3_result_error_toobig(sqlite3_context *pCtx){ +#ifdef SQLITE_ENABLE_API_ARMOR + if( pCtx==0 ) return; +#endif assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); pCtx->isError = SQLITE_TOOBIG; sqlite3VdbeMemSetStr(pCtx->pOut, "string or blob too big", -1, @@ -89785,6 +90094,9 @@ SQLITE_API void sqlite3_result_error_toobig(sqlite3_context *pCtx){ /* An SQLITE_NOMEM error. */ SQLITE_API void sqlite3_result_error_nomem(sqlite3_context *pCtx){ +#ifdef SQLITE_ENABLE_API_ARMOR + if( pCtx==0 ) return; +#endif assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); sqlite3VdbeMemSetNull(pCtx->pOut); pCtx->isError = SQLITE_NOMEM_BKPT; @@ -90037,7 +90349,11 @@ SQLITE_API int sqlite3_step(sqlite3_stmt *pStmt){ ** pointer to it. */ SQLITE_API void *sqlite3_user_data(sqlite3_context *p){ +#ifdef SQLITE_ENABLE_API_ARMOR + if( p==0 ) return 0; +#else assert( p && p->pFunc ); +#endif return p->pFunc->pUserData; } @@ -90052,7 +90368,11 @@ SQLITE_API void *sqlite3_user_data(sqlite3_context *p){ ** application defined function. */ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context *p){ +#ifdef SQLITE_ENABLE_API_ARMOR + if( p==0 ) return 0; +#else assert( p && p->pOut ); +#endif return p->pOut->db; } @@ -90071,7 +90391,11 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context *p){ ** value, as a signal to the xUpdate routine that the column is unchanged. */ SQLITE_API int sqlite3_vtab_nochange(sqlite3_context *p){ +#ifdef SQLITE_ENABLE_API_ARMOR + if( p==0 ) return 0; +#else assert( p ); +#endif return sqlite3_value_nochange(p->pOut); } @@ -90099,7 +90423,7 @@ static int valueFromValueList( ValueList *pRhs; *ppOut = 0; - if( pVal==0 ) return SQLITE_MISUSE; + if( pVal==0 ) return SQLITE_MISUSE_BKPT; if( (pVal->flags & MEM_Dyn)==0 || pVal->xDel!=sqlite3VdbeValueListFree ){ return SQLITE_ERROR; }else{ @@ -90230,6 +90554,9 @@ SQLITE_API void *sqlite3_aggregate_context(sqlite3_context *p, int nByte){ SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){ AuxData *pAuxData; +#ifdef SQLITE_ENABLE_API_ARMOR + if( pCtx==0 ) return 0; +#endif assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); #if SQLITE_ENABLE_STAT4 if( pCtx->pVdbe==0 ) return 0; @@ -90262,8 +90589,12 @@ SQLITE_API void sqlite3_set_auxdata( void (*xDelete)(void*) ){ AuxData *pAuxData; - Vdbe *pVdbe = pCtx->pVdbe; + Vdbe *pVdbe; +#ifdef SQLITE_ENABLE_API_ARMOR + if( pCtx==0 ) return; +#endif + pVdbe= pCtx->pVdbe; assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); #ifdef SQLITE_ENABLE_STAT4 if( pVdbe==0 ) goto failed; @@ -90700,7 +91031,7 @@ static int vdbeUnbind(Vdbe *p, unsigned int i){ } sqlite3_mutex_enter(p->db->mutex); if( p->eVdbeState!=VDBE_READY_STATE ){ - sqlite3Error(p->db, SQLITE_MISUSE); + sqlite3Error(p->db, SQLITE_MISUSE_BKPT); sqlite3_mutex_leave(p->db->mutex); sqlite3_log(SQLITE_MISUSE, "bind on a busy prepared statement: [%s]", p->zSql); @@ -90929,6 +91260,9 @@ SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){ SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt *pStmt, int i, sqlite3_uint64 n){ int rc; Vdbe *p = (Vdbe *)pStmt; +#ifdef SQLITE_ENABLE_API_ARMOR + if( p==0 ) return SQLITE_MISUSE_BKPT; +#endif sqlite3_mutex_enter(p->db->mutex); if( n>(u64)p->db->aLimit[SQLITE_LIMIT_LENGTH] ){ rc = SQLITE_TOOBIG; @@ -91055,6 +91389,9 @@ SQLITE_API int sqlite3_stmt_isexplain(sqlite3_stmt *pStmt){ SQLITE_API int sqlite3_stmt_explain(sqlite3_stmt *pStmt, int eMode){ Vdbe *v = (Vdbe*)pStmt; int rc; +#ifdef SQLITE_ENABLE_API_ARMOR + if( pStmt==0 ) return SQLITE_MISUSE_BKPT; +#endif sqlite3_mutex_enter(v->db->mutex); if( ((int)v->explain)==eMode ){ rc = SQLITE_OK; @@ -91221,10 +91558,16 @@ static UnpackedRecord *vdbeUnpackRecord( ** a field of the row currently being updated or deleted. */ SQLITE_API int sqlite3_preupdate_old(sqlite3 *db, int iIdx, sqlite3_value **ppValue){ - PreUpdate *p = db->pPreUpdate; + PreUpdate *p; Mem *pMem; int rc = SQLITE_OK; +#ifdef SQLITE_ENABLE_API_ARMOR + if( db==0 || ppValue==0 ){ + return SQLITE_MISUSE_BKPT; + } +#endif + p = db->pPreUpdate; /* Test that this call is being made from within an SQLITE_DELETE or ** SQLITE_UPDATE pre-update callback, and that iIdx is within range. */ if( !p || p->op==SQLITE_INSERT ){ @@ -91285,7 +91628,12 @@ SQLITE_API int sqlite3_preupdate_old(sqlite3 *db, int iIdx, sqlite3_value **ppVa ** the number of columns in the row being updated, deleted or inserted. */ SQLITE_API int sqlite3_preupdate_count(sqlite3 *db){ - PreUpdate *p = db->pPreUpdate; + PreUpdate *p; +#ifdef SQLITE_ENABLE_API_ARMOR + p = db!=0 ? db->pPreUpdate : 0; +#else + p = db->pPreUpdate; +#endif return (p ? p->keyinfo.nKeyField : 0); } #endif /* SQLITE_ENABLE_PREUPDATE_HOOK */ @@ -91303,7 +91651,12 @@ SQLITE_API int sqlite3_preupdate_count(sqlite3 *db){ ** or SET DEFAULT action is considered a trigger. */ SQLITE_API int sqlite3_preupdate_depth(sqlite3 *db){ - PreUpdate *p = db->pPreUpdate; + PreUpdate *p; +#ifdef SQLITE_ENABLE_API_ARMOR + p = db!=0 ? db->pPreUpdate : 0; +#else + p = db->pPreUpdate; +#endif return (p ? p->v->nFrame : 0); } #endif /* SQLITE_ENABLE_PREUPDATE_HOOK */ @@ -91314,7 +91667,12 @@ SQLITE_API int sqlite3_preupdate_depth(sqlite3 *db){ ** only. */ SQLITE_API int sqlite3_preupdate_blobwrite(sqlite3 *db){ - PreUpdate *p = db->pPreUpdate; + PreUpdate *p; +#ifdef SQLITE_ENABLE_API_ARMOR + p = db!=0 ? db->pPreUpdate : 0; +#else + p = db->pPreUpdate; +#endif return (p ? p->iBlobWrite : -1); } #endif @@ -91325,10 +91683,16 @@ SQLITE_API int sqlite3_preupdate_blobwrite(sqlite3 *db){ ** a field of the row currently being updated or inserted. */ SQLITE_API int sqlite3_preupdate_new(sqlite3 *db, int iIdx, sqlite3_value **ppValue){ - PreUpdate *p = db->pPreUpdate; + PreUpdate *p; int rc = SQLITE_OK; Mem *pMem; +#ifdef SQLITE_ENABLE_API_ARMOR + if( db==0 || ppValue==0 ){ + return SQLITE_MISUSE_BKPT; + } +#endif + p = db->pPreUpdate; if( !p || p->op==SQLITE_DELETE ){ rc = SQLITE_MISUSE_BKPT; goto preupdate_new_out; @@ -91407,11 +91771,20 @@ SQLITE_API int sqlite3_stmt_scanstatus_v2( void *pOut /* OUT: Write the answer here */ ){ Vdbe *p = (Vdbe*)pStmt; - VdbeOp *aOp = p->aOp; - int nOp = p->nOp; + VdbeOp *aOp; + int nOp; ScanStatus *pScan = 0; int idx; +#ifdef SQLITE_ENABLE_API_ARMOR + if( p==0 || pOut==0 + || iScanStatusOpSQLITE_SCANSTAT_NCYCLE ){ + return 1; + } +#endif + aOp = p->aOp; + nOp = p->nOp; if( p->pFrame ){ VdbeFrame *pFrame; for(pFrame=p->pFrame; pFrame->pParent; pFrame=pFrame->pParent); @@ -91558,7 +91931,7 @@ SQLITE_API int sqlite3_stmt_scanstatus( SQLITE_API void sqlite3_stmt_scanstatus_reset(sqlite3_stmt *pStmt){ Vdbe *p = (Vdbe*)pStmt; int ii; - for(ii=0; iinOp; ii++){ + for(ii=0; p!=0 && iinOp; ii++){ Op *pOp = &p->aOp[ii]; pOp->nExec = 0; pOp->nCycle = 0; @@ -92527,11 +92900,11 @@ static SQLITE_NOINLINE int vdbeColumnFromOverflow( sqlite3RCStrRef(pBuf); if( t&1 ){ rc = sqlite3VdbeMemSetStr(pDest, pBuf, len, encoding, - (void(*)(void*))sqlite3RCStrUnref); + sqlite3RCStrUnref); pDest->flags |= MEM_Term; }else{ rc = sqlite3VdbeMemSetStr(pDest, pBuf, len, 0, - (void(*)(void*))sqlite3RCStrUnref); + sqlite3RCStrUnref); } }else{ rc = sqlite3VdbeMemFromBtree(pC->uc.pCursor, iOffset, len, pDest); @@ -95406,7 +95779,6 @@ case OP_MakeRecord: { /* NULL value. No change in zPayload */ }else{ u64 v; - u32 i; if( serial_type==7 ){ assert( sizeof(v)==sizeof(pRec->u.r) ); memcpy(&v, &pRec->u.r, sizeof(v)); @@ -95414,12 +95786,17 @@ case OP_MakeRecord: { }else{ v = pRec->u.i; } - len = i = sqlite3SmallTypeSizes[serial_type]; - assert( i>0 ); - while( 1 /*exit-by-break*/ ){ - zPayload[--i] = (u8)(v&0xFF); - if( i==0 ) break; - v >>= 8; + len = sqlite3SmallTypeSizes[serial_type]; + assert( len>=1 && len<=8 && len!=5 && len!=7 ); + switch( len ){ + default: zPayload[7] = (u8)(v&0xff); v >>= 8; + zPayload[6] = (u8)(v&0xff); v >>= 8; + case 6: zPayload[5] = (u8)(v&0xff); v >>= 8; + zPayload[4] = (u8)(v&0xff); v >>= 8; + case 4: zPayload[3] = (u8)(v&0xff); v >>= 8; + case 3: zPayload[2] = (u8)(v&0xff); v >>= 8; + case 2: zPayload[1] = (u8)(v&0xff); v >>= 8; + case 1: zPayload[0] = (u8)(v&0xff); } zPayload += len; } @@ -97536,8 +97913,13 @@ case OP_RowCell: { ** the "primary" delete. The others are all on OPFLAG_FORDELETE ** cursors or else are marked with the AUXDELETE flag. ** -** If the OPFLAG_NCHANGE flag of P2 (NB: P2 not P5) is set, then the row -** change count is incremented (otherwise not). +** If the OPFLAG_NCHANGE (0x01) flag of P2 (NB: P2 not P5) is set, then +** the row change count is incremented (otherwise not). +** +** If the OPFLAG_ISNOOP (0x40) flag of P2 (not P5!) is set, then the +** pre-update-hook for deletes is run, but the btree is otherwise unchanged. +** This happens when the OP_Delete is to be shortly followed by an OP_Insert +** with the same key, causing the btree entry to be overwritten. ** ** P1 must not be pseudo-table. It has to be a real table with ** multiple rows. @@ -98662,13 +99044,41 @@ case OP_CreateBtree: { /* out2 */ /* Opcode: SqlExec * * * P4 * ** ** Run the SQL statement or statements specified in the P4 string. +** Disable Auth and Trace callbacks while those statements are running if +** P1 is true. */ case OP_SqlExec: { + char *zErr; +#ifndef SQLITE_OMIT_AUTHORIZATION + sqlite3_xauth xAuth; +#endif + u8 mTrace; + sqlite3VdbeIncrWriteCounter(p, 0); db->nSqlExec++; - rc = sqlite3_exec(db, pOp->p4.z, 0, 0, 0); + zErr = 0; +#ifndef SQLITE_OMIT_AUTHORIZATION + xAuth = db->xAuth; +#endif + mTrace = db->mTrace; + if( pOp->p1 ){ +#ifndef SQLITE_OMIT_AUTHORIZATION + db->xAuth = 0; +#endif + db->mTrace = 0; + } + rc = sqlite3_exec(db, pOp->p4.z, 0, 0, &zErr); db->nSqlExec--; - if( rc ) goto abort_due_to_error; +#ifndef SQLITE_OMIT_AUTHORIZATION + db->xAuth = xAuth; +#endif + db->mTrace = mTrace; + if( zErr || rc ){ + sqlite3VdbeError(p, "%s", zErr); + sqlite3_free(zErr); + if( rc==SQLITE_NOMEM ) goto no_mem; + goto abort_due_to_error; + } break; } @@ -99889,6 +100299,53 @@ case OP_VOpen: { /* ncycle */ } #endif /* SQLITE_OMIT_VIRTUALTABLE */ +#ifndef SQLITE_OMIT_VIRTUALTABLE +/* Opcode: VCheck P1 P2 P3 P4 * +** +** P4 is a pointer to a Table object that is a virtual table in schema P1 +** that supports the xIntegrity() method. This opcode runs the xIntegrity() +** method for that virtual table, using P3 as the integer argument. If +** an error is reported back, the table name is prepended to the error +** message and that message is stored in P2. If no errors are seen, +** register P2 is set to NULL. +*/ +case OP_VCheck: { /* out2 */ + Table *pTab; + sqlite3_vtab *pVtab; + const sqlite3_module *pModule; + char *zErr = 0; + + pOut = &aMem[pOp->p2]; + sqlite3VdbeMemSetNull(pOut); /* Innocent until proven guilty */ + assert( pOp->p4type==P4_TABLE ); + pTab = pOp->p4.pTab; + assert( pTab!=0 ); + assert( IsVirtual(pTab) ); + assert( pTab->u.vtab.p!=0 ); + pVtab = pTab->u.vtab.p->pVtab; + assert( pVtab!=0 ); + pModule = pVtab->pModule; + assert( pModule!=0 ); + assert( pModule->iVersion>=4 ); + assert( pModule->xIntegrity!=0 ); + pTab->nTabRef++; + sqlite3VtabLock(pTab->u.vtab.p); + assert( pOp->p1>=0 && pOp->p1nDb ); + rc = pModule->xIntegrity(pVtab, db->aDb[pOp->p1].zDbSName, pTab->zName, + pOp->p3, &zErr); + sqlite3VtabUnlock(pTab->u.vtab.p); + sqlite3DeleteTable(db, pTab); + if( rc ){ + sqlite3_free(zErr); + goto abort_due_to_error; + } + if( zErr ){ + sqlite3VdbeMemSetStr(pOut, zErr, -1, SQLITE_UTF8, sqlite3_free); + } + break; +} +#endif /* SQLITE_OMIT_VIRTUALTABLE */ + #ifndef SQLITE_OMIT_VIRTUALTABLE /* Opcode: VInitIn P1 P2 P3 * * ** Synopsis: r[P2]=ValueList(P1,P3) @@ -100918,7 +101375,7 @@ SQLITE_API int sqlite3_blob_open( #endif *ppBlob = 0; #ifdef SQLITE_ENABLE_API_ARMOR - if( !sqlite3SafetyCheckOk(db) || zTable==0 ){ + if( !sqlite3SafetyCheckOk(db) || zTable==0 || zColumn==0 ){ return SQLITE_MISUSE_BKPT; } #endif @@ -101480,7 +101937,7 @@ struct SorterFile { struct SorterList { SorterRecord *pList; /* Linked list of records */ u8 *aMemory; /* If non-NULL, bulk memory to hold pList */ - int szPMA; /* Size of pList as PMA in bytes */ + i64 szPMA; /* Size of pList as PMA in bytes */ }; /* @@ -101589,10 +102046,10 @@ typedef int (*SorterCompare)(SortSubtask*,int*,const void*,int,const void*,int); struct SortSubtask { SQLiteThread *pThread; /* Background thread, if any */ int bDone; /* Set if thread is finished but not joined */ + int nPMA; /* Number of PMAs currently in file */ VdbeSorter *pSorter; /* Sorter that owns this sub-task */ UnpackedRecord *pUnpacked; /* Space to unpack a record */ SorterList list; /* List for thread to write to a PMA */ - int nPMA; /* Number of PMAs currently in file */ SorterCompare xCompare; /* Compare function to use */ SorterFile file; /* Temp file for level-0 PMAs */ SorterFile file2; /* Space for other PMAs */ @@ -103066,8 +103523,8 @@ SQLITE_PRIVATE int sqlite3VdbeSorterWrite( int rc = SQLITE_OK; /* Return Code */ SorterRecord *pNew; /* New list element */ int bFlush; /* True to flush contents of memory to PMA */ - int nReq; /* Bytes of memory required */ - int nPMA; /* Bytes of PMA space required */ + i64 nReq; /* Bytes of memory required */ + i64 nPMA; /* Bytes of PMA space required */ int t; /* serial type of first record field */ assert( pCsr->eCurType==CURTYPE_SORTER ); @@ -104491,7 +104948,8 @@ static sqlite3_module bytecodevtabModule = { /* xSavepoint */ 0, /* xRelease */ 0, /* xRollbackTo */ 0, - /* xShadowName */ 0 + /* xShadowName */ 0, + /* xIntegrity */ 0 }; @@ -105320,21 +105778,36 @@ static void resolveAlias( } /* -** Subqueries stores the original database, table and column names for their -** result sets in ExprList.a[].zSpan, in the form "DATABASE.TABLE.COLUMN". -** Check to see if the zSpan given to this routine matches the zDb, zTab, -** and zCol. If any of zDb, zTab, and zCol are NULL then those fields will -** match anything. +** Subqueries store the original database, table and column names for their +** result sets in ExprList.a[].zSpan, in the form "DATABASE.TABLE.COLUMN", +** and mark the expression-list item by setting ExprList.a[].fg.eEName +** to ENAME_TAB. +** +** Check to see if the zSpan/eEName of the expression-list item passed to this +** routine matches the zDb, zTab, and zCol. If any of zDb, zTab, and zCol are +** NULL then those fields will match anything. Return true if there is a match, +** or false otherwise. +** +** SF_NestedFrom subqueries also store an entry for the implicit rowid (or +** _rowid_, or oid) column by setting ExprList.a[].fg.eEName to ENAME_ROWID, +** and setting zSpan to "DATABASE.TABLE.". This type of pItem +** argument matches if zCol is a rowid alias. If it is not NULL, (*pbRowid) +** is set to 1 if there is this kind of match. */ SQLITE_PRIVATE int sqlite3MatchEName( const struct ExprList_item *pItem, const char *zCol, const char *zTab, - const char *zDb + const char *zDb, + int *pbRowid ){ int n; const char *zSpan; - if( pItem->fg.eEName!=ENAME_TAB ) return 0; + int eEName = pItem->fg.eEName; + if( eEName!=ENAME_TAB && (eEName!=ENAME_ROWID || NEVER(pbRowid==0)) ){ + return 0; + } + assert( pbRowid==0 || *pbRowid==0 ); zSpan = pItem->zEName; for(n=0; ALWAYS(zSpan[n]) && zSpan[n]!='.'; n++){} if( zDb && (sqlite3StrNICmp(zSpan, zDb, n)!=0 || zDb[n]!=0) ){ @@ -105346,9 +105819,11 @@ SQLITE_PRIVATE int sqlite3MatchEName( return 0; } zSpan += n+1; - if( zCol && sqlite3StrICmp(zSpan, zCol)!=0 ){ - return 0; + if( zCol ){ + if( eEName==ENAME_TAB && sqlite3StrICmp(zSpan, zCol)!=0 ) return 0; + if( eEName==ENAME_ROWID && sqlite3IsRowid(zCol)==0 ) return 0; } + if( eEName==ENAME_ROWID ) *pbRowid = 1; return 1; } @@ -105481,7 +105956,7 @@ static int lookupName( ){ int i, j; /* Loop counters */ int cnt = 0; /* Number of matching column names */ - int cntTab = 0; /* Number of matching table names */ + int cntTab = 0; /* Number of potential "rowid" matches */ int nSubquery = 0; /* How many levels of subquery */ sqlite3 *db = pParse->db; /* The database connection */ SrcItem *pItem; /* Use for looping over pSrcList items */ @@ -105558,39 +106033,49 @@ static int lookupName( assert( pEList!=0 ); assert( pEList->nExpr==pTab->nCol ); for(j=0; jnExpr; j++){ - if( !sqlite3MatchEName(&pEList->a[j], zCol, zTab, zDb) ){ + int bRowid = 0; /* True if possible rowid match */ + if( !sqlite3MatchEName(&pEList->a[j], zCol, zTab, zDb, &bRowid) ){ continue; } - if( cnt>0 ){ - if( pItem->fg.isUsing==0 - || sqlite3IdListIndex(pItem->u3.pUsing, zCol)<0 - ){ - /* Two or more tables have the same column name which is - ** not joined by USING. This is an error. Signal as much - ** by clearing pFJMatch and letting cnt go above 1. */ - sqlite3ExprListDelete(db, pFJMatch); - pFJMatch = 0; - }else - if( (pItem->fg.jointype & JT_RIGHT)==0 ){ - /* An INNER or LEFT JOIN. Use the left-most table */ - continue; - }else - if( (pItem->fg.jointype & JT_LEFT)==0 ){ - /* A RIGHT JOIN. Use the right-most table */ - cnt = 0; - sqlite3ExprListDelete(db, pFJMatch); - pFJMatch = 0; - }else{ - /* For a FULL JOIN, we must construct a coalesce() func */ - extendFJMatch(pParse, &pFJMatch, pMatch, pExpr->iColumn); + if( bRowid==0 ){ + if( cnt>0 ){ + if( pItem->fg.isUsing==0 + || sqlite3IdListIndex(pItem->u3.pUsing, zCol)<0 + ){ + /* Two or more tables have the same column name which is + ** not joined by USING. This is an error. Signal as much + ** by clearing pFJMatch and letting cnt go above 1. */ + sqlite3ExprListDelete(db, pFJMatch); + pFJMatch = 0; + }else + if( (pItem->fg.jointype & JT_RIGHT)==0 ){ + /* An INNER or LEFT JOIN. Use the left-most table */ + continue; + }else + if( (pItem->fg.jointype & JT_LEFT)==0 ){ + /* A RIGHT JOIN. Use the right-most table */ + cnt = 0; + sqlite3ExprListDelete(db, pFJMatch); + pFJMatch = 0; + }else{ + /* For a FULL JOIN, we must construct a coalesce() func */ + extendFJMatch(pParse, &pFJMatch, pMatch, pExpr->iColumn); + } } + cnt++; + hit = 1; + }else if( cnt>0 ){ + /* This is a potential rowid match, but there has already been + ** a real match found. So this can be ignored. */ + continue; } - cnt++; - cntTab = 2; + cntTab++; pMatch = pItem; pExpr->iColumn = j; pEList->a[j].fg.bUsed = 1; - hit = 1; + + /* rowid cannot be part of a USING clause - assert() this. */ + assert( bRowid==0 || pEList->a[j].fg.bUsingTerm==0 ); if( pEList->a[j].fg.bUsingTerm ) break; } if( hit || zTab==0 ) continue; @@ -105785,10 +106270,10 @@ static int lookupName( && pMatch && (pNC->ncFlags & (NC_IdxExpr|NC_GenCol))==0 && sqlite3IsRowid(zCol) - && ALWAYS(VisibleRowid(pMatch->pTab)) + && ALWAYS(VisibleRowid(pMatch->pTab) || pMatch->fg.isNestedFrom) ){ cnt = 1; - pExpr->iColumn = -1; + if( pMatch->fg.isNestedFrom==0 ) pExpr->iColumn = -1; pExpr->affExpr = SQLITE_AFF_INTEGER; } @@ -106241,6 +106726,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ Window *pWin = (IsWindowFunc(pExpr) ? pExpr->y.pWin : 0); #endif assert( !ExprHasProperty(pExpr, EP_xIsSelect|EP_IntValue) ); + assert( pExpr->pLeft==0 || pExpr->pLeft->op==TK_ORDER ); zId = pExpr->u.zToken; pDef = sqlite3FindFunction(pParse->db, zId, n, enc, 0); if( pDef==0 ){ @@ -106382,6 +106868,10 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ pNC->nNcErr++; } #endif + else if( is_agg==0 && pExpr->pLeft ){ + sqlite3ExprOrderByAggregateError(pParse, pExpr); + pNC->nNcErr++; + } if( is_agg ){ /* Window functions may not be arguments of aggregate functions. ** Or arguments of other window functions. But aggregate functions @@ -106400,6 +106890,11 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ #endif sqlite3WalkExprList(pWalker, pList); if( is_agg ){ + if( pExpr->pLeft ){ + assert( pExpr->pLeft->op==TK_ORDER ); + assert( ExprUseXList(pExpr->pLeft) ); + sqlite3WalkExprList(pWalker, pExpr->pLeft->x.pList); + } #ifndef SQLITE_OMIT_WINDOWFUNC if( pWin ){ Select *pSel = pNC->pWinSelect; @@ -106963,10 +107458,8 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ while( p ){ assert( (p->selFlags & SF_Expanded)!=0 ); assert( (p->selFlags & SF_Resolved)==0 ); - assert( db->suppressErr==0 ); /* SF_Resolved not set if errors suppressed */ p->selFlags |= SF_Resolved; - /* Resolve the expressions in the LIMIT and OFFSET clauses. These ** are not allowed to refer to any names, so pass an empty NameContext. */ @@ -107972,6 +108465,7 @@ SQLITE_PRIVATE Expr *sqlite3ExprForVectorField( */ pRet = sqlite3PExpr(pParse, TK_SELECT_COLUMN, 0, 0); if( pRet ){ + ExprSetProperty(pRet, EP_FullSize); pRet->iTable = nField; pRet->iColumn = iField; pRet->pLeft = pVector; @@ -108562,6 +109056,69 @@ SQLITE_PRIVATE Expr *sqlite3ExprFunction( return pNew; } +/* +** Report an error when attempting to use an ORDER BY clause within +** the arguments of a non-aggregate function. +*/ +SQLITE_PRIVATE void sqlite3ExprOrderByAggregateError(Parse *pParse, Expr *p){ + sqlite3ErrorMsg(pParse, + "ORDER BY may not be used with non-aggregate %#T()", p + ); +} + +/* +** Attach an ORDER BY clause to a function call. +** +** functionname( arguments ORDER BY sortlist ) +** \_____________________/ \______/ +** pExpr pOrderBy +** +** The ORDER BY clause is inserted into a new Expr node of type TK_ORDER +** and added to the Expr.pLeft field of the parent TK_FUNCTION node. +*/ +SQLITE_PRIVATE void sqlite3ExprAddFunctionOrderBy( + Parse *pParse, /* Parsing context */ + Expr *pExpr, /* The function call to which ORDER BY is to be added */ + ExprList *pOrderBy /* The ORDER BY clause to add */ +){ + Expr *pOB; + sqlite3 *db = pParse->db; + if( NEVER(pOrderBy==0) ){ + assert( db->mallocFailed ); + return; + } + if( pExpr==0 ){ + assert( db->mallocFailed ); + sqlite3ExprListDelete(db, pOrderBy); + return; + } + assert( pExpr->op==TK_FUNCTION ); + assert( pExpr->pLeft==0 ); + assert( ExprUseXList(pExpr) ); + if( pExpr->x.pList==0 || NEVER(pExpr->x.pList->nExpr==0) ){ + /* Ignore ORDER BY on zero-argument aggregates */ + sqlite3ParserAddCleanup(pParse, + (void(*)(sqlite3*,void*))sqlite3ExprListDelete, + pOrderBy); + return; + } + if( IsWindowFunc(pExpr) ){ + sqlite3ExprOrderByAggregateError(pParse, pExpr); + sqlite3ExprListDelete(db, pOrderBy); + return; + } + + pOB = sqlite3ExprAlloc(db, TK_ORDER, 0, 0); + if( pOB==0 ){ + sqlite3ExprListDelete(db, pOrderBy); + return; + } + pOB->x.pList = pOrderBy; + assert( ExprUseXList(pOB) ); + pExpr->pLeft = pOB; + ExprSetProperty(pOB, EP_FullSize); +} + /* ** Check to see if a function is usable according to current access ** rules: @@ -108815,11 +109372,7 @@ static int dupedExprStructSize(const Expr *p, int flags){ assert( flags==EXPRDUP_REDUCE || flags==0 ); /* Only one flag value allowed */ assert( EXPR_FULLSIZE<=0xfff ); assert( (0xfff & (EP_Reduced|EP_TokenOnly))==0 ); - if( 0==flags || p->op==TK_SELECT_COLUMN -#ifndef SQLITE_OMIT_WINDOWFUNC - || ExprHasProperty(p, EP_WinFunc) -#endif - ){ + if( 0==flags || ExprHasProperty(p, EP_FullSize) ){ nSize = EXPR_FULLSIZE; }else{ assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) ); @@ -108850,56 +109403,93 @@ static int dupedExprNodeSize(const Expr *p, int flags){ /* ** Return the number of bytes required to create a duplicate of the -** expression passed as the first argument. The second argument is a -** mask containing EXPRDUP_XXX flags. +** expression passed as the first argument. ** ** The value returned includes space to create a copy of the Expr struct ** itself and the buffer referred to by Expr.u.zToken, if any. ** -** If the EXPRDUP_REDUCE flag is set, then the return value includes -** space to duplicate all Expr nodes in the tree formed by Expr.pLeft -** and Expr.pRight variables (but not for any structures pointed to or -** descended from the Expr.x.pList or Expr.x.pSelect variables). +** The return value includes space to duplicate all Expr nodes in the +** tree formed by Expr.pLeft and Expr.pRight, but not any other +** substructure such as Expr.x.pList, Expr.x.pSelect, and Expr.y.pWin. */ -static int dupedExprSize(const Expr *p, int flags){ - int nByte = 0; - if( p ){ - nByte = dupedExprNodeSize(p, flags); - if( flags&EXPRDUP_REDUCE ){ - nByte += dupedExprSize(p->pLeft, flags) + dupedExprSize(p->pRight, flags); - } - } +static int dupedExprSize(const Expr *p){ + int nByte; + assert( p!=0 ); + nByte = dupedExprNodeSize(p, EXPRDUP_REDUCE); + if( p->pLeft ) nByte += dupedExprSize(p->pLeft); + if( p->pRight ) nByte += dupedExprSize(p->pRight); + assert( nByte==ROUND8(nByte) ); return nByte; } /* -** This function is similar to sqlite3ExprDup(), except that if pzBuffer -** is not NULL then *pzBuffer is assumed to point to a buffer large enough -** to store the copy of expression p, the copies of p->u.zToken -** (if applicable), and the copies of the p->pLeft and p->pRight expressions, -** if any. Before returning, *pzBuffer is set to the first byte past the -** portion of the buffer copied into by this function. +** An EdupBuf is a memory allocation used to stored multiple Expr objects +** together with their Expr.zToken content. This is used to help implement +** compression while doing sqlite3ExprDup(). The top-level Expr does the +** allocation for itself and many of its decendents, then passes an instance +** of the structure down into exprDup() so that they decendents can have +** access to that memory. */ -static Expr *exprDup(sqlite3 *db, const Expr *p, int dupFlags, u8 **pzBuffer){ +typedef struct EdupBuf EdupBuf; +struct EdupBuf { + u8 *zAlloc; /* Memory space available for storage */ +#ifdef SQLITE_DEBUG + u8 *zEnd; /* First byte past the end of memory */ +#endif +}; + +/* +** This function is similar to sqlite3ExprDup(), except that if pEdupBuf +** is not NULL then it points to memory that can be used to store a copy +** of the input Expr p together with its p->u.zToken (if any). pEdupBuf +** is updated with the new buffer tail prior to returning. +*/ +static Expr *exprDup( + sqlite3 *db, /* Database connection (for memory allocation) */ + const Expr *p, /* Expr tree to be duplicated */ + int dupFlags, /* EXPRDUP_REDUCE for compression. 0 if not */ + EdupBuf *pEdupBuf /* Preallocated storage space, or NULL */ +){ Expr *pNew; /* Value to return */ - u8 *zAlloc; /* Memory space from which to build Expr object */ + EdupBuf sEdupBuf; /* Memory space from which to build Expr object */ u32 staticFlag; /* EP_Static if space not obtained from malloc */ + int nToken = -1; /* Space needed for p->u.zToken. -1 means unknown */ assert( db!=0 ); assert( p ); assert( dupFlags==0 || dupFlags==EXPRDUP_REDUCE ); - assert( pzBuffer==0 || dupFlags==EXPRDUP_REDUCE ); + assert( pEdupBuf==0 || dupFlags==EXPRDUP_REDUCE ); /* Figure out where to write the new Expr structure. */ - if( pzBuffer ){ - zAlloc = *pzBuffer; + if( pEdupBuf ){ + sEdupBuf.zAlloc = pEdupBuf->zAlloc; +#ifdef SQLITE_DEBUG + sEdupBuf.zEnd = pEdupBuf->zEnd; +#endif staticFlag = EP_Static; - assert( zAlloc!=0 ); + assert( sEdupBuf.zAlloc!=0 ); + assert( dupFlags==EXPRDUP_REDUCE ); }else{ - zAlloc = sqlite3DbMallocRawNN(db, dupedExprSize(p, dupFlags)); + int nAlloc; + if( dupFlags ){ + nAlloc = dupedExprSize(p); + }else if( !ExprHasProperty(p, EP_IntValue) && p->u.zToken ){ + nToken = sqlite3Strlen30NN(p->u.zToken)+1; + nAlloc = ROUND8(EXPR_FULLSIZE + nToken); + }else{ + nToken = 0; + nAlloc = ROUND8(EXPR_FULLSIZE); + } + assert( nAlloc==ROUND8(nAlloc) ); + sEdupBuf.zAlloc = sqlite3DbMallocRawNN(db, nAlloc); +#ifdef SQLITE_DEBUG + sEdupBuf.zEnd = sEdupBuf.zAlloc ? sEdupBuf.zAlloc+nAlloc : 0; +#endif + staticFlag = 0; } - pNew = (Expr *)zAlloc; + pNew = (Expr *)sEdupBuf.zAlloc; + assert( EIGHT_BYTE_ALIGNMENT(pNew) ); if( pNew ){ /* Set nNewSize to the size allocated for the structure pointed to @@ -108908,22 +109498,27 @@ static Expr *exprDup(sqlite3 *db, const Expr *p, int dupFlags, u8 **pzBuffer){ ** by the copy of the p->u.zToken string (if any). */ const unsigned nStructSize = dupedExprStructSize(p, dupFlags); - const int nNewSize = nStructSize & 0xfff; - int nToken; - if( !ExprHasProperty(p, EP_IntValue) && p->u.zToken ){ - nToken = sqlite3Strlen30(p->u.zToken) + 1; - }else{ - nToken = 0; + int nNewSize = nStructSize & 0xfff; + if( nToken<0 ){ + if( !ExprHasProperty(p, EP_IntValue) && p->u.zToken ){ + nToken = sqlite3Strlen30(p->u.zToken) + 1; + }else{ + nToken = 0; + } } if( dupFlags ){ + assert( (int)(sEdupBuf.zEnd - sEdupBuf.zAlloc) >= nNewSize+nToken ); assert( ExprHasProperty(p, EP_Reduced)==0 ); - memcpy(zAlloc, p, nNewSize); + memcpy(sEdupBuf.zAlloc, p, nNewSize); }else{ u32 nSize = (u32)exprStructSize(p); - memcpy(zAlloc, p, nSize); + assert( (int)(sEdupBuf.zEnd - sEdupBuf.zAlloc) >= + (int)EXPR_FULLSIZE+nToken ); + memcpy(sEdupBuf.zAlloc, p, nSize); if( nSizeu.zToken string, if any. */ - if( nToken ){ - char *zToken = pNew->u.zToken = (char*)&zAlloc[nNewSize]; + assert( nToken>=0 ); + if( nToken>0 ){ + char *zToken = pNew->u.zToken = (char*)&sEdupBuf.zAlloc[nNewSize]; memcpy(zToken, p->u.zToken, nToken); + nNewSize += nToken; } + sEdupBuf.zAlloc += ROUND8(nNewSize); + + if( ((p->flags|pNew->flags)&(EP_TokenOnly|EP_Leaf))==0 ){ - if( 0==((p->flags|pNew->flags) & (EP_TokenOnly|EP_Leaf)) ){ /* Fill in the pNew->x.pSelect or pNew->x.pList member. */ if( ExprUseXSelect(p) ){ pNew->x.pSelect = sqlite3SelectDup(db, p->x.pSelect, dupFlags); }else{ - pNew->x.pList = sqlite3ExprListDup(db, p->x.pList, dupFlags); + pNew->x.pList = sqlite3ExprListDup(db, p->x.pList, + p->op!=TK_ORDER ? dupFlags : 0); } - } - /* Fill in pNew->pLeft and pNew->pRight. */ - if( ExprHasProperty(pNew, EP_Reduced|EP_TokenOnly|EP_WinFunc) ){ - zAlloc += dupedExprNodeSize(p, dupFlags); - if( !ExprHasProperty(pNew, EP_TokenOnly|EP_Leaf) ){ - pNew->pLeft = p->pLeft ? - exprDup(db, p->pLeft, EXPRDUP_REDUCE, &zAlloc) : 0; - pNew->pRight = p->pRight ? - exprDup(db, p->pRight, EXPRDUP_REDUCE, &zAlloc) : 0; - } #ifndef SQLITE_OMIT_WINDOWFUNC if( ExprHasProperty(p, EP_WinFunc) ){ pNew->y.pWin = sqlite3WindowDup(db, pNew, p->y.pWin); assert( ExprHasProperty(pNew, EP_WinFunc) ); } #endif /* SQLITE_OMIT_WINDOWFUNC */ - if( pzBuffer ){ - *pzBuffer = zAlloc; - } - }else{ - if( !ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){ - if( pNew->op==TK_SELECT_COLUMN ){ + + /* Fill in pNew->pLeft and pNew->pRight. */ + if( dupFlags ){ + if( p->op==TK_SELECT_COLUMN ){ pNew->pLeft = p->pLeft; - assert( p->pRight==0 || p->pRight==p->pLeft - || ExprHasProperty(p->pLeft, EP_Subquery) ); + assert( p->pRight==0 + || p->pRight==p->pLeft + || ExprHasProperty(p->pLeft, EP_Subquery) ); + }else{ + pNew->pLeft = p->pLeft ? + exprDup(db, p->pLeft, EXPRDUP_REDUCE, &sEdupBuf) : 0; + } + pNew->pRight = p->pRight ? + exprDup(db, p->pRight, EXPRDUP_REDUCE, &sEdupBuf) : 0; + }else{ + if( p->op==TK_SELECT_COLUMN ){ + pNew->pLeft = p->pLeft; + assert( p->pRight==0 + || p->pRight==p->pLeft + || ExprHasProperty(p->pLeft, EP_Subquery) ); }else{ pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0); } @@ -108981,6 +109582,8 @@ static Expr *exprDup(sqlite3 *db, const Expr *p, int dupFlags, u8 **pzBuffer){ } } } + if( pEdupBuf ) memcpy(pEdupBuf, &sEdupBuf, sizeof(sEdupBuf)); + assert( sEdupBuf.zAlloc <= sEdupBuf.zEnd ); return pNew; } @@ -109245,11 +109848,7 @@ SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, const Select *p, int flags) ** initially NULL, then create a new expression list. ** ** The pList argument must be either NULL or a pointer to an ExprList -** obtained from a prior call to sqlite3ExprListAppend(). This routine -** may not be used with an ExprList obtained from sqlite3ExprListDup(). -** Reason: This routine assumes that the number of slots in pList->a[] -** is a power of two. That is true for sqlite3ExprListAppend() returns -** but is not necessarily true from the return value of sqlite3ExprListDup(). +** obtained from a prior call to sqlite3ExprListAppend(). ** ** If a memory allocation error occurs, the entire list is freed and ** NULL is returned. If non-NULL is returned, then it is guaranteed @@ -110075,6 +110674,27 @@ SQLITE_PRIVATE int sqlite3IsRowid(const char *z){ return 0; } +/* +** Return a pointer to a buffer containing a usable rowid alias for table +** pTab. An alias is usable if there is not an explicit user-defined column +** of the same name. +*/ +SQLITE_PRIVATE const char *sqlite3RowidAlias(Table *pTab){ + const char *azOpt[] = {"_ROWID_", "ROWID", "OID"}; + int ii; + assert( VisibleRowid(pTab) ); + for(ii=0; iinCol; iCol++){ + if( sqlite3_stricmp(azOpt[ii], pTab->aCol[iCol].zCnName)==0 ) break; + } + if( iCol==pTab->nCol ){ + return azOpt[ii]; + } + } + return 0; +} + /* ** pX is the RHS of an IN operator. If pX is a SELECT statement ** that can be simplified to a direct table access, then return @@ -111612,6 +112232,41 @@ static SQLITE_NOINLINE int sqlite3IndexedExprLookup( } +/* +** Expresion pExpr is guaranteed to be a TK_COLUMN or equivalent. This +** function checks the Parse.pIdxPartExpr list to see if this column +** can be replaced with a constant value. If so, it generates code to +** put the constant value in a register (ideally, but not necessarily, +** register iTarget) and returns the register number. +** +** Or, if the TK_COLUMN cannot be replaced by a constant, zero is +** returned. +*/ +static int exprPartidxExprLookup(Parse *pParse, Expr *pExpr, int iTarget){ + IndexedExpr *p; + for(p=pParse->pIdxPartExpr; p; p=p->pIENext){ + if( pExpr->iColumn==p->iIdxCol && pExpr->iTable==p->iDataCur ){ + Vdbe *v = pParse->pVdbe; + int addr = 0; + int ret; + + if( p->bMaybeNullRow ){ + addr = sqlite3VdbeAddOp1(v, OP_IfNullRow, p->iIdxCur); + } + ret = sqlite3ExprCodeTarget(pParse, p->pExpr, iTarget); + sqlite3VdbeAddOp4(pParse->pVdbe, OP_Affinity, ret, 1, 0, + (const char*)&p->aff, 1); + if( addr ){ + sqlite3VdbeJumpHere(v, addr); + sqlite3VdbeChangeP3(v, addr, ret); + } + return ret; + } + } + return 0; +} + + /* ** Generate code into the current Vdbe to evaluate the given ** expression. Attempt to store the results in register "target". @@ -111648,6 +112303,7 @@ expr_code_doover: assert( !ExprHasVVAProperty(pExpr,EP_Immutable) ); op = pExpr->op; } + assert( op!=TK_ORDER ); switch( op ){ case TK_AGG_COLUMN: { AggInfo *pAggInfo = pExpr->pAggInfo; @@ -111661,7 +112317,7 @@ expr_code_doover: #ifdef SQLITE_VDBE_COVERAGE /* Verify that the OP_Null above is exercised by tests ** tag-20230325-2 */ - sqlite3VdbeAddOp2(v, OP_NotNull, target, 1); + sqlite3VdbeAddOp3(v, OP_NotNull, target, 1, 20230325); VdbeCoverageNeverTaken(v); #endif break; @@ -111769,6 +112425,11 @@ expr_code_doover: iTab = pParse->iSelfTab - 1; } } + else if( pParse->pIdxPartExpr + && 0!=(r1 = exprPartidxExprLookup(pParse, pExpr, target)) + ){ + return r1; + } assert( ExprUseYTab(pExpr) ); assert( pExpr->y.pTab!=0 ); iReg = sqlite3ExprCodeGetColumn(pParse, pExpr->y.pTab, @@ -112429,7 +113090,7 @@ expr_code_doover: ** once. If no functions are involved, then factor the code out and put it at ** the end of the prepared statement in the initialization section. ** -** If regDest>=0 then the result is always stored in that register and the +** If regDest>0 then the result is always stored in that register and the ** result is not reusable. If regDest<0 then this routine is free to ** store the value wherever it wants. The register where the expression ** is stored is returned. When regDest<0, two identical expressions might @@ -112444,6 +113105,7 @@ SQLITE_PRIVATE int sqlite3ExprCodeRunJustOnce( ){ ExprList *p; assert( ConstFactorOk(pParse) ); + assert( regDest!=0 ); p = pParse->pConstExpr; if( regDest<0 && p ){ struct ExprList_item *pItem; @@ -113728,6 +114390,12 @@ SQLITE_PRIVATE int sqlite3ReferencesSrcList(Parse *pParse, Expr *pExpr, SrcList assert( pExpr->op==TK_AGG_FUNCTION ); assert( ExprUseXList(pExpr) ); sqlite3WalkExprList(&w, pExpr->x.pList); + if( pExpr->pLeft ){ + assert( pExpr->pLeft->op==TK_ORDER ); + assert( ExprUseXList(pExpr->pLeft) ); + assert( pExpr->pLeft->x.pList!=0 ); + sqlite3WalkExprList(&w, pExpr->pLeft->x.pList); + } #ifndef SQLITE_OMIT_WINDOWFUNC if( ExprHasProperty(pExpr, EP_WinFunc) ){ sqlite3WalkExpr(&w, pExpr->y.pWin->pFilter); @@ -113992,14 +114660,42 @@ static int analyzeAggregate(Walker *pWalker, Expr *pExpr){ u8 enc = ENC(pParse->db); i = addAggInfoFunc(pParse->db, pAggInfo); if( i>=0 ){ + int nArg; assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); pItem = &pAggInfo->aFunc[i]; pItem->pFExpr = pExpr; assert( ExprUseUToken(pExpr) ); + nArg = pExpr->x.pList ? pExpr->x.pList->nExpr : 0; pItem->pFunc = sqlite3FindFunction(pParse->db, - pExpr->u.zToken, - pExpr->x.pList ? pExpr->x.pList->nExpr : 0, enc, 0); - if( pExpr->flags & EP_Distinct ){ + pExpr->u.zToken, nArg, enc, 0); + assert( pItem->bOBUnique==0 ); + if( pExpr->pLeft + && (pItem->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL)==0 + ){ + /* The NEEDCOLL test above causes any ORDER BY clause on + ** aggregate min() or max() to be ignored. */ + ExprList *pOBList; + assert( nArg>0 ); + assert( pExpr->pLeft->op==TK_ORDER ); + assert( ExprUseXList(pExpr->pLeft) ); + pItem->iOBTab = pParse->nTab++; + pOBList = pExpr->pLeft->x.pList; + assert( pOBList->nExpr>0 ); + assert( pItem->bOBUnique==0 ); + if( pOBList->nExpr==1 + && nArg==1 + && sqlite3ExprCompare(0,pOBList->a[0].pExpr, + pExpr->x.pList->a[0].pExpr,0)==0 + ){ + pItem->bOBPayload = 0; + pItem->bOBUnique = ExprHasProperty(pExpr, EP_Distinct); + }else{ + pItem->bOBPayload = 1; + } + }else{ + pItem->iOBTab = -1; + } + if( ExprHasProperty(pExpr, EP_Distinct) && !pItem->bOBUnique ){ pItem->iDistinct = pParse->nTab++; }else{ pItem->iDistinct = -1; @@ -114635,14 +115331,19 @@ SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){ /* Verify that constraints are still satisfied */ if( pNew->pCheck!=0 || (pCol->notNull && (pCol->colFlags & COLFLAG_GENERATED)!=0) + || (pTab->tabFlags & TF_Strict)!=0 ){ sqlite3NestedParse(pParse, "SELECT CASE WHEN quick_check GLOB 'CHECK*'" " THEN raise(ABORT,'CHECK constraint failed')" + " WHEN quick_check GLOB 'non-* value in*'" + " THEN raise(ABORT,'type mismatch on DEFAULT')" " ELSE raise(ABORT,'NOT NULL constraint failed')" " END" " FROM pragma_quick_check(%Q,%Q)" - " WHERE quick_check GLOB 'CHECK*' OR quick_check GLOB 'NULL*'", + " WHERE quick_check GLOB 'CHECK*'" + " OR quick_check GLOB 'NULL*'" + " OR quick_check GLOB 'non-* value in*'", zTab, zDb ); } @@ -119621,19 +120322,14 @@ SQLITE_PRIVATE void sqlite3FinishCoding(Parse *pParse){ */ if( pParse->pAinc ) sqlite3AutoincrementBegin(pParse); - /* Code constant expressions that where factored out of inner loops. - ** - ** The pConstExpr list might also contain expressions that we simply - ** want to keep around until the Parse object is deleted. Such - ** expressions have iConstExprReg==0. Do not generate code for - ** those expressions, of course. + /* Code constant expressions that were factored out of inner loops. */ if( pParse->pConstExpr ){ ExprList *pEL = pParse->pConstExpr; pParse->okConstFactor = 0; for(i=0; inExpr; i++){ - int iReg = pEL->a[i].u.iConstExprReg; - sqlite3ExprCode(pParse, pEL->a[i].pExpr, iReg); + assert( pEL->a[i].u.iConstExprReg>0 ); + sqlite3ExprCode(pParse, pEL->a[i].pExpr, pEL->a[i].u.iConstExprReg); } } @@ -120787,20 +121483,13 @@ SQLITE_PRIVATE void sqlite3ColumnPropertiesFromName(Table *pTab, Column *pCol){ } #endif -/* -** Name of the special TEMP trigger used to implement RETURNING. The -** name begins with "sqlite_" so that it is guaranteed not to collide -** with any application-generated triggers. -*/ -#define RETURNING_TRIGGER_NAME "sqlite_returning" - /* ** Clean up the data structures associated with the RETURNING clause. */ static void sqlite3DeleteReturning(sqlite3 *db, Returning *pRet){ Hash *pHash; pHash = &(db->aDb[1].pSchema->trigHash); - sqlite3HashInsert(pHash, RETURNING_TRIGGER_NAME, 0); + sqlite3HashInsert(pHash, pRet->zName, 0); sqlite3ExprListDelete(db, pRet->pReturnEL); sqlite3DbFree(db, pRet); } @@ -120843,7 +121532,9 @@ SQLITE_PRIVATE void sqlite3AddReturning(Parse *pParse, ExprList *pList){ (void(*)(sqlite3*,void*))sqlite3DeleteReturning, pRet); testcase( pParse->earlyCleanup ); if( db->mallocFailed ) return; - pRet->retTrig.zName = RETURNING_TRIGGER_NAME; + sqlite3_snprintf(sizeof(pRet->zName), pRet->zName, + "sqlite_returning_%p", pParse); + pRet->retTrig.zName = pRet->zName; pRet->retTrig.op = TK_RETURNING; pRet->retTrig.tr_tm = TRIGGER_AFTER; pRet->retTrig.bReturning = 1; @@ -120854,9 +121545,9 @@ SQLITE_PRIVATE void sqlite3AddReturning(Parse *pParse, ExprList *pList){ pRet->retTStep.pTrig = &pRet->retTrig; pRet->retTStep.pExprList = pList; pHash = &(db->aDb[1].pSchema->trigHash); - assert( sqlite3HashFind(pHash, RETURNING_TRIGGER_NAME)==0 + assert( sqlite3HashFind(pHash, pRet->zName)==0 || pParse->nErr || pParse->ifNotExists ); - if( sqlite3HashInsert(pHash, RETURNING_TRIGGER_NAME, &pRet->retTrig) + if( sqlite3HashInsert(pHash, pRet->zName, &pRet->retTrig) ==&pRet->retTrig ){ sqlite3OomFault(db); } @@ -122300,6 +122991,17 @@ SQLITE_PRIVATE void sqlite3EndTable( /* Reparse everything to update our internal data structures */ sqlite3VdbeAddParseSchemaOp(v, iDb, sqlite3MPrintf(db, "tbl_name='%q' AND type!='trigger'", p->zName),0); + + /* Test for cycles in generated columns and illegal expressions + ** in CHECK constraints and in DEFAULT clauses. */ + if( p->tabFlags & TF_HasGenerated ){ + sqlite3VdbeAddOp4(v, OP_SqlExec, 1, 0, 0, + sqlite3MPrintf(db, "SELECT*FROM\"%w\".\"%w\"", + db->aDb[iDb].zDbSName, p->zName), P4_DYNAMIC); + } + sqlite3VdbeAddOp4(v, OP_SqlExec, 1, 0, 0, + sqlite3MPrintf(db, "PRAGMA \"%w\".integrity_check(%Q)", + db->aDb[iDb].zDbSName, p->zName), P4_DYNAMIC); } /* Add the table to the in-memory representation of the database. @@ -127902,7 +128604,8 @@ static void hexFunc( *(z++) = hexdigits[c&0xf]; } *z = 0; - sqlite3_result_text(context, zHex, n*2, sqlite3_free); + sqlite3_result_text64(context, zHex, (u64)(z-zHex), + sqlite3_free, SQLITE_UTF8); } } @@ -128196,6 +128899,81 @@ static void trimFunc( sqlite3_result_text(context, (char*)zIn, nIn, SQLITE_TRANSIENT); } +/* The core implementation of the CONCAT(...) and CONCAT_WS(SEP,...) +** functions. +** +** Return a string value that is the concatenation of all non-null +** entries in argv[]. Use zSep as the separator. +*/ +static void concatFuncCore( + sqlite3_context *context, + int argc, + sqlite3_value **argv, + int nSep, + const char *zSep +){ + i64 j, k, n = 0; + int i; + char *z; + for(i=0; i0 ){ + const char *v = (const char*)sqlite3_value_text(argv[i]); + if( v!=0 ){ + if( j>0 && nSep>0 ){ + memcpy(&z[j], zSep, nSep); + j += nSep; + } + memcpy(&z[j], v, k); + j += k; + } + } + } + z[j] = 0; + assert( j<=n ); + sqlite3_result_text64(context, z, j, sqlite3_free, SQLITE_UTF8); +} + +/* +** The CONCAT(...) function. Generate a string result that is the +** concatentation of all non-null arguments. +*/ +static void concatFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + concatFuncCore(context, argc, argv, 0, ""); +} + +/* +** The CONCAT_WS(separator, ...) function. +** +** Generate a string that is the concatenation of 2nd through the Nth +** argument. Use the first argument (which must be non-NULL) as the +** separator. +*/ +static void concatwsFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + int nSep = sqlite3_value_bytes(argv[0]); + const char *zSep = (const char*)sqlite3_value_text(argv[0]); + if( zSep==0 ) return; + concatFuncCore(context, argc-1, argv+1, nSep, zSep); +} + #ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION /* @@ -128617,6 +129395,7 @@ static void minMaxFinalize(sqlite3_context *context){ /* ** group_concat(EXPR, ?SEPARATOR?) +** string_agg(EXPR, SEPARATOR) ** ** The SEPARATOR goes before the EXPR string. This is tragic. The ** groupConcatInverse() implementation would have been easier if the @@ -129207,6 +129986,11 @@ SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void){ FUNCTION(hex, 1, 0, 0, hexFunc ), FUNCTION(unhex, 1, 0, 0, unhexFunc ), FUNCTION(unhex, 2, 0, 0, unhexFunc ), + FUNCTION(concat, -1, 0, 0, concatFunc ), + FUNCTION(concat, 0, 0, 0, 0 ), + FUNCTION(concat_ws, -1, 0, 0, concatwsFunc ), + FUNCTION(concat_ws, 0, 0, 0, 0 ), + FUNCTION(concat_ws, 1, 0, 0, 0 ), INLINE_FUNC(ifnull, 2, INLINEFUNC_coalesce, 0 ), VFUNCTION(random, 0, 0, 0, randomFunc ), VFUNCTION(randomblob, 1, 0, 0, randomBlob ), @@ -129236,6 +130020,8 @@ SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void){ groupConcatFinalize, groupConcatValue, groupConcatInverse, 0), WAGGREGATE(group_concat, 2, 0, 0, groupConcatStep, groupConcatFinalize, groupConcatValue, groupConcatInverse, 0), + WAGGREGATE(string_agg, 2, 0, 0, groupConcatStep, + groupConcatFinalize, groupConcatValue, groupConcatInverse, 0), LIKEFUNC(glob, 2, &globInfo, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE), #ifdef SQLITE_CASE_SENSITIVE_LIKE @@ -130178,6 +130964,7 @@ static int isSetNullAction(Parse *pParse, FKey *pFKey){ if( (p==pFKey->apTrigger[0] && pFKey->aAction[0]==OE_SetNull) || (p==pFKey->apTrigger[1] && pFKey->aAction[1]==OE_SetNull) ){ + assert( (pTop->db->flags & SQLITE_FkNoAction)==0 ); return 1; } } @@ -130372,6 +131159,8 @@ SQLITE_PRIVATE void sqlite3FkCheck( } if( regOld!=0 ){ int eAction = pFKey->aAction[aChange!=0]; + if( (db->flags & SQLITE_FkNoAction) ) eAction = OE_None; + fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regOld, 1); /* If this is a deferred FK constraint, or a CASCADE or SET NULL ** action applies, then any foreign key violations caused by @@ -130487,7 +131276,11 @@ SQLITE_PRIVATE int sqlite3FkRequired( /* Check if any parent key columns are being modified. */ for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){ if( fkParentIsModified(pTab, p, aChange, chngRowid) ){ - if( p->aAction[1]!=OE_None ) return 2; + if( (pParse->db->flags & SQLITE_FkNoAction)==0 + && p->aAction[1]!=OE_None + ){ + return 2; + } bHaveFK = 1; } } @@ -130537,6 +131330,7 @@ static Trigger *fkActionTrigger( int iAction = (pChanges!=0); /* 1 for UPDATE, 0 for DELETE */ action = pFKey->aAction[iAction]; + if( (db->flags & SQLITE_FkNoAction) ) action = OE_None; if( action==OE_Restrict && (db->flags & SQLITE_DeferFKs) ){ return 0; } @@ -134492,6 +135286,9 @@ struct sqlite3_api_routines { int (*is_interrupted)(sqlite3*); /* Version 3.43.0 and later */ int (*stmt_explain)(sqlite3_stmt*,int); + /* Version 3.44.0 and later */ + void *(*get_clientdata)(sqlite3*,const char*); + int (*set_clientdata)(sqlite3*, const char*, void*, void(*)(void*)); }; /* @@ -134822,6 +135619,9 @@ typedef int (*sqlite3_loadext_entry)( #define sqlite3_is_interrupted sqlite3_api->is_interrupted /* Version 3.43.0 and later */ #define sqlite3_stmt_explain sqlite3_api->stmt_explain +/* Version 3.44.0 and later */ +#define sqlite3_get_clientdata sqlite3_api->get_clientdata +#define sqlite3_set_clientdata sqlite3_api->set_clientdata #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) @@ -135340,7 +136140,10 @@ static const sqlite3_api_routines sqlite3Apis = { /* Version 3.41.0 and later */ sqlite3_is_interrupted, /* Version 3.43.0 and later */ - sqlite3_stmt_explain + sqlite3_stmt_explain, + /* Version 3.44.0 and later */ + sqlite3_get_clientdata, + sqlite3_set_clientdata }; /* True if x is the directory separator character @@ -135556,6 +136359,9 @@ SQLITE_PRIVATE void sqlite3CloseExtensions(sqlite3 *db){ ** default so as not to open security holes in older applications. */ SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff){ +#ifdef SQLITE_ENABLE_API_ARMOR + if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT; +#endif sqlite3_mutex_enter(db->mutex); if( onoff ){ db->flags |= SQLITE_LoadExtension|SQLITE_LoadExtFunc; @@ -135605,6 +136411,9 @@ SQLITE_API int sqlite3_auto_extension( void (*xInit)(void) ){ int rc = SQLITE_OK; +#ifdef SQLITE_ENABLE_API_ARMOR + if( xInit==0 ) return SQLITE_MISUSE_BKPT; +#endif #ifndef SQLITE_OMIT_AUTOINIT rc = sqlite3_initialize(); if( rc ){ @@ -135657,6 +136466,9 @@ SQLITE_API int sqlite3_cancel_auto_extension( int i; int n = 0; wsdAutoextInit; +#ifdef SQLITE_ENABLE_API_ARMOR + if( xInit==0 ) return 0; +#endif sqlite3_mutex_enter(mutex); for(i=(int)wsdAutoext.nExt-1; i>=0; i--){ if( wsdAutoext.aExt[i]==xInit ){ @@ -137526,7 +138338,11 @@ SQLITE_PRIVATE void sqlite3Pragma( #endif if( sqlite3GetBoolean(zRight, 0) ){ - db->flags |= mask; + if( (mask & SQLITE_WriteSchema)==0 + || (db->flags & SQLITE_Defensive)==0 + ){ + db->flags |= mask; + } }else{ db->flags &= ~mask; if( mask==SQLITE_DeferFKs ) db->nDeferredImmCons = 0; @@ -138159,8 +138975,31 @@ SQLITE_PRIVATE void sqlite3Pragma( int r2; /* Previous key for WITHOUT ROWID tables */ int mxCol; /* Maximum non-virtual column number */ - if( !IsOrdinaryTable(pTab) ) continue; if( pObjTab && pObjTab!=pTab ) continue; + if( !IsOrdinaryTable(pTab) ){ +#ifndef SQLITE_OMIT_VIRTUALTABLE + sqlite3_vtab *pVTab; + int a1; + if( !IsVirtual(pTab) ) continue; + if( pTab->nCol<=0 ){ + const char *zMod = pTab->u.vtab.azArg[0]; + if( sqlite3HashFind(&db->aModule, zMod)==0 ) continue; + } + sqlite3ViewGetColumnNames(pParse, pTab); + if( pTab->u.vtab.p==0 ) continue; + pVTab = pTab->u.vtab.p->pVtab; + if( NEVER(pVTab==0) ) continue; + if( NEVER(pVTab->pModule==0) ) continue; + if( pVTab->pModule->iVersion<4 ) continue; + if( pVTab->pModule->xIntegrity==0 ) continue; + sqlite3VdbeAddOp3(v, OP_VCheck, i, 3, isQuick); + sqlite3VdbeAppendP4(v, pTab, P4_TABLE); + a1 = sqlite3VdbeAddOp1(v, OP_IsNull, 3); VdbeCoverage(v); + integrityCheckResultRow(v); + sqlite3VdbeJumpHere(v, a1); +#endif + continue; + } if( isQuick || HasRowid(pTab) ){ pPk = 0; r2 = 0; @@ -139286,7 +140125,8 @@ static const sqlite3_module pragmaVtabModule = { 0, /* xSavepoint */ 0, /* xRelease */ 0, /* xRollbackTo */ - 0 /* xShadowName */ + 0, /* xShadowName */ + 0 /* xIntegrity */ }; /* @@ -139910,8 +140750,6 @@ SQLITE_PRIVATE void sqlite3ParseObjectReset(Parse *pParse){ db->lookaside.sz = db->lookaside.bDisable ? 0 : db->lookaside.szTrue; assert( pParse->db->pParse==pParse ); db->pParse = pParse->pOuterParse; - pParse->db = 0; - pParse->disableLookaside = 0; } /* @@ -140849,6 +141687,7 @@ static void unsetJoinExpr(Expr *p, int iTable, int nullable){ } if( p->op==TK_FUNCTION ){ assert( ExprUseXList(p) ); + assert( p->pLeft==0 ); if( p->x.pList ){ int i; for(i=0; ix.pList->nExpr; i++){ @@ -146509,6 +147348,7 @@ static int selectExpander(Walker *pWalker, Select *p){ char *zTName = 0; /* text of name of TABLE */ int iErrOfst; if( pE->op==TK_DOT ){ + assert( (selFlags & SF_NestedFrom)==0 ); assert( pE->pLeft!=0 ); assert( !ExprHasProperty(pE->pLeft, EP_IntValue) ); zTName = pE->pLeft->u.zToken; @@ -146519,6 +147359,7 @@ static int selectExpander(Walker *pWalker, Select *p){ iErrOfst = pE->w.iOfst; } for(i=0, pFrom=pTabList->a; inSrc; i++, pFrom++){ + int nAdd; /* Number of cols including rowid */ Table *pTab = pFrom->pTab; /* Table for this data source */ ExprList *pNestedFrom; /* Result-set of a nested FROM clause */ char *zTabName; /* AS name for this data source */ @@ -146536,6 +147377,7 @@ static int selectExpander(Walker *pWalker, Select *p){ pNestedFrom = pFrom->pSelect->pEList; assert( pNestedFrom!=0 ); assert( pNestedFrom->nExpr==pTab->nCol ); + assert( VisibleRowid(pTab)==0 ); }else{ if( zTName && sqlite3StrICmp(zTName, zTabName)!=0 ){ continue; @@ -146566,33 +147408,48 @@ static int selectExpander(Walker *pWalker, Select *p){ }else{ pUsing = 0; } - for(j=0; jnCol; j++){ - char *zName = pTab->aCol[j].zCnName; + + nAdd = pTab->nCol + (VisibleRowid(pTab) && (selFlags&SF_NestedFrom)); + for(j=0; ja[j], 0, zTName, 0)==0 - ){ - continue; - } + if( j==pTab->nCol ){ + zName = sqlite3RowidAlias(pTab); + if( zName==0 ) continue; + }else{ + zName = pTab->aCol[j].zCnName; - /* If a column is marked as 'hidden', omit it from the expanded - ** result-set list unless the SELECT has the SF_IncludeHidden - ** bit set. - */ - if( (p->selFlags & SF_IncludeHidden)==0 - && IsHiddenColumn(&pTab->aCol[j]) - ){ - continue; - } - if( (pTab->aCol[j].colFlags & COLFLAG_NOEXPAND)!=0 - && zTName==0 - && (selFlags & (SF_NestedFrom))==0 - ){ - continue; + /* If pTab is actually an SF_NestedFrom sub-select, do not + ** expand any ENAME_ROWID columns. */ + if( pNestedFrom && pNestedFrom->a[j].fg.eEName==ENAME_ROWID ){ + continue; + } + + if( zTName + && pNestedFrom + && sqlite3MatchEName(&pNestedFrom->a[j], 0, zTName, 0, 0)==0 + ){ + continue; + } + + /* If a column is marked as 'hidden', omit it from the expanded + ** result-set list unless the SELECT has the SF_IncludeHidden + ** bit set. + */ + if( (p->selFlags & SF_IncludeHidden)==0 + && IsHiddenColumn(&pTab->aCol[j]) + ){ + continue; + } + if( (pTab->aCol[j].colFlags & COLFLAG_NOEXPAND)!=0 + && zTName==0 + && (selFlags & (SF_NestedFrom))==0 + ){ + continue; + } } + assert( zName ); tableSeen = 1; if( i>0 && zTName==0 && (selFlags & SF_NestedFrom)==0 ){ @@ -146642,11 +147499,11 @@ static int selectExpander(Walker *pWalker, Select *p){ zSchemaName, zTabName, zName); testcase( pX->zEName==0 ); } - pX->fg.eEName = ENAME_TAB; + pX->fg.eEName = (j==pTab->nCol ? ENAME_ROWID : ENAME_TAB); if( (pFrom->fg.isUsing && sqlite3IdListIndex(pFrom->u3.pUsing, zName)>=0) || (pUsing && sqlite3IdListIndex(pUsing, zName)>=0) - || (pTab->aCol[j].colFlags & COLFLAG_NOEXPAND)!=0 + || (jnCol && (pTab->aCol[j].colFlags & COLFLAG_NOEXPAND)) ){ pX->fg.bNoExpand = 1; } @@ -146867,8 +147724,14 @@ static void analyzeAggFuncArgs( pNC->ncFlags |= NC_InAggFunc; for(i=0; inFunc; i++){ Expr *pExpr = pAggInfo->aFunc[i].pFExpr; + assert( pExpr->op==TK_FUNCTION || pExpr->op==TK_AGG_FUNCTION ); assert( ExprUseXList(pExpr) ); sqlite3ExprAnalyzeAggList(pNC, pExpr->x.pList); + if( pExpr->pLeft ){ + assert( pExpr->pLeft->op==TK_ORDER ); + assert( ExprUseXList(pExpr->pLeft) ); + sqlite3ExprAnalyzeAggList(pNC, pExpr->pLeft->x.pList); + } #ifndef SQLITE_OMIT_WINDOWFUNC assert( !IsWindowFunc(pExpr) ); if( ExprHasProperty(pExpr, EP_WinFunc) ){ @@ -147023,6 +147886,32 @@ static void resetAccumulator(Parse *pParse, AggInfo *pAggInfo){ pFunc->pFunc->zName)); } } + if( pFunc->iOBTab>=0 ){ + ExprList *pOBList; + KeyInfo *pKeyInfo; + int nExtra = 0; + assert( pFunc->pFExpr->pLeft!=0 ); + assert( pFunc->pFExpr->pLeft->op==TK_ORDER ); + assert( ExprUseXList(pFunc->pFExpr->pLeft) ); + pOBList = pFunc->pFExpr->pLeft->x.pList; + if( !pFunc->bOBUnique ){ + nExtra++; /* One extra column for the OP_Sequence */ + } + if( pFunc->bOBPayload ){ + /* extra columns for the function arguments */ + assert( ExprUseXList(pFunc->pFExpr) ); + nExtra += pFunc->pFExpr->x.pList->nExpr; + } + pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pOBList, 0, nExtra); + if( !pFunc->bOBUnique && pParse->nErr==0 ){ + pKeyInfo->nKeyField++; + } + sqlite3VdbeAddOp4(v, OP_OpenEphemeral, + pFunc->iOBTab, pOBList->nExpr+nExtra, 0, + (char*)pKeyInfo, P4_KEYINFO); + ExplainQueryPlan((pParse, 0, "USE TEMP B-TREE FOR %s(ORDER BY)", + pFunc->pFunc->zName)); + } } } @@ -147038,13 +147927,46 @@ static void finalizeAggFunctions(Parse *pParse, AggInfo *pAggInfo){ ExprList *pList; assert( ExprUseXList(pF->pFExpr) ); pList = pF->pFExpr->x.pList; + if( pF->iOBTab>=0 ){ + /* For an ORDER BY aggregate, calls to OP_AggStep where deferred and + ** all content was stored in emphermal table pF->iOBTab. Extract that + ** content now (in ORDER BY order) and make all calls to OP_AggStep + ** before doing the OP_AggFinal call. */ + int iTop; /* Start of loop for extracting columns */ + int nArg; /* Number of columns to extract */ + int nKey; /* Key columns to be skipped */ + int regAgg; /* Extract into this array */ + int j; /* Loop counter */ + + nArg = pList->nExpr; + regAgg = sqlite3GetTempRange(pParse, nArg); + + if( pF->bOBPayload==0 ){ + nKey = 0; + }else{ + assert( pF->pFExpr->pLeft!=0 ); + assert( ExprUseXList(pF->pFExpr->pLeft) ); + assert( pF->pFExpr->pLeft->x.pList!=0 ); + nKey = pF->pFExpr->pLeft->x.pList->nExpr; + if( ALWAYS(!pF->bOBUnique) ) nKey++; + } + iTop = sqlite3VdbeAddOp1(v, OP_Rewind, pF->iOBTab); VdbeCoverage(v); + for(j=nArg-1; j>=0; j--){ + sqlite3VdbeAddOp3(v, OP_Column, pF->iOBTab, nKey+j, regAgg+j); + } + sqlite3VdbeAddOp3(v, OP_AggStep, 0, regAgg, AggInfoFuncReg(pAggInfo,i)); + sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF); + sqlite3VdbeChangeP5(v, (u8)nArg); + sqlite3VdbeAddOp2(v, OP_Next, pF->iOBTab, iTop+1); VdbeCoverage(v); + sqlite3VdbeJumpHere(v, iTop); + sqlite3ReleaseTempRange(pParse, regAgg, nArg); + } sqlite3VdbeAddOp2(v, OP_AggFinal, AggInfoFuncReg(pAggInfo,i), pList ? pList->nExpr : 0); sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF); } } - /* ** Generate code that will update the accumulator memory cells for an ** aggregate based on the current cursor position. @@ -147053,6 +147975,13 @@ static void finalizeAggFunctions(Parse *pParse, AggInfo *pAggInfo){ ** in pAggInfo, then only populate the pAggInfo->nAccumulator accumulator ** registers if register regAcc contains 0. The caller will take care ** of setting and clearing regAcc. +** +** For an ORDER BY aggregate, the actual accumulator memory cell update +** is deferred until after all input rows have been received, so that they +** can be run in the requested order. In that case, instead of invoking +** OP_AggStep to update the accumulator, just add the arguments that would +** have been passed into OP_AggStep into the sorting ephemeral table +** (along with the appropriate sort key). */ static void updateAccumulator( Parse *pParse, @@ -147074,6 +148003,8 @@ static void updateAccumulator( int nArg; int addrNext = 0; int regAgg; + int regAggSz = 0; + int regDistinct = 0; ExprList *pList; assert( ExprUseXList(pF->pFExpr) ); assert( !IsWindowFunc(pF->pFExpr) ); @@ -147100,9 +148031,44 @@ static void updateAccumulator( addrNext = sqlite3VdbeMakeLabel(pParse); sqlite3ExprIfFalse(pParse, pFilter, addrNext, SQLITE_JUMPIFNULL); } - if( pList ){ + if( pF->iOBTab>=0 ){ + /* Instead of invoking AggStep, we must push the arguments that would + ** have been passed to AggStep onto the sorting table. */ + int jj; /* Registered used so far in building the record */ + ExprList *pOBList; /* The ORDER BY clause */ + assert( pList!=0 ); + nArg = pList->nExpr; + assert( nArg>0 ); + assert( pF->pFExpr->pLeft!=0 ); + assert( pF->pFExpr->pLeft->op==TK_ORDER ); + assert( ExprUseXList(pF->pFExpr->pLeft) ); + pOBList = pF->pFExpr->pLeft->x.pList; + assert( pOBList!=0 ); + assert( pOBList->nExpr>0 ); + regAggSz = pOBList->nExpr; + if( !pF->bOBUnique ){ + regAggSz++; /* One register for OP_Sequence */ + } + if( pF->bOBPayload ){ + regAggSz += nArg; + } + regAggSz++; /* One extra register to hold result of MakeRecord */ + regAgg = sqlite3GetTempRange(pParse, regAggSz); + regDistinct = regAgg; + sqlite3ExprCodeExprList(pParse, pOBList, regAgg, 0, SQLITE_ECEL_DUP); + jj = pOBList->nExpr; + if( !pF->bOBUnique ){ + sqlite3VdbeAddOp2(v, OP_Sequence, pF->iOBTab, regAgg+jj); + jj++; + } + if( pF->bOBPayload ){ + regDistinct = regAgg+jj; + sqlite3ExprCodeExprList(pParse, pList, regDistinct, 0, SQLITE_ECEL_DUP); + } + }else if( pList ){ nArg = pList->nExpr; regAgg = sqlite3GetTempRange(pParse, nArg); + regDistinct = regAgg; sqlite3ExprCodeExprList(pParse, pList, regAgg, 0, SQLITE_ECEL_DUP); }else{ nArg = 0; @@ -147113,26 +148079,37 @@ static void updateAccumulator( addrNext = sqlite3VdbeMakeLabel(pParse); } pF->iDistinct = codeDistinct(pParse, eDistinctType, - pF->iDistinct, addrNext, pList, regAgg); + pF->iDistinct, addrNext, pList, regDistinct); } - if( pF->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){ - CollSeq *pColl = 0; - struct ExprList_item *pItem; - int j; - assert( pList!=0 ); /* pList!=0 if pF->pFunc has NEEDCOLL */ - for(j=0, pItem=pList->a; !pColl && jpExpr); + if( pF->iOBTab>=0 ){ + /* Insert a new record into the ORDER BY table */ + sqlite3VdbeAddOp3(v, OP_MakeRecord, regAgg, regAggSz-1, + regAgg+regAggSz-1); + sqlite3VdbeAddOp4Int(v, OP_IdxInsert, pF->iOBTab, regAgg+regAggSz-1, + regAgg, regAggSz-1); + sqlite3ReleaseTempRange(pParse, regAgg, regAggSz); + }else{ + /* Invoke the AggStep function */ + if( pF->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){ + CollSeq *pColl = 0; + struct ExprList_item *pItem; + int j; + assert( pList!=0 ); /* pList!=0 if pF->pFunc has NEEDCOLL */ + for(j=0, pItem=pList->a; !pColl && jpExpr); + } + if( !pColl ){ + pColl = pParse->db->pDfltColl; + } + if( regHit==0 && pAggInfo->nAccumulator ) regHit = ++pParse->nMem; + sqlite3VdbeAddOp4(v, OP_CollSeq, regHit, 0, 0, + (char *)pColl, P4_COLLSEQ); } - if( !pColl ){ - pColl = pParse->db->pDfltColl; - } - if( regHit==0 && pAggInfo->nAccumulator ) regHit = ++pParse->nMem; - sqlite3VdbeAddOp4(v, OP_CollSeq, regHit, 0, 0, (char *)pColl, P4_COLLSEQ); + sqlite3VdbeAddOp3(v, OP_AggStep, 0, regAgg, AggInfoFuncReg(pAggInfo,i)); + sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF); + sqlite3VdbeChangeP5(v, (u8)nArg); + sqlite3ReleaseTempRange(pParse, regAgg, nArg); } - sqlite3VdbeAddOp3(v, OP_AggStep, 0, regAgg, AggInfoFuncReg(pAggInfo,i)); - sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF); - sqlite3VdbeChangeP5(v, (u8)nArg); - sqlite3ReleaseTempRange(pParse, regAgg, nArg); if( addrNext ){ sqlite3VdbeResolveLabel(v, addrNext); } @@ -149193,6 +150170,10 @@ SQLITE_PRIVATE void sqlite3BeginTrigger( sqlite3ErrorMsg(pParse, "cannot create triggers on virtual tables"); goto trigger_orphan_error; } + if( (pTab->tabFlags & TF_Shadow)!=0 && sqlite3ReadOnlyShadowTables(db) ){ + sqlite3ErrorMsg(pParse, "cannot create triggers on shadow tables"); + goto trigger_orphan_error; + } /* Check that the trigger name is not reserved and that no trigger of the ** specified name exists */ @@ -149976,10 +150957,17 @@ static void codeReturningTrigger( SrcList sFrom; assert( v!=0 ); - assert( pParse->bReturning ); + if( !pParse->bReturning ){ + /* This RETURNING trigger must be for a different statement as + ** this statement lacks a RETURNING clause. */ + return; + } assert( db->pParse==pParse ); pReturning = pParse->u1.pReturning; - assert( pTrigger == &(pReturning->retTrig) ); + if( pTrigger != &(pReturning->retTrig) ){ + /* This RETURNING trigger is for a different statement */ + return; + } memset(&sSelect, 0, sizeof(sSelect)); memset(&sFrom, 0, sizeof(sFrom)); sSelect.pEList = sqlite3ExprListDup(db, pReturning->pReturnEL, 0); @@ -153416,7 +154404,7 @@ SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){ sqlite3_mutex_enter(db->mutex); pCtx = db->pVtabCtx; if( !pCtx || pCtx->bDeclared ){ - sqlite3Error(db, SQLITE_MISUSE); + sqlite3Error(db, SQLITE_MISUSE_BKPT); sqlite3_mutex_leave(db->mutex); return SQLITE_MISUSE_BKPT; } @@ -154607,7 +155595,7 @@ SQLITE_PRIVATE void sqlite3WhereTabFuncArgs(Parse*, SrcItem*, WhereClause*); #define WHERE_BLOOMFILTER 0x00400000 /* Consider using a Bloom-filter */ #define WHERE_SELFCULL 0x00800000 /* nOut reduced by extra WHERE terms */ #define WHERE_OMIT_OFFSET 0x01000000 /* Set offset counter to zero */ -#define WHERE_VIEWSCAN 0x02000000 /* A full-scan of a VIEW or subquery */ + /* 0x02000000 -- available for reuse */ #define WHERE_EXPRIDX 0x04000000 /* Uses an index-on-expressions */ #endif /* !defined(SQLITE_WHEREINT_H) */ @@ -160402,13 +161390,17 @@ static SQLITE_NOINLINE void sqlite3ConstructBloomFilter( WhereLoop *pLoop = pLevel->pWLoop; /* The loop being coded */ int iCur; /* Cursor for table getting the filter */ IndexedExpr *saved_pIdxEpr; /* saved copy of Parse.pIdxEpr */ + IndexedExpr *saved_pIdxPartExpr; /* saved copy of Parse.pIdxPartExpr */ saved_pIdxEpr = pParse->pIdxEpr; + saved_pIdxPartExpr = pParse->pIdxPartExpr; pParse->pIdxEpr = 0; + pParse->pIdxPartExpr = 0; assert( pLoop!=0 ); assert( v!=0 ); assert( pLoop->wsFlags & WHERE_BLOOMFILTER ); + assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 ); addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v); do{ @@ -160498,6 +161490,7 @@ static SQLITE_NOINLINE void sqlite3ConstructBloomFilter( }while( iLevel < pWInfo->nLevel ); sqlite3VdbeJumpHere(v, addrOnce); pParse->pIdxEpr = saved_pIdxEpr; + pParse->pIdxPartExpr = saved_pIdxPartExpr; } @@ -162757,6 +163750,100 @@ static SQLITE_NOINLINE u32 whereIsCoveringIndex( return rc; } +/* +** This is an sqlite3ParserAddCleanup() callback that is invoked to +** free the Parse->pIdxEpr list when the Parse object is destroyed. +*/ +static void whereIndexedExprCleanup(sqlite3 *db, void *pObject){ + IndexedExpr **pp = (IndexedExpr**)pObject; + while( *pp!=0 ){ + IndexedExpr *p = *pp; + *pp = p->pIENext; + sqlite3ExprDelete(db, p->pExpr); + sqlite3DbFreeNN(db, p); + } +} + +/* +** This function is called for a partial index - one with a WHERE clause - in +** two scenarios. In both cases, it determines whether or not the WHERE +** clause on the index implies that a column of the table may be safely +** replaced by a constant expression. For example, in the following +** SELECT: +** +** CREATE INDEX i1 ON t1(b, c) WHERE a=; +** SELECT a, b, c FROM t1 WHERE a= AND b=?; +** +** The "a" in the select-list may be replaced by , iff: +** +** (a) is a constant expression, and +** (b) The (a=) comparison uses the BINARY collation sequence, and +** (c) Column "a" has an affinity other than NONE or BLOB. +** +** If argument pItem is NULL, then pMask must not be NULL. In this case this +** function is being called as part of determining whether or not pIdx +** is a covering index. This function clears any bits in (*pMask) +** corresponding to columns that may be replaced by constants as described +** above. +** +** Otherwise, if pItem is not NULL, then this function is being called +** as part of coding a loop that uses index pIdx. In this case, add entries +** to the Parse.pIdxPartExpr list for each column that can be replaced +** by a constant. +*/ +static void wherePartIdxExpr( + Parse *pParse, /* Parse context */ + Index *pIdx, /* Partial index being processed */ + Expr *pPart, /* WHERE clause being processed */ + Bitmask *pMask, /* Mask to clear bits in */ + int iIdxCur, /* Cursor number for index */ + SrcItem *pItem /* The FROM clause entry for the table */ +){ + assert( pItem==0 || (pItem->fg.jointype & JT_RIGHT)==0 ); + assert( (pItem==0 || pMask==0) && (pMask!=0 || pItem!=0) ); + + if( pPart->op==TK_AND ){ + wherePartIdxExpr(pParse, pIdx, pPart->pRight, pMask, iIdxCur, pItem); + pPart = pPart->pLeft; + } + + if( (pPart->op==TK_EQ || pPart->op==TK_IS) ){ + Expr *pLeft = pPart->pLeft; + Expr *pRight = pPart->pRight; + u8 aff; + + if( pLeft->op!=TK_COLUMN ) return; + if( !sqlite3ExprIsConstant(pRight) ) return; + if( !sqlite3IsBinary(sqlite3ExprCompareCollSeq(pParse, pPart)) ) return; + if( pLeft->iColumn<0 ) return; + aff = pIdx->pTable->aCol[pLeft->iColumn].affinity; + if( aff>=SQLITE_AFF_TEXT ){ + if( pItem ){ + sqlite3 *db = pParse->db; + IndexedExpr *p = (IndexedExpr*)sqlite3DbMallocRaw(db, sizeof(*p)); + if( p ){ + int bNullRow = (pItem->fg.jointype&(JT_LEFT|JT_LTORJ))!=0; + p->pExpr = sqlite3ExprDup(db, pRight, 0); + p->iDataCur = pItem->iCursor; + p->iIdxCur = iIdxCur; + p->iIdxCol = pLeft->iColumn; + p->bMaybeNullRow = bNullRow; + p->pIENext = pParse->pIdxPartExpr; + p->aff = aff; + pParse->pIdxPartExpr = p; + if( p->pIENext==0 ){ + void *pArg = (void*)&pParse->pIdxPartExpr; + sqlite3ParserAddCleanup(pParse, whereIndexedExprCleanup, pArg); + } + } + }else if( pLeft->iColumn<(BMS-1) ){ + *pMask &= ~((Bitmask)1 << pLeft->iColumn); + } + } + } +} + + /* ** Add all WhereLoop objects for a single table of the join where the table ** is identified by pBuilder->pNew->iTab. That table is guaranteed to be @@ -162960,9 +164047,6 @@ static int whereLoopAddBtree( #else pNew->rRun = rSize + 16; #endif - if( IsView(pTab) || (pTab->tabFlags & TF_Ephemeral)!=0 ){ - pNew->wsFlags |= WHERE_VIEWSCAN; - } ApplyCostMultiplier(pNew->rRun, pTab->costMult); whereLoopOutputAdjust(pWC, pNew, rSize); rc = whereLoopInsert(pBuilder, pNew); @@ -162975,6 +164059,11 @@ static int whereLoopAddBtree( pNew->wsFlags = WHERE_IDX_ONLY | WHERE_INDEXED; }else{ m = pSrc->colUsed & pProbe->colNotIdxed; + if( pProbe->pPartIdxWhere ){ + wherePartIdxExpr( + pWInfo->pParse, pProbe, pProbe->pPartIdxWhere, &m, 0, 0 + ); + } pNew->wsFlags = WHERE_INDEXED; if( m==TOPBIT || (pProbe->bHasExpr && !pProbe->bHasVCol && m!=0) ){ u32 isCov = whereIsCoveringIndex(pWInfo, pProbe, pSrc->iCursor); @@ -163357,7 +164446,7 @@ SQLITE_API int sqlite3_vtab_rhs_value( sqlite3_value *pVal = 0; int rc = SQLITE_OK; if( iCons<0 || iCons>=pIdxInfo->nConstraint ){ - rc = SQLITE_MISUSE; /* EV: R-30545-25046 */ + rc = SQLITE_MISUSE_BKPT; /* EV: R-30545-25046 */ }else{ if( pH->aRhs[iCons]==0 ){ WhereTerm *pTerm = &pH->pWC->a[pIdxInfo->aConstraint[iCons].iTermOffset]; @@ -164381,14 +165470,6 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ rUnsorted -= 2; /* TUNING: Slight bias in favor of no-sort plans */ } - /* TUNING: A full-scan of a VIEW or subquery in the outer loop - ** is not so bad. */ - if( iLoop==0 && (pWLoop->wsFlags & WHERE_VIEWSCAN)!=0 && nLoop>1 ){ - rCost += -10; - nOut += -30; - WHERETRACE(0x80,("VIEWSCAN cost reduction for %c\n",pWLoop->cId)); - } - /* Check to see if pWLoop should be added to the set of ** mxChoice best-so-far paths. ** @@ -164938,20 +166019,6 @@ static SQLITE_NOINLINE void whereCheckIfBloomFilterIsUseful( } } -/* -** This is an sqlite3ParserAddCleanup() callback that is invoked to -** free the Parse->pIdxEpr list when the Parse object is destroyed. -*/ -static void whereIndexedExprCleanup(sqlite3 *db, void *pObject){ - Parse *pParse = (Parse*)pObject; - while( pParse->pIdxEpr!=0 ){ - IndexedExpr *p = pParse->pIdxEpr; - pParse->pIdxEpr = p->pIENext; - sqlite3ExprDelete(db, p->pExpr); - sqlite3DbFreeNN(db, p); - } -} - /* ** The index pIdx is used by a query and contains one or more expressions. ** In other words pIdx is an index on an expression. iIdxCur is the cursor @@ -165013,7 +166080,8 @@ static SQLITE_NOINLINE void whereAddIndexedExpr( #endif pParse->pIdxEpr = p; if( p->pIENext==0 ){ - sqlite3ParserAddCleanup(pParse, whereIndexedExprCleanup, pParse); + void *pArg = (void*)&pParse->pIdxEpr; + sqlite3ParserAddCleanup(pParse, whereIndexedExprCleanup, pArg); } } } @@ -165403,6 +166471,16 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin( wherePathSolver(pWInfo, pWInfo->nRowOut+1); if( db->mallocFailed ) goto whereBeginError; } + + /* TUNING: Assume that a DISTINCT clause on a subquery reduces + ** the output size by a factor of 8 (LogEst -30). + */ + if( (pWInfo->wctrlFlags & WHERE_WANT_DISTINCT)!=0 ){ + WHERETRACE(0x0080,("nRowOut reduced from %d to %d due to DISTINCT\n", + pWInfo->nRowOut, pWInfo->nRowOut-30)); + pWInfo->nRowOut -= 30; + } + } assert( pWInfo->pTabList!=0 ); if( pWInfo->pOrderBy==0 && (db->flags & SQLITE_ReverseOrder)!=0 ){ @@ -165615,6 +166693,11 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin( if( pIx->bHasExpr && OptimizationEnabled(db, SQLITE_IndexedExpr) ){ whereAddIndexedExpr(pParse, pIx, iIndexCur, pTabItem); } + if( pIx->pPartIdxWhere && (pTabItem->fg.jointype & JT_RIGHT)==0 ){ + wherePartIdxExpr( + pParse, pIx, pIx->pPartIdxWhere, 0, iIndexCur, pTabItem + ); + } } pLevel->iIdxCur = iIndexCur; assert( pIx!=0 ); @@ -167431,8 +168514,9 @@ SQLITE_PRIVATE void sqlite3WindowAttach(Parse *pParse, Expr *p, Window *pWin){ if( p ){ assert( p->op==TK_FUNCTION ); assert( pWin ); + assert( ExprIsFullSize(p) ); p->y.pWin = pWin; - ExprSetProperty(p, EP_WinFunc); + ExprSetProperty(p, EP_WinFunc|EP_FullSize); pWin->pOwner = p; if( (p->flags & EP_Distinct) && pWin->eFrmType!=TK_FILTER ){ sqlite3ErrorMsg(pParse, @@ -169734,18 +170818,18 @@ typedef union { #define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse; #define sqlite3ParserCTX_STORE yypParser->pParse=pParse; #define YYFALLBACK 1 -#define YYNSTATE 575 -#define YYNRULE 403 -#define YYNRULE_WITH_ACTION 338 +#define YYNSTATE 579 +#define YYNRULE 405 +#define YYNRULE_WITH_ACTION 340 #define YYNTOKEN 185 -#define YY_MAX_SHIFT 574 -#define YY_MIN_SHIFTREDUCE 833 -#define YY_MAX_SHIFTREDUCE 1235 -#define YY_ERROR_ACTION 1236 -#define YY_ACCEPT_ACTION 1237 -#define YY_NO_ACTION 1238 -#define YY_MIN_REDUCE 1239 -#define YY_MAX_REDUCE 1641 +#define YY_MAX_SHIFT 578 +#define YY_MIN_SHIFTREDUCE 838 +#define YY_MAX_SHIFTREDUCE 1242 +#define YY_ERROR_ACTION 1243 +#define YY_ACCEPT_ACTION 1244 +#define YY_NO_ACTION 1245 +#define YY_MIN_REDUCE 1246 +#define YY_MAX_REDUCE 1650 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -169812,218 +170896,218 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (2096) +#define YY_ACTTAB_COUNT (2100) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 568, 208, 568, 118, 115, 229, 568, 118, 115, 229, - /* 10 */ 568, 1310, 377, 1289, 408, 562, 562, 562, 568, 409, - /* 20 */ 378, 1310, 1272, 41, 41, 41, 41, 208, 1520, 71, - /* 30 */ 71, 969, 419, 41, 41, 491, 303, 279, 303, 970, - /* 40 */ 397, 71, 71, 125, 126, 80, 1210, 1210, 1047, 1050, - /* 50 */ 1037, 1037, 123, 123, 124, 124, 124, 124, 476, 409, - /* 60 */ 1237, 1, 1, 574, 2, 1241, 550, 118, 115, 229, - /* 70 */ 317, 480, 146, 480, 524, 118, 115, 229, 529, 1323, - /* 80 */ 417, 523, 142, 125, 126, 80, 1210, 1210, 1047, 1050, - /* 90 */ 1037, 1037, 123, 123, 124, 124, 124, 124, 118, 115, - /* 100 */ 229, 327, 122, 122, 122, 122, 121, 121, 120, 120, - /* 110 */ 120, 119, 116, 444, 284, 284, 284, 284, 442, 442, - /* 120 */ 442, 1559, 376, 1561, 1186, 375, 1157, 565, 1157, 565, - /* 130 */ 409, 1559, 537, 259, 226, 444, 101, 145, 449, 316, - /* 140 */ 559, 240, 122, 122, 122, 122, 121, 121, 120, 120, - /* 150 */ 120, 119, 116, 444, 125, 126, 80, 1210, 1210, 1047, - /* 160 */ 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, 142, - /* 170 */ 294, 1186, 339, 448, 120, 120, 120, 119, 116, 444, - /* 180 */ 127, 1186, 1187, 1186, 148, 441, 440, 568, 119, 116, - /* 190 */ 444, 124, 124, 124, 124, 117, 122, 122, 122, 122, - /* 200 */ 121, 121, 120, 120, 120, 119, 116, 444, 454, 113, - /* 210 */ 13, 13, 546, 122, 122, 122, 122, 121, 121, 120, - /* 220 */ 120, 120, 119, 116, 444, 422, 316, 559, 1186, 1187, - /* 230 */ 1186, 149, 1218, 409, 1218, 124, 124, 124, 124, 122, - /* 240 */ 122, 122, 122, 121, 121, 120, 120, 120, 119, 116, - /* 250 */ 444, 465, 342, 1034, 1034, 1048, 1051, 125, 126, 80, - /* 260 */ 1210, 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, - /* 270 */ 124, 124, 1275, 522, 222, 1186, 568, 409, 224, 514, - /* 280 */ 175, 82, 83, 122, 122, 122, 122, 121, 121, 120, - /* 290 */ 120, 120, 119, 116, 444, 1005, 16, 16, 1186, 133, - /* 300 */ 133, 125, 126, 80, 1210, 1210, 1047, 1050, 1037, 1037, - /* 310 */ 123, 123, 124, 124, 124, 124, 122, 122, 122, 122, - /* 320 */ 121, 121, 120, 120, 120, 119, 116, 444, 1038, 546, - /* 330 */ 1186, 373, 1186, 1187, 1186, 252, 1429, 399, 504, 501, - /* 340 */ 500, 111, 560, 566, 4, 924, 924, 433, 499, 340, - /* 350 */ 460, 328, 360, 394, 1231, 1186, 1187, 1186, 563, 568, - /* 360 */ 122, 122, 122, 122, 121, 121, 120, 120, 120, 119, - /* 370 */ 116, 444, 284, 284, 369, 1572, 1598, 441, 440, 154, - /* 380 */ 409, 445, 71, 71, 1282, 565, 1215, 1186, 1187, 1186, - /* 390 */ 85, 1217, 271, 557, 543, 515, 515, 568, 98, 1216, - /* 400 */ 6, 1274, 472, 142, 125, 126, 80, 1210, 1210, 1047, - /* 410 */ 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, 550, - /* 420 */ 13, 13, 1024, 507, 1218, 1186, 1218, 549, 109, 109, - /* 430 */ 222, 568, 1232, 175, 568, 427, 110, 197, 445, 569, - /* 440 */ 445, 430, 1546, 1014, 325, 551, 1186, 270, 287, 368, - /* 450 */ 510, 363, 509, 257, 71, 71, 543, 71, 71, 359, - /* 460 */ 316, 559, 1604, 122, 122, 122, 122, 121, 121, 120, - /* 470 */ 120, 120, 119, 116, 444, 1014, 1014, 1016, 1017, 27, - /* 480 */ 284, 284, 1186, 1187, 1186, 1152, 568, 1603, 409, 899, - /* 490 */ 190, 550, 356, 565, 550, 935, 533, 517, 1152, 516, - /* 500 */ 413, 1152, 552, 1186, 1187, 1186, 568, 544, 544, 51, - /* 510 */ 51, 214, 125, 126, 80, 1210, 1210, 1047, 1050, 1037, - /* 520 */ 1037, 123, 123, 124, 124, 124, 124, 1186, 474, 135, - /* 530 */ 135, 409, 284, 284, 1484, 505, 121, 121, 120, 120, - /* 540 */ 120, 119, 116, 444, 1005, 565, 518, 217, 541, 541, - /* 550 */ 316, 559, 142, 6, 532, 125, 126, 80, 1210, 1210, - /* 560 */ 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, - /* 570 */ 1548, 122, 122, 122, 122, 121, 121, 120, 120, 120, - /* 580 */ 119, 116, 444, 485, 1186, 1187, 1186, 482, 281, 1263, - /* 590 */ 955, 252, 1186, 373, 504, 501, 500, 1186, 340, 570, - /* 600 */ 1186, 570, 409, 292, 499, 955, 874, 191, 480, 316, - /* 610 */ 559, 384, 290, 380, 122, 122, 122, 122, 121, 121, - /* 620 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1210, - /* 630 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, - /* 640 */ 124, 409, 394, 1132, 1186, 867, 100, 284, 284, 1186, - /* 650 */ 1187, 1186, 373, 1089, 1186, 1187, 1186, 1186, 1187, 1186, - /* 660 */ 565, 455, 32, 373, 233, 125, 126, 80, 1210, 1210, - /* 670 */ 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, - /* 680 */ 1428, 957, 568, 228, 956, 122, 122, 122, 122, 121, - /* 690 */ 121, 120, 120, 120, 119, 116, 444, 1152, 228, 1186, - /* 700 */ 157, 1186, 1187, 1186, 1547, 13, 13, 301, 955, 1226, - /* 710 */ 1152, 153, 409, 1152, 373, 1575, 1170, 5, 369, 1572, - /* 720 */ 429, 1232, 3, 955, 122, 122, 122, 122, 121, 121, - /* 730 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1210, - /* 740 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, - /* 750 */ 124, 409, 208, 567, 1186, 1025, 1186, 1187, 1186, 1186, - /* 760 */ 388, 850, 155, 1546, 286, 402, 1094, 1094, 488, 568, - /* 770 */ 465, 342, 1315, 1315, 1546, 125, 126, 80, 1210, 1210, - /* 780 */ 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, - /* 790 */ 129, 568, 13, 13, 374, 122, 122, 122, 122, 121, - /* 800 */ 121, 120, 120, 120, 119, 116, 444, 302, 568, 453, - /* 810 */ 528, 1186, 1187, 1186, 13, 13, 1186, 1187, 1186, 1293, - /* 820 */ 463, 1263, 409, 1313, 1313, 1546, 1010, 453, 452, 200, - /* 830 */ 299, 71, 71, 1261, 122, 122, 122, 122, 121, 121, - /* 840 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1210, - /* 850 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, - /* 860 */ 124, 409, 227, 1069, 1152, 284, 284, 419, 312, 278, - /* 870 */ 278, 285, 285, 1415, 406, 405, 382, 1152, 565, 568, - /* 880 */ 1152, 1189, 565, 1592, 565, 125, 126, 80, 1210, 1210, - /* 890 */ 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, 124, - /* 900 */ 453, 1476, 13, 13, 1530, 122, 122, 122, 122, 121, - /* 910 */ 121, 120, 120, 120, 119, 116, 444, 201, 568, 354, - /* 920 */ 1578, 574, 2, 1241, 838, 839, 840, 1554, 317, 1205, - /* 930 */ 146, 6, 409, 255, 254, 253, 206, 1323, 9, 1189, - /* 940 */ 262, 71, 71, 424, 122, 122, 122, 122, 121, 121, - /* 950 */ 120, 120, 120, 119, 116, 444, 125, 126, 80, 1210, - /* 960 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, - /* 970 */ 124, 568, 284, 284, 568, 1206, 409, 573, 313, 1241, - /* 980 */ 349, 1292, 352, 419, 317, 565, 146, 491, 525, 1635, - /* 990 */ 395, 371, 491, 1323, 70, 70, 1291, 71, 71, 240, - /* 1000 */ 1321, 104, 80, 1210, 1210, 1047, 1050, 1037, 1037, 123, - /* 1010 */ 123, 124, 124, 124, 124, 122, 122, 122, 122, 121, - /* 1020 */ 121, 120, 120, 120, 119, 116, 444, 1110, 284, 284, - /* 1030 */ 428, 448, 1519, 1206, 439, 284, 284, 1483, 1348, 311, - /* 1040 */ 474, 565, 1111, 969, 491, 491, 217, 1259, 565, 1532, - /* 1050 */ 568, 970, 207, 568, 1024, 240, 383, 1112, 519, 122, - /* 1060 */ 122, 122, 122, 121, 121, 120, 120, 120, 119, 116, - /* 1070 */ 444, 1015, 107, 71, 71, 1014, 13, 13, 910, 568, - /* 1080 */ 1489, 568, 284, 284, 97, 526, 491, 448, 911, 1322, - /* 1090 */ 1318, 545, 409, 284, 284, 565, 151, 209, 1489, 1491, - /* 1100 */ 262, 450, 55, 55, 56, 56, 565, 1014, 1014, 1016, - /* 1110 */ 443, 332, 409, 527, 12, 295, 125, 126, 80, 1210, - /* 1120 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, - /* 1130 */ 124, 347, 409, 862, 1528, 1206, 125, 126, 80, 1210, - /* 1140 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, - /* 1150 */ 124, 1133, 1633, 474, 1633, 371, 125, 114, 80, 1210, - /* 1160 */ 1210, 1047, 1050, 1037, 1037, 123, 123, 124, 124, 124, - /* 1170 */ 124, 1489, 329, 474, 331, 122, 122, 122, 122, 121, - /* 1180 */ 121, 120, 120, 120, 119, 116, 444, 203, 1415, 568, - /* 1190 */ 1290, 862, 464, 1206, 436, 122, 122, 122, 122, 121, - /* 1200 */ 121, 120, 120, 120, 119, 116, 444, 553, 1133, 1634, - /* 1210 */ 539, 1634, 15, 15, 890, 122, 122, 122, 122, 121, - /* 1220 */ 121, 120, 120, 120, 119, 116, 444, 568, 298, 538, - /* 1230 */ 1131, 1415, 1552, 1553, 1327, 409, 6, 6, 1163, 1264, - /* 1240 */ 415, 320, 284, 284, 1415, 508, 565, 525, 300, 457, - /* 1250 */ 43, 43, 568, 891, 12, 565, 330, 478, 425, 407, - /* 1260 */ 126, 80, 1210, 1210, 1047, 1050, 1037, 1037, 123, 123, - /* 1270 */ 124, 124, 124, 124, 568, 57, 57, 288, 1186, 1415, - /* 1280 */ 496, 458, 392, 392, 391, 273, 389, 1131, 1551, 847, - /* 1290 */ 1163, 407, 6, 568, 321, 1152, 470, 44, 44, 1550, - /* 1300 */ 1110, 426, 234, 6, 323, 256, 540, 256, 1152, 431, - /* 1310 */ 568, 1152, 322, 17, 487, 1111, 58, 58, 122, 122, - /* 1320 */ 122, 122, 121, 121, 120, 120, 120, 119, 116, 444, - /* 1330 */ 1112, 216, 481, 59, 59, 1186, 1187, 1186, 111, 560, - /* 1340 */ 324, 4, 236, 456, 526, 568, 237, 456, 568, 437, - /* 1350 */ 168, 556, 420, 141, 479, 563, 568, 293, 568, 1091, - /* 1360 */ 568, 293, 568, 1091, 531, 568, 870, 8, 60, 60, - /* 1370 */ 235, 61, 61, 568, 414, 568, 414, 568, 445, 62, - /* 1380 */ 62, 45, 45, 46, 46, 47, 47, 199, 49, 49, - /* 1390 */ 557, 568, 359, 568, 100, 486, 50, 50, 63, 63, - /* 1400 */ 64, 64, 561, 415, 535, 410, 568, 1024, 568, 534, - /* 1410 */ 316, 559, 316, 559, 65, 65, 14, 14, 568, 1024, - /* 1420 */ 568, 512, 930, 870, 1015, 109, 109, 929, 1014, 66, - /* 1430 */ 66, 131, 131, 110, 451, 445, 569, 445, 416, 177, - /* 1440 */ 1014, 132, 132, 67, 67, 568, 467, 568, 930, 471, - /* 1450 */ 1360, 283, 226, 929, 315, 1359, 407, 568, 459, 407, - /* 1460 */ 1014, 1014, 1016, 239, 407, 86, 213, 1346, 52, 52, - /* 1470 */ 68, 68, 1014, 1014, 1016, 1017, 27, 1577, 1174, 447, - /* 1480 */ 69, 69, 288, 97, 108, 1535, 106, 392, 392, 391, - /* 1490 */ 273, 389, 568, 877, 847, 881, 568, 111, 560, 466, - /* 1500 */ 4, 568, 152, 30, 38, 568, 1128, 234, 396, 323, - /* 1510 */ 111, 560, 527, 4, 563, 53, 53, 322, 568, 163, - /* 1520 */ 163, 568, 337, 468, 164, 164, 333, 563, 76, 76, - /* 1530 */ 568, 289, 1508, 568, 31, 1507, 568, 445, 338, 483, - /* 1540 */ 100, 54, 54, 344, 72, 72, 296, 236, 1076, 557, - /* 1550 */ 445, 877, 1356, 134, 134, 168, 73, 73, 141, 161, - /* 1560 */ 161, 1566, 557, 535, 568, 319, 568, 348, 536, 1007, - /* 1570 */ 473, 261, 261, 889, 888, 235, 535, 568, 1024, 568, - /* 1580 */ 475, 534, 261, 367, 109, 109, 521, 136, 136, 130, - /* 1590 */ 130, 1024, 110, 366, 445, 569, 445, 109, 109, 1014, - /* 1600 */ 162, 162, 156, 156, 568, 110, 1076, 445, 569, 445, - /* 1610 */ 410, 351, 1014, 568, 353, 316, 559, 568, 343, 568, - /* 1620 */ 100, 497, 357, 258, 100, 896, 897, 140, 140, 355, - /* 1630 */ 1306, 1014, 1014, 1016, 1017, 27, 139, 139, 362, 451, - /* 1640 */ 137, 137, 138, 138, 1014, 1014, 1016, 1017, 27, 1174, - /* 1650 */ 447, 568, 372, 288, 111, 560, 1018, 4, 392, 392, - /* 1660 */ 391, 273, 389, 568, 1137, 847, 568, 1072, 568, 258, - /* 1670 */ 492, 563, 568, 211, 75, 75, 555, 960, 234, 261, - /* 1680 */ 323, 111, 560, 927, 4, 113, 77, 77, 322, 74, - /* 1690 */ 74, 42, 42, 1369, 445, 48, 48, 1414, 563, 972, - /* 1700 */ 973, 1088, 1087, 1088, 1087, 860, 557, 150, 928, 1342, - /* 1710 */ 113, 1354, 554, 1419, 1018, 1271, 1262, 1250, 236, 1249, - /* 1720 */ 1251, 445, 1585, 1339, 308, 276, 168, 309, 11, 141, - /* 1730 */ 393, 310, 232, 557, 1401, 1024, 335, 291, 1396, 219, - /* 1740 */ 336, 109, 109, 934, 297, 1406, 235, 341, 477, 110, - /* 1750 */ 502, 445, 569, 445, 1389, 1405, 1014, 400, 1289, 365, - /* 1760 */ 223, 1480, 1024, 1479, 1351, 1352, 1350, 1349, 109, 109, - /* 1770 */ 204, 1588, 1226, 558, 265, 218, 110, 205, 445, 569, - /* 1780 */ 445, 410, 387, 1014, 1527, 179, 316, 559, 1014, 1014, - /* 1790 */ 1016, 1017, 27, 230, 1525, 1223, 79, 560, 85, 4, - /* 1800 */ 418, 215, 548, 81, 84, 188, 1402, 173, 181, 461, - /* 1810 */ 451, 35, 462, 563, 183, 1014, 1014, 1016, 1017, 27, - /* 1820 */ 184, 1485, 185, 186, 495, 242, 98, 398, 1408, 36, - /* 1830 */ 1407, 484, 91, 469, 401, 1410, 445, 192, 1474, 246, - /* 1840 */ 1496, 490, 346, 277, 248, 196, 493, 511, 557, 350, - /* 1850 */ 1252, 249, 250, 403, 1309, 1308, 111, 560, 432, 4, - /* 1860 */ 1307, 1300, 93, 1602, 881, 1601, 224, 404, 434, 520, - /* 1870 */ 263, 435, 1571, 563, 1279, 1278, 364, 1024, 306, 1277, - /* 1880 */ 264, 1600, 1557, 109, 109, 370, 1299, 307, 1556, 438, - /* 1890 */ 128, 110, 1374, 445, 569, 445, 445, 546, 1014, 10, - /* 1900 */ 1461, 105, 381, 1373, 34, 571, 99, 1332, 557, 314, - /* 1910 */ 1180, 530, 272, 274, 379, 210, 1331, 547, 385, 386, - /* 1920 */ 275, 572, 1247, 1242, 411, 412, 1512, 165, 178, 1513, - /* 1930 */ 1014, 1014, 1016, 1017, 27, 1511, 1510, 1024, 78, 147, - /* 1940 */ 166, 220, 221, 109, 109, 834, 304, 167, 446, 212, - /* 1950 */ 318, 110, 231, 445, 569, 445, 144, 1086, 1014, 1084, - /* 1960 */ 326, 180, 169, 1205, 182, 334, 238, 913, 241, 1100, - /* 1970 */ 187, 170, 171, 421, 87, 88, 423, 189, 89, 90, - /* 1980 */ 172, 1103, 243, 1099, 244, 158, 18, 245, 345, 247, - /* 1990 */ 1014, 1014, 1016, 1017, 27, 261, 1092, 193, 1220, 489, - /* 2000 */ 194, 37, 366, 849, 494, 251, 195, 506, 92, 19, - /* 2010 */ 498, 358, 20, 503, 879, 361, 94, 892, 305, 159, - /* 2020 */ 513, 39, 95, 1168, 160, 1053, 964, 1139, 96, 174, - /* 2030 */ 1138, 225, 280, 282, 198, 958, 113, 1158, 1154, 260, - /* 2040 */ 21, 22, 23, 1156, 1162, 1161, 1143, 24, 33, 25, - /* 2050 */ 202, 542, 26, 100, 1067, 102, 1054, 103, 7, 1052, - /* 2060 */ 1056, 1109, 1057, 1108, 266, 267, 28, 40, 390, 1019, - /* 2070 */ 861, 112, 29, 564, 1176, 1175, 268, 176, 143, 923, - /* 2080 */ 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238, - /* 2090 */ 1238, 1238, 1238, 1238, 269, 1593, + /* 0 */ 572, 210, 572, 119, 116, 231, 572, 119, 116, 231, + /* 10 */ 572, 1317, 379, 1296, 410, 566, 566, 566, 572, 411, + /* 20 */ 380, 1317, 1279, 42, 42, 42, 42, 210, 1529, 72, + /* 30 */ 72, 974, 421, 42, 42, 495, 305, 281, 305, 975, + /* 40 */ 399, 72, 72, 126, 127, 81, 1217, 1217, 1054, 1057, + /* 50 */ 1044, 1044, 124, 124, 125, 125, 125, 125, 480, 411, + /* 60 */ 1244, 1, 1, 578, 2, 1248, 554, 119, 116, 231, + /* 70 */ 319, 484, 147, 484, 528, 119, 116, 231, 533, 1330, + /* 80 */ 419, 527, 143, 126, 127, 81, 1217, 1217, 1054, 1057, + /* 90 */ 1044, 1044, 124, 124, 125, 125, 125, 125, 119, 116, + /* 100 */ 231, 329, 123, 123, 123, 123, 122, 122, 121, 121, + /* 110 */ 121, 120, 117, 448, 286, 286, 286, 286, 446, 446, + /* 120 */ 446, 1568, 378, 1570, 1193, 377, 1164, 569, 1164, 569, + /* 130 */ 411, 1568, 541, 261, 228, 448, 102, 146, 453, 318, + /* 140 */ 563, 242, 123, 123, 123, 123, 122, 122, 121, 121, + /* 150 */ 121, 120, 117, 448, 126, 127, 81, 1217, 1217, 1054, + /* 160 */ 1057, 1044, 1044, 124, 124, 125, 125, 125, 125, 143, + /* 170 */ 296, 1193, 341, 452, 121, 121, 121, 120, 117, 448, + /* 180 */ 128, 1193, 1194, 1193, 149, 445, 444, 572, 120, 117, + /* 190 */ 448, 125, 125, 125, 125, 118, 123, 123, 123, 123, + /* 200 */ 122, 122, 121, 121, 121, 120, 117, 448, 458, 114, + /* 210 */ 13, 13, 550, 123, 123, 123, 123, 122, 122, 121, + /* 220 */ 121, 121, 120, 117, 448, 424, 318, 563, 1193, 1194, + /* 230 */ 1193, 150, 1225, 411, 1225, 125, 125, 125, 125, 123, + /* 240 */ 123, 123, 123, 122, 122, 121, 121, 121, 120, 117, + /* 250 */ 448, 469, 344, 1041, 1041, 1055, 1058, 126, 127, 81, + /* 260 */ 1217, 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, + /* 270 */ 125, 125, 1282, 526, 224, 1193, 572, 411, 226, 519, + /* 280 */ 177, 83, 84, 123, 123, 123, 123, 122, 122, 121, + /* 290 */ 121, 121, 120, 117, 448, 1010, 16, 16, 1193, 134, + /* 300 */ 134, 126, 127, 81, 1217, 1217, 1054, 1057, 1044, 1044, + /* 310 */ 124, 124, 125, 125, 125, 125, 123, 123, 123, 123, + /* 320 */ 122, 122, 121, 121, 121, 120, 117, 448, 1045, 550, + /* 330 */ 1193, 375, 1193, 1194, 1193, 254, 1438, 401, 508, 505, + /* 340 */ 504, 112, 564, 570, 4, 929, 929, 435, 503, 342, + /* 350 */ 464, 330, 362, 396, 1238, 1193, 1194, 1193, 567, 572, + /* 360 */ 123, 123, 123, 123, 122, 122, 121, 121, 121, 120, + /* 370 */ 117, 448, 286, 286, 371, 1581, 1607, 445, 444, 155, + /* 380 */ 411, 449, 72, 72, 1289, 569, 1222, 1193, 1194, 1193, + /* 390 */ 86, 1224, 273, 561, 547, 520, 520, 572, 99, 1223, + /* 400 */ 6, 1281, 476, 143, 126, 127, 81, 1217, 1217, 1054, + /* 410 */ 1057, 1044, 1044, 124, 124, 125, 125, 125, 125, 554, + /* 420 */ 13, 13, 1031, 511, 1225, 1193, 1225, 553, 110, 110, + /* 430 */ 224, 572, 1239, 177, 572, 429, 111, 199, 449, 573, + /* 440 */ 449, 432, 1555, 1019, 327, 555, 1193, 272, 289, 370, + /* 450 */ 514, 365, 513, 259, 72, 72, 547, 72, 72, 361, + /* 460 */ 318, 563, 1613, 123, 123, 123, 123, 122, 122, 121, + /* 470 */ 121, 121, 120, 117, 448, 1019, 1019, 1021, 1022, 28, + /* 480 */ 286, 286, 1193, 1194, 1193, 1159, 572, 1612, 411, 904, + /* 490 */ 192, 554, 358, 569, 554, 940, 537, 521, 1159, 437, + /* 500 */ 415, 1159, 556, 1193, 1194, 1193, 572, 548, 548, 52, + /* 510 */ 52, 216, 126, 127, 81, 1217, 1217, 1054, 1057, 1044, + /* 520 */ 1044, 124, 124, 125, 125, 125, 125, 1193, 478, 136, + /* 530 */ 136, 411, 286, 286, 1493, 509, 122, 122, 121, 121, + /* 540 */ 121, 120, 117, 448, 1010, 569, 522, 219, 545, 545, + /* 550 */ 318, 563, 143, 6, 536, 126, 127, 81, 1217, 1217, + /* 560 */ 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, 125, + /* 570 */ 1557, 123, 123, 123, 123, 122, 122, 121, 121, 121, + /* 580 */ 120, 117, 448, 489, 1193, 1194, 1193, 486, 283, 1270, + /* 590 */ 960, 254, 1193, 375, 508, 505, 504, 1193, 342, 574, + /* 600 */ 1193, 574, 411, 294, 503, 960, 879, 193, 484, 318, + /* 610 */ 563, 386, 292, 382, 123, 123, 123, 123, 122, 122, + /* 620 */ 121, 121, 121, 120, 117, 448, 126, 127, 81, 1217, + /* 630 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, + /* 640 */ 125, 411, 396, 1139, 1193, 872, 101, 286, 286, 1193, + /* 650 */ 1194, 1193, 375, 1096, 1193, 1194, 1193, 1193, 1194, 1193, + /* 660 */ 569, 459, 33, 375, 235, 126, 127, 81, 1217, 1217, + /* 670 */ 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, 125, + /* 680 */ 1437, 962, 572, 230, 961, 123, 123, 123, 123, 122, + /* 690 */ 122, 121, 121, 121, 120, 117, 448, 1159, 230, 1193, + /* 700 */ 158, 1193, 1194, 1193, 1556, 13, 13, 303, 960, 1233, + /* 710 */ 1159, 154, 411, 1159, 375, 1584, 1177, 5, 371, 1581, + /* 720 */ 431, 1239, 3, 960, 123, 123, 123, 123, 122, 122, + /* 730 */ 121, 121, 121, 120, 117, 448, 126, 127, 81, 1217, + /* 740 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, + /* 750 */ 125, 411, 210, 571, 1193, 1032, 1193, 1194, 1193, 1193, + /* 760 */ 390, 855, 156, 1555, 376, 404, 1101, 1101, 492, 572, + /* 770 */ 469, 344, 1322, 1322, 1555, 126, 127, 81, 1217, 1217, + /* 780 */ 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, 125, + /* 790 */ 130, 572, 13, 13, 532, 123, 123, 123, 123, 122, + /* 800 */ 122, 121, 121, 121, 120, 117, 448, 304, 572, 457, + /* 810 */ 229, 1193, 1194, 1193, 13, 13, 1193, 1194, 1193, 1300, + /* 820 */ 467, 1270, 411, 1320, 1320, 1555, 1015, 457, 456, 436, + /* 830 */ 301, 72, 72, 1268, 123, 123, 123, 123, 122, 122, + /* 840 */ 121, 121, 121, 120, 117, 448, 126, 127, 81, 1217, + /* 850 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, + /* 860 */ 125, 411, 384, 1076, 1159, 286, 286, 421, 314, 280, + /* 870 */ 280, 287, 287, 461, 408, 407, 1539, 1159, 569, 572, + /* 880 */ 1159, 1196, 569, 409, 569, 126, 127, 81, 1217, 1217, + /* 890 */ 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, 125, + /* 900 */ 457, 1485, 13, 13, 1541, 123, 123, 123, 123, 122, + /* 910 */ 122, 121, 121, 121, 120, 117, 448, 202, 572, 462, + /* 920 */ 1587, 578, 2, 1248, 843, 844, 845, 1563, 319, 409, + /* 930 */ 147, 6, 411, 257, 256, 255, 208, 1330, 9, 1196, + /* 940 */ 264, 72, 72, 1436, 123, 123, 123, 123, 122, 122, + /* 950 */ 121, 121, 121, 120, 117, 448, 126, 127, 81, 1217, + /* 960 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, + /* 970 */ 125, 572, 286, 286, 572, 1213, 411, 577, 315, 1248, + /* 980 */ 421, 371, 1581, 356, 319, 569, 147, 495, 529, 1644, + /* 990 */ 397, 935, 495, 1330, 71, 71, 934, 72, 72, 242, + /* 1000 */ 1328, 105, 81, 1217, 1217, 1054, 1057, 1044, 1044, 124, + /* 1010 */ 124, 125, 125, 125, 125, 123, 123, 123, 123, 122, + /* 1020 */ 122, 121, 121, 121, 120, 117, 448, 1117, 286, 286, + /* 1030 */ 1422, 452, 1528, 1213, 443, 286, 286, 1492, 1355, 313, + /* 1040 */ 478, 569, 1118, 454, 351, 495, 354, 1266, 569, 209, + /* 1050 */ 572, 418, 179, 572, 1031, 242, 385, 1119, 523, 123, + /* 1060 */ 123, 123, 123, 122, 122, 121, 121, 121, 120, 117, + /* 1070 */ 448, 1020, 108, 72, 72, 1019, 13, 13, 915, 572, + /* 1080 */ 1498, 572, 286, 286, 98, 530, 1537, 452, 916, 1334, + /* 1090 */ 1329, 203, 411, 286, 286, 569, 152, 211, 1498, 1500, + /* 1100 */ 426, 569, 56, 56, 57, 57, 569, 1019, 1019, 1021, + /* 1110 */ 447, 572, 411, 531, 12, 297, 126, 127, 81, 1217, + /* 1120 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, + /* 1130 */ 125, 572, 411, 867, 15, 15, 126, 127, 81, 1217, + /* 1140 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, + /* 1150 */ 125, 373, 529, 264, 44, 44, 126, 115, 81, 1217, + /* 1160 */ 1217, 1054, 1057, 1044, 1044, 124, 124, 125, 125, 125, + /* 1170 */ 125, 1498, 478, 1271, 417, 123, 123, 123, 123, 122, + /* 1180 */ 122, 121, 121, 121, 120, 117, 448, 205, 1213, 495, + /* 1190 */ 430, 867, 468, 322, 495, 123, 123, 123, 123, 122, + /* 1200 */ 122, 121, 121, 121, 120, 117, 448, 572, 557, 1140, + /* 1210 */ 1642, 1422, 1642, 543, 572, 123, 123, 123, 123, 122, + /* 1220 */ 122, 121, 121, 121, 120, 117, 448, 572, 1422, 572, + /* 1230 */ 13, 13, 542, 323, 1325, 411, 334, 58, 58, 349, + /* 1240 */ 1422, 1170, 326, 286, 286, 549, 1213, 300, 895, 530, + /* 1250 */ 45, 45, 59, 59, 1140, 1643, 569, 1643, 565, 417, + /* 1260 */ 127, 81, 1217, 1217, 1054, 1057, 1044, 1044, 124, 124, + /* 1270 */ 125, 125, 125, 125, 1367, 373, 500, 290, 1193, 512, + /* 1280 */ 1366, 427, 394, 394, 393, 275, 391, 896, 1138, 852, + /* 1290 */ 478, 258, 1422, 1170, 463, 1159, 12, 331, 428, 333, + /* 1300 */ 1117, 460, 236, 258, 325, 460, 544, 1544, 1159, 1098, + /* 1310 */ 491, 1159, 324, 1098, 440, 1118, 335, 516, 123, 123, + /* 1320 */ 123, 123, 122, 122, 121, 121, 121, 120, 117, 448, + /* 1330 */ 1119, 318, 563, 1138, 572, 1193, 1194, 1193, 112, 564, + /* 1340 */ 201, 4, 238, 433, 935, 490, 285, 228, 1517, 934, + /* 1350 */ 170, 560, 572, 142, 1516, 567, 572, 60, 60, 572, + /* 1360 */ 416, 572, 441, 572, 535, 302, 875, 8, 487, 572, + /* 1370 */ 237, 572, 416, 572, 485, 61, 61, 572, 449, 62, + /* 1380 */ 62, 332, 63, 63, 46, 46, 47, 47, 361, 572, + /* 1390 */ 561, 572, 48, 48, 50, 50, 51, 51, 572, 295, + /* 1400 */ 64, 64, 482, 295, 539, 412, 471, 1031, 572, 538, + /* 1410 */ 318, 563, 65, 65, 66, 66, 409, 475, 572, 1031, + /* 1420 */ 572, 14, 14, 875, 1020, 110, 110, 409, 1019, 572, + /* 1430 */ 474, 67, 67, 111, 455, 449, 573, 449, 98, 317, + /* 1440 */ 1019, 132, 132, 133, 133, 572, 1561, 572, 974, 409, + /* 1450 */ 6, 1562, 68, 68, 1560, 6, 975, 572, 6, 1559, + /* 1460 */ 1019, 1019, 1021, 6, 346, 218, 101, 531, 53, 53, + /* 1470 */ 69, 69, 1019, 1019, 1021, 1022, 28, 1586, 1181, 451, + /* 1480 */ 70, 70, 290, 87, 215, 31, 1363, 394, 394, 393, + /* 1490 */ 275, 391, 350, 109, 852, 107, 572, 112, 564, 483, + /* 1500 */ 4, 1212, 572, 239, 153, 572, 39, 236, 1299, 325, + /* 1510 */ 112, 564, 1298, 4, 567, 572, 32, 324, 572, 54, + /* 1520 */ 54, 572, 1135, 353, 398, 165, 165, 567, 166, 166, + /* 1530 */ 572, 291, 355, 572, 17, 357, 572, 449, 77, 77, + /* 1540 */ 1313, 55, 55, 1297, 73, 73, 572, 238, 470, 561, + /* 1550 */ 449, 472, 364, 135, 135, 170, 74, 74, 142, 163, + /* 1560 */ 163, 374, 561, 539, 572, 321, 572, 886, 540, 137, + /* 1570 */ 137, 339, 1353, 422, 298, 237, 539, 572, 1031, 572, + /* 1580 */ 340, 538, 101, 369, 110, 110, 162, 131, 131, 164, + /* 1590 */ 164, 1031, 111, 368, 449, 573, 449, 110, 110, 1019, + /* 1600 */ 157, 157, 141, 141, 572, 111, 572, 449, 573, 449, + /* 1610 */ 412, 288, 1019, 572, 882, 318, 563, 572, 219, 572, + /* 1620 */ 241, 1012, 477, 263, 263, 894, 893, 140, 140, 138, + /* 1630 */ 138, 1019, 1019, 1021, 1022, 28, 139, 139, 525, 455, + /* 1640 */ 76, 76, 78, 78, 1019, 1019, 1021, 1022, 28, 1181, + /* 1650 */ 451, 572, 1083, 290, 112, 564, 1575, 4, 394, 394, + /* 1660 */ 393, 275, 391, 572, 1023, 852, 572, 479, 345, 263, + /* 1670 */ 101, 567, 882, 1376, 75, 75, 1421, 501, 236, 260, + /* 1680 */ 325, 112, 564, 359, 4, 101, 43, 43, 324, 49, + /* 1690 */ 49, 901, 902, 161, 449, 101, 977, 978, 567, 1079, + /* 1700 */ 1349, 260, 965, 932, 263, 114, 561, 1095, 517, 1095, + /* 1710 */ 1083, 1094, 865, 1094, 151, 933, 1144, 114, 238, 1361, + /* 1720 */ 558, 449, 1023, 559, 1426, 1278, 170, 1269, 1257, 142, + /* 1730 */ 1601, 1256, 1258, 561, 1594, 1031, 496, 278, 213, 1346, + /* 1740 */ 310, 110, 110, 939, 311, 312, 237, 11, 234, 111, + /* 1750 */ 221, 449, 573, 449, 293, 395, 1019, 1408, 337, 1403, + /* 1760 */ 1396, 338, 1031, 299, 343, 1413, 1412, 481, 110, 110, + /* 1770 */ 506, 402, 225, 1296, 206, 367, 111, 1358, 449, 573, + /* 1780 */ 449, 412, 1359, 1019, 1489, 1488, 318, 563, 1019, 1019, + /* 1790 */ 1021, 1022, 28, 562, 207, 220, 80, 564, 389, 4, + /* 1800 */ 1597, 1357, 552, 1356, 1233, 181, 267, 232, 1536, 1534, + /* 1810 */ 455, 1230, 420, 567, 82, 1019, 1019, 1021, 1022, 28, + /* 1820 */ 86, 217, 85, 1494, 190, 175, 183, 465, 185, 466, + /* 1830 */ 36, 1409, 186, 187, 188, 499, 449, 244, 37, 99, + /* 1840 */ 400, 1415, 1414, 488, 1417, 194, 473, 403, 561, 1483, + /* 1850 */ 248, 92, 1505, 494, 198, 279, 112, 564, 250, 4, + /* 1860 */ 348, 497, 405, 352, 1259, 251, 252, 515, 1316, 434, + /* 1870 */ 1315, 1314, 94, 567, 1307, 886, 1306, 1031, 226, 406, + /* 1880 */ 1611, 1610, 438, 110, 110, 1580, 1286, 524, 439, 308, + /* 1890 */ 266, 111, 1285, 449, 573, 449, 449, 309, 1019, 366, + /* 1900 */ 1284, 1609, 265, 1566, 1565, 442, 372, 1381, 561, 129, + /* 1910 */ 550, 1380, 10, 1470, 383, 106, 316, 551, 100, 35, + /* 1920 */ 534, 575, 212, 1339, 381, 387, 1187, 1338, 274, 276, + /* 1930 */ 1019, 1019, 1021, 1022, 28, 277, 413, 1031, 576, 1254, + /* 1940 */ 388, 1521, 1249, 110, 110, 167, 1522, 168, 148, 1520, + /* 1950 */ 1519, 111, 306, 449, 573, 449, 222, 223, 1019, 839, + /* 1960 */ 169, 79, 450, 214, 414, 233, 320, 145, 1093, 1091, + /* 1970 */ 328, 182, 171, 1212, 918, 184, 240, 336, 243, 1107, + /* 1980 */ 189, 172, 173, 423, 425, 88, 180, 191, 89, 90, + /* 1990 */ 1019, 1019, 1021, 1022, 28, 91, 174, 1110, 245, 1106, + /* 2000 */ 246, 159, 18, 247, 347, 1099, 263, 195, 1227, 493, + /* 2010 */ 249, 196, 38, 854, 498, 368, 253, 360, 897, 197, + /* 2020 */ 502, 93, 19, 20, 507, 884, 363, 510, 95, 307, + /* 2030 */ 160, 96, 518, 97, 1175, 1060, 1146, 40, 21, 227, + /* 2040 */ 176, 1145, 282, 284, 969, 200, 963, 114, 262, 1165, + /* 2050 */ 22, 23, 24, 1161, 1169, 25, 1163, 1150, 34, 26, + /* 2060 */ 1168, 546, 27, 204, 101, 103, 104, 1074, 7, 1061, + /* 2070 */ 1059, 1063, 1116, 1064, 1115, 268, 269, 29, 41, 270, + /* 2080 */ 1024, 866, 113, 30, 568, 392, 1183, 144, 178, 1182, + /* 2090 */ 271, 928, 1245, 1245, 1245, 1245, 1245, 1245, 1245, 1602, }; static const YYCODETYPE yy_lookahead[] = { /* 0 */ 193, 193, 193, 274, 275, 276, 193, 274, 275, 276, @@ -170102,7 +171186,7 @@ static const YYCODETYPE yy_lookahead[] = { /* 730 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46, /* 740 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, /* 750 */ 57, 19, 193, 193, 59, 23, 116, 117, 118, 59, - /* 760 */ 201, 21, 241, 304, 22, 206, 127, 128, 129, 193, + /* 760 */ 201, 21, 241, 304, 193, 206, 127, 128, 129, 193, /* 770 */ 128, 129, 235, 236, 304, 43, 44, 45, 46, 47, /* 780 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, /* 790 */ 22, 193, 216, 217, 193, 102, 103, 104, 105, 106, @@ -170113,129 +171197,129 @@ static const YYCODETYPE yy_lookahead[] = { /* 840 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46, /* 850 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, /* 860 */ 57, 19, 193, 123, 76, 239, 240, 193, 253, 239, - /* 870 */ 240, 239, 240, 193, 106, 107, 193, 89, 252, 193, - /* 880 */ 92, 59, 252, 141, 252, 43, 44, 45, 46, 47, + /* 870 */ 240, 239, 240, 244, 106, 107, 193, 89, 252, 193, + /* 880 */ 92, 59, 252, 254, 252, 43, 44, 45, 46, 47, /* 890 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, /* 900 */ 284, 161, 216, 217, 193, 102, 103, 104, 105, 106, - /* 910 */ 107, 108, 109, 110, 111, 112, 113, 231, 193, 16, - /* 920 */ 187, 188, 189, 190, 7, 8, 9, 309, 195, 25, + /* 910 */ 107, 108, 109, 110, 111, 112, 113, 231, 193, 244, + /* 920 */ 187, 188, 189, 190, 7, 8, 9, 309, 195, 254, /* 930 */ 197, 313, 19, 127, 128, 129, 262, 204, 22, 117, - /* 940 */ 24, 216, 217, 263, 102, 103, 104, 105, 106, 107, + /* 940 */ 24, 216, 217, 273, 102, 103, 104, 105, 106, 107, /* 950 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46, /* 960 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, /* 970 */ 57, 193, 239, 240, 193, 59, 19, 188, 253, 190, - /* 980 */ 77, 226, 79, 193, 195, 252, 197, 193, 19, 301, - /* 990 */ 302, 193, 193, 204, 216, 217, 226, 216, 217, 266, + /* 980 */ 193, 311, 312, 16, 195, 252, 197, 193, 19, 301, + /* 990 */ 302, 135, 193, 204, 216, 217, 140, 216, 217, 266, /* 1000 */ 204, 159, 45, 46, 47, 48, 49, 50, 51, 52, /* 1010 */ 53, 54, 55, 56, 57, 102, 103, 104, 105, 106, /* 1020 */ 107, 108, 109, 110, 111, 112, 113, 12, 239, 240, - /* 1030 */ 232, 298, 238, 117, 253, 239, 240, 238, 259, 260, - /* 1040 */ 193, 252, 27, 31, 193, 193, 142, 204, 252, 193, - /* 1050 */ 193, 39, 262, 193, 100, 266, 278, 42, 204, 102, + /* 1030 */ 193, 298, 238, 117, 253, 239, 240, 238, 259, 260, + /* 1040 */ 193, 252, 27, 193, 77, 193, 79, 204, 252, 262, + /* 1050 */ 193, 299, 300, 193, 100, 266, 278, 42, 204, 102, /* 1060 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, /* 1070 */ 113, 117, 159, 216, 217, 121, 216, 217, 63, 193, - /* 1080 */ 193, 193, 239, 240, 115, 116, 193, 298, 73, 238, + /* 1080 */ 193, 193, 239, 240, 115, 116, 193, 298, 73, 240, /* 1090 */ 238, 231, 19, 239, 240, 252, 22, 24, 211, 212, - /* 1100 */ 24, 193, 216, 217, 216, 217, 252, 153, 154, 155, - /* 1110 */ 253, 16, 19, 144, 213, 268, 43, 44, 45, 46, + /* 1100 */ 263, 252, 216, 217, 216, 217, 252, 153, 154, 155, + /* 1110 */ 253, 193, 19, 144, 213, 268, 43, 44, 45, 46, /* 1120 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, - /* 1130 */ 57, 238, 19, 59, 193, 59, 43, 44, 45, 46, + /* 1130 */ 57, 193, 19, 59, 216, 217, 43, 44, 45, 46, /* 1140 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, - /* 1150 */ 57, 22, 23, 193, 25, 193, 43, 44, 45, 46, + /* 1150 */ 57, 193, 19, 24, 216, 217, 43, 44, 45, 46, /* 1160 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, - /* 1170 */ 57, 284, 77, 193, 79, 102, 103, 104, 105, 106, - /* 1180 */ 107, 108, 109, 110, 111, 112, 113, 286, 193, 193, - /* 1190 */ 193, 117, 291, 117, 232, 102, 103, 104, 105, 106, - /* 1200 */ 107, 108, 109, 110, 111, 112, 113, 204, 22, 23, - /* 1210 */ 66, 25, 216, 217, 35, 102, 103, 104, 105, 106, - /* 1220 */ 107, 108, 109, 110, 111, 112, 113, 193, 268, 85, - /* 1230 */ 101, 193, 309, 309, 240, 19, 313, 313, 94, 208, - /* 1240 */ 209, 193, 239, 240, 193, 66, 252, 19, 268, 244, - /* 1250 */ 216, 217, 193, 74, 213, 252, 161, 19, 263, 254, + /* 1170 */ 57, 284, 193, 208, 209, 102, 103, 104, 105, 106, + /* 1180 */ 107, 108, 109, 110, 111, 112, 113, 286, 59, 193, + /* 1190 */ 232, 117, 291, 193, 193, 102, 103, 104, 105, 106, + /* 1200 */ 107, 108, 109, 110, 111, 112, 113, 193, 204, 22, + /* 1210 */ 23, 193, 25, 66, 193, 102, 103, 104, 105, 106, + /* 1220 */ 107, 108, 109, 110, 111, 112, 113, 193, 193, 193, + /* 1230 */ 216, 217, 85, 193, 238, 19, 16, 216, 217, 238, + /* 1240 */ 193, 94, 193, 239, 240, 231, 117, 268, 35, 116, + /* 1250 */ 216, 217, 216, 217, 22, 23, 252, 25, 208, 209, /* 1260 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, - /* 1270 */ 54, 55, 56, 57, 193, 216, 217, 5, 59, 193, - /* 1280 */ 19, 244, 10, 11, 12, 13, 14, 101, 309, 17, - /* 1290 */ 146, 254, 313, 193, 193, 76, 115, 216, 217, 309, - /* 1300 */ 12, 263, 30, 313, 32, 46, 87, 46, 89, 130, - /* 1310 */ 193, 92, 40, 22, 263, 27, 216, 217, 102, 103, + /* 1270 */ 54, 55, 56, 57, 193, 193, 19, 5, 59, 66, + /* 1280 */ 193, 263, 10, 11, 12, 13, 14, 74, 101, 17, + /* 1290 */ 193, 46, 193, 146, 193, 76, 213, 77, 263, 79, + /* 1300 */ 12, 260, 30, 46, 32, 264, 87, 193, 89, 29, + /* 1310 */ 263, 92, 40, 33, 232, 27, 193, 108, 102, 103, /* 1320 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, - /* 1330 */ 42, 150, 291, 216, 217, 116, 117, 118, 19, 20, - /* 1340 */ 193, 22, 70, 260, 116, 193, 24, 264, 193, 263, - /* 1350 */ 78, 63, 61, 81, 116, 36, 193, 260, 193, 29, - /* 1360 */ 193, 264, 193, 33, 145, 193, 59, 48, 216, 217, - /* 1370 */ 98, 216, 217, 193, 115, 193, 115, 193, 59, 216, - /* 1380 */ 217, 216, 217, 216, 217, 216, 217, 255, 216, 217, - /* 1390 */ 71, 193, 131, 193, 25, 65, 216, 217, 216, 217, - /* 1400 */ 216, 217, 208, 209, 85, 133, 193, 100, 193, 90, - /* 1410 */ 138, 139, 138, 139, 216, 217, 216, 217, 193, 100, - /* 1420 */ 193, 108, 135, 116, 117, 106, 107, 140, 121, 216, - /* 1430 */ 217, 216, 217, 114, 162, 116, 117, 118, 299, 300, - /* 1440 */ 121, 216, 217, 216, 217, 193, 244, 193, 135, 244, - /* 1450 */ 193, 256, 257, 140, 244, 193, 254, 193, 193, 254, - /* 1460 */ 153, 154, 155, 141, 254, 149, 150, 258, 216, 217, + /* 1330 */ 42, 138, 139, 101, 193, 116, 117, 118, 19, 20, + /* 1340 */ 255, 22, 70, 130, 135, 65, 256, 257, 193, 140, + /* 1350 */ 78, 63, 193, 81, 193, 36, 193, 216, 217, 193, + /* 1360 */ 115, 193, 263, 193, 145, 268, 59, 48, 193, 193, + /* 1370 */ 98, 193, 115, 193, 291, 216, 217, 193, 59, 216, + /* 1380 */ 217, 161, 216, 217, 216, 217, 216, 217, 131, 193, + /* 1390 */ 71, 193, 216, 217, 216, 217, 216, 217, 193, 260, + /* 1400 */ 216, 217, 19, 264, 85, 133, 244, 100, 193, 90, + /* 1410 */ 138, 139, 216, 217, 216, 217, 254, 244, 193, 100, + /* 1420 */ 193, 216, 217, 116, 117, 106, 107, 254, 121, 193, + /* 1430 */ 115, 216, 217, 114, 162, 116, 117, 118, 115, 244, + /* 1440 */ 121, 216, 217, 216, 217, 193, 309, 193, 31, 254, + /* 1450 */ 313, 309, 216, 217, 309, 313, 39, 193, 313, 309, + /* 1460 */ 153, 154, 155, 313, 193, 150, 25, 144, 216, 217, /* 1470 */ 216, 217, 153, 154, 155, 156, 157, 0, 1, 2, - /* 1480 */ 216, 217, 5, 115, 158, 193, 160, 10, 11, 12, - /* 1490 */ 13, 14, 193, 59, 17, 126, 193, 19, 20, 129, - /* 1500 */ 22, 193, 22, 22, 24, 193, 23, 30, 25, 32, - /* 1510 */ 19, 20, 144, 22, 36, 216, 217, 40, 193, 216, - /* 1520 */ 217, 193, 152, 129, 216, 217, 193, 36, 216, 217, - /* 1530 */ 193, 99, 193, 193, 53, 193, 193, 59, 23, 193, - /* 1540 */ 25, 216, 217, 193, 216, 217, 152, 70, 59, 71, - /* 1550 */ 59, 117, 193, 216, 217, 78, 216, 217, 81, 216, - /* 1560 */ 217, 318, 71, 85, 193, 133, 193, 193, 90, 23, - /* 1570 */ 23, 25, 25, 120, 121, 98, 85, 193, 100, 193, - /* 1580 */ 23, 90, 25, 121, 106, 107, 19, 216, 217, 216, + /* 1480 */ 216, 217, 5, 149, 150, 22, 193, 10, 11, 12, + /* 1490 */ 13, 14, 193, 158, 17, 160, 193, 19, 20, 116, + /* 1500 */ 22, 25, 193, 24, 22, 193, 24, 30, 226, 32, + /* 1510 */ 19, 20, 226, 22, 36, 193, 53, 40, 193, 216, + /* 1520 */ 217, 193, 23, 193, 25, 216, 217, 36, 216, 217, + /* 1530 */ 193, 99, 193, 193, 22, 193, 193, 59, 216, 217, + /* 1540 */ 193, 216, 217, 193, 216, 217, 193, 70, 129, 71, + /* 1550 */ 59, 129, 193, 216, 217, 78, 216, 217, 81, 216, + /* 1560 */ 217, 193, 71, 85, 193, 133, 193, 126, 90, 216, + /* 1570 */ 217, 152, 258, 61, 152, 98, 85, 193, 100, 193, + /* 1580 */ 23, 90, 25, 121, 106, 107, 23, 216, 217, 216, /* 1590 */ 217, 100, 114, 131, 116, 117, 118, 106, 107, 121, - /* 1600 */ 216, 217, 216, 217, 193, 114, 117, 116, 117, 118, - /* 1610 */ 133, 193, 121, 193, 193, 138, 139, 193, 23, 193, - /* 1620 */ 25, 23, 23, 25, 25, 7, 8, 216, 217, 193, - /* 1630 */ 193, 153, 154, 155, 156, 157, 216, 217, 193, 162, + /* 1600 */ 216, 217, 216, 217, 193, 114, 193, 116, 117, 118, + /* 1610 */ 133, 22, 121, 193, 59, 138, 139, 193, 142, 193, + /* 1620 */ 141, 23, 23, 25, 25, 120, 121, 216, 217, 216, + /* 1630 */ 217, 153, 154, 155, 156, 157, 216, 217, 19, 162, /* 1640 */ 216, 217, 216, 217, 153, 154, 155, 156, 157, 1, - /* 1650 */ 2, 193, 193, 5, 19, 20, 59, 22, 10, 11, - /* 1660 */ 12, 13, 14, 193, 97, 17, 193, 23, 193, 25, - /* 1670 */ 288, 36, 193, 242, 216, 217, 236, 23, 30, 25, + /* 1650 */ 2, 193, 59, 5, 19, 20, 318, 22, 10, 11, + /* 1660 */ 12, 13, 14, 193, 59, 17, 193, 23, 23, 25, + /* 1670 */ 25, 36, 117, 193, 216, 217, 193, 23, 30, 25, /* 1680 */ 32, 19, 20, 23, 22, 25, 216, 217, 40, 216, - /* 1690 */ 217, 216, 217, 193, 59, 216, 217, 193, 36, 83, - /* 1700 */ 84, 153, 153, 155, 155, 23, 71, 25, 23, 193, - /* 1710 */ 25, 193, 193, 193, 117, 193, 193, 193, 70, 193, - /* 1720 */ 193, 59, 193, 255, 255, 287, 78, 255, 243, 81, - /* 1730 */ 191, 255, 297, 71, 271, 100, 293, 245, 267, 214, - /* 1740 */ 246, 106, 107, 108, 246, 271, 98, 245, 293, 114, - /* 1750 */ 220, 116, 117, 118, 267, 271, 121, 271, 225, 219, - /* 1760 */ 229, 219, 100, 219, 259, 259, 259, 259, 106, 107, - /* 1770 */ 249, 196, 60, 280, 141, 243, 114, 249, 116, 117, - /* 1780 */ 118, 133, 245, 121, 200, 297, 138, 139, 153, 154, - /* 1790 */ 155, 156, 157, 297, 200, 38, 19, 20, 151, 22, - /* 1800 */ 200, 150, 140, 294, 294, 22, 272, 43, 234, 18, - /* 1810 */ 162, 270, 200, 36, 237, 153, 154, 155, 156, 157, - /* 1820 */ 237, 283, 237, 237, 18, 199, 149, 246, 272, 270, - /* 1830 */ 272, 200, 158, 246, 246, 234, 59, 234, 246, 199, - /* 1840 */ 290, 62, 289, 200, 199, 22, 221, 115, 71, 200, - /* 1850 */ 200, 199, 199, 221, 218, 218, 19, 20, 64, 22, - /* 1860 */ 218, 227, 22, 224, 126, 224, 165, 221, 24, 305, - /* 1870 */ 200, 113, 312, 36, 218, 220, 218, 100, 282, 218, - /* 1880 */ 91, 218, 317, 106, 107, 221, 227, 282, 317, 82, - /* 1890 */ 148, 114, 265, 116, 117, 118, 59, 145, 121, 22, - /* 1900 */ 277, 158, 200, 265, 25, 202, 147, 250, 71, 279, - /* 1910 */ 13, 146, 194, 194, 249, 248, 250, 140, 247, 246, - /* 1920 */ 6, 192, 192, 192, 303, 303, 213, 207, 300, 213, - /* 1930 */ 153, 154, 155, 156, 157, 213, 213, 100, 213, 222, - /* 1940 */ 207, 214, 214, 106, 107, 4, 222, 207, 3, 22, - /* 1950 */ 163, 114, 15, 116, 117, 118, 16, 23, 121, 23, - /* 1960 */ 139, 151, 130, 25, 142, 16, 24, 20, 144, 1, - /* 1970 */ 142, 130, 130, 61, 53, 53, 37, 151, 53, 53, - /* 1980 */ 130, 116, 34, 1, 141, 5, 22, 115, 161, 141, - /* 1990 */ 153, 154, 155, 156, 157, 25, 68, 68, 75, 41, - /* 2000 */ 115, 24, 131, 20, 19, 125, 22, 96, 22, 22, - /* 2010 */ 67, 23, 22, 67, 59, 24, 22, 28, 67, 23, - /* 2020 */ 22, 22, 149, 23, 23, 23, 116, 23, 25, 37, - /* 2030 */ 97, 141, 23, 23, 22, 143, 25, 75, 88, 34, - /* 2040 */ 34, 34, 34, 86, 75, 93, 23, 34, 22, 34, - /* 2050 */ 25, 24, 34, 25, 23, 142, 23, 142, 44, 23, - /* 2060 */ 23, 23, 11, 23, 25, 22, 22, 22, 15, 23, - /* 2070 */ 23, 22, 22, 25, 1, 1, 141, 25, 23, 135, - /* 2080 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, - /* 2090 */ 319, 319, 319, 319, 141, 141, 319, 319, 319, 319, + /* 1690 */ 217, 7, 8, 23, 59, 25, 83, 84, 36, 23, + /* 1700 */ 193, 25, 23, 23, 25, 25, 71, 153, 145, 155, + /* 1710 */ 117, 153, 23, 155, 25, 23, 97, 25, 70, 193, + /* 1720 */ 193, 59, 117, 236, 193, 193, 78, 193, 193, 81, + /* 1730 */ 141, 193, 193, 71, 193, 100, 288, 287, 242, 255, + /* 1740 */ 255, 106, 107, 108, 255, 255, 98, 243, 297, 114, + /* 1750 */ 214, 116, 117, 118, 245, 191, 121, 271, 293, 267, + /* 1760 */ 267, 246, 100, 246, 245, 271, 271, 293, 106, 107, + /* 1770 */ 220, 271, 229, 225, 249, 219, 114, 259, 116, 117, + /* 1780 */ 118, 133, 259, 121, 219, 219, 138, 139, 153, 154, + /* 1790 */ 155, 156, 157, 280, 249, 243, 19, 20, 245, 22, + /* 1800 */ 196, 259, 140, 259, 60, 297, 141, 297, 200, 200, + /* 1810 */ 162, 38, 200, 36, 294, 153, 154, 155, 156, 157, + /* 1820 */ 151, 150, 294, 283, 22, 43, 234, 18, 237, 200, + /* 1830 */ 270, 272, 237, 237, 237, 18, 59, 199, 270, 149, + /* 1840 */ 246, 272, 272, 200, 234, 234, 246, 246, 71, 246, + /* 1850 */ 199, 158, 290, 62, 22, 200, 19, 20, 199, 22, + /* 1860 */ 289, 221, 221, 200, 200, 199, 199, 115, 218, 64, + /* 1870 */ 218, 218, 22, 36, 227, 126, 227, 100, 165, 221, + /* 1880 */ 224, 224, 24, 106, 107, 312, 218, 305, 113, 282, + /* 1890 */ 91, 114, 220, 116, 117, 118, 59, 282, 121, 218, + /* 1900 */ 218, 218, 200, 317, 317, 82, 221, 265, 71, 148, + /* 1910 */ 145, 265, 22, 277, 200, 158, 279, 140, 147, 25, + /* 1920 */ 146, 202, 248, 250, 249, 247, 13, 250, 194, 194, + /* 1930 */ 153, 154, 155, 156, 157, 6, 303, 100, 192, 192, + /* 1940 */ 246, 213, 192, 106, 107, 207, 213, 207, 222, 213, + /* 1950 */ 213, 114, 222, 116, 117, 118, 214, 214, 121, 4, + /* 1960 */ 207, 213, 3, 22, 303, 15, 163, 16, 23, 23, + /* 1970 */ 139, 151, 130, 25, 20, 142, 24, 16, 144, 1, + /* 1980 */ 142, 130, 130, 61, 37, 53, 300, 151, 53, 53, + /* 1990 */ 153, 154, 155, 156, 157, 53, 130, 116, 34, 1, + /* 2000 */ 141, 5, 22, 115, 161, 68, 25, 68, 75, 41, + /* 2010 */ 141, 115, 24, 20, 19, 131, 125, 23, 28, 22, + /* 2020 */ 67, 22, 22, 22, 67, 59, 24, 96, 22, 67, + /* 2030 */ 23, 149, 22, 25, 23, 23, 23, 22, 34, 141, + /* 2040 */ 37, 97, 23, 23, 116, 22, 143, 25, 34, 75, + /* 2050 */ 34, 34, 34, 88, 75, 34, 86, 23, 22, 34, + /* 2060 */ 93, 24, 34, 25, 25, 142, 142, 23, 44, 23, + /* 2070 */ 23, 23, 23, 11, 23, 25, 22, 22, 22, 141, + /* 2080 */ 23, 23, 22, 22, 25, 15, 1, 23, 25, 1, + /* 2090 */ 141, 135, 319, 319, 319, 319, 319, 319, 319, 141, /* 2100 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, /* 2110 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, /* 2120 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, @@ -170254,176 +171338,177 @@ static const YYCODETYPE yy_lookahead[] = { /* 2250 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, /* 2260 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, /* 2270 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319, - /* 2280 */ 319, + /* 2280 */ 319, 319, 319, 319, 319, }; -#define YY_SHIFT_COUNT (574) +#define YY_SHIFT_COUNT (578) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (2074) +#define YY_SHIFT_MAX (2088) static const unsigned short int yy_shift_ofst[] = { /* 0 */ 1648, 1477, 1272, 322, 322, 1, 1319, 1478, 1491, 1837, /* 10 */ 1837, 1837, 471, 0, 0, 214, 1093, 1837, 1837, 1837, /* 20 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, - /* 30 */ 271, 271, 1219, 1219, 216, 88, 1, 1, 1, 1, - /* 40 */ 1, 40, 111, 258, 361, 469, 512, 583, 622, 693, - /* 50 */ 732, 803, 842, 913, 1073, 1093, 1093, 1093, 1093, 1093, + /* 30 */ 1837, 271, 271, 1219, 1219, 216, 88, 1, 1, 1, + /* 40 */ 1, 1, 40, 111, 258, 361, 469, 512, 583, 622, + /* 50 */ 693, 732, 803, 842, 913, 1073, 1093, 1093, 1093, 1093, /* 60 */ 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, - /* 70 */ 1093, 1093, 1093, 1113, 1093, 1216, 957, 957, 1635, 1662, - /* 80 */ 1777, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, + /* 70 */ 1093, 1093, 1093, 1093, 1113, 1093, 1216, 957, 957, 1635, + /* 80 */ 1662, 1777, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, /* 90 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, /* 100 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, /* 110 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, /* 120 */ 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, 1837, - /* 130 */ 137, 181, 181, 181, 181, 181, 181, 181, 94, 430, - /* 140 */ 66, 65, 112, 366, 533, 533, 740, 1261, 533, 533, - /* 150 */ 79, 79, 533, 412, 412, 412, 77, 412, 123, 113, - /* 160 */ 113, 22, 22, 2096, 2096, 328, 328, 328, 239, 468, - /* 170 */ 468, 468, 468, 1015, 1015, 409, 366, 1129, 1186, 533, - /* 180 */ 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, - /* 190 */ 533, 533, 533, 533, 533, 533, 533, 533, 533, 969, - /* 200 */ 621, 621, 533, 642, 788, 788, 1228, 1228, 822, 822, - /* 210 */ 67, 1274, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 1307, - /* 220 */ 954, 954, 585, 472, 640, 387, 695, 538, 541, 700, - /* 230 */ 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, - /* 240 */ 222, 533, 533, 533, 533, 533, 533, 533, 533, 533, - /* 250 */ 533, 533, 533, 1179, 1179, 1179, 533, 533, 533, 565, - /* 260 */ 533, 533, 533, 916, 1144, 533, 533, 1288, 533, 533, - /* 270 */ 533, 533, 533, 533, 533, 533, 639, 1330, 209, 1076, - /* 280 */ 1076, 1076, 1076, 580, 209, 209, 1313, 768, 917, 649, - /* 290 */ 1181, 1316, 405, 1316, 1238, 249, 1181, 1181, 249, 1181, - /* 300 */ 405, 1238, 1369, 464, 1259, 1012, 1012, 1012, 1368, 1368, - /* 310 */ 1368, 1368, 184, 184, 1326, 904, 1287, 1480, 1712, 1712, - /* 320 */ 1633, 1633, 1757, 1757, 1633, 1647, 1651, 1783, 1764, 1791, - /* 330 */ 1791, 1791, 1791, 1633, 1806, 1677, 1651, 1651, 1677, 1783, - /* 340 */ 1764, 1677, 1764, 1677, 1633, 1806, 1674, 1779, 1633, 1806, - /* 350 */ 1823, 1633, 1806, 1633, 1806, 1823, 1732, 1732, 1732, 1794, - /* 360 */ 1840, 1840, 1823, 1732, 1738, 1732, 1794, 1732, 1732, 1701, - /* 370 */ 1844, 1758, 1758, 1823, 1633, 1789, 1789, 1807, 1807, 1742, - /* 380 */ 1752, 1877, 1633, 1743, 1742, 1759, 1765, 1677, 1879, 1897, - /* 390 */ 1897, 1914, 1914, 1914, 2096, 2096, 2096, 2096, 2096, 2096, - /* 400 */ 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 207, - /* 410 */ 1095, 331, 620, 903, 806, 1074, 1483, 1432, 1481, 1322, - /* 420 */ 1370, 1394, 1515, 1291, 1546, 1547, 1557, 1595, 1598, 1599, - /* 430 */ 1434, 1453, 1618, 1462, 1567, 1489, 1644, 1654, 1616, 1660, - /* 440 */ 1548, 1549, 1682, 1685, 1597, 742, 1941, 1945, 1927, 1787, - /* 450 */ 1937, 1940, 1934, 1936, 1821, 1810, 1832, 1938, 1938, 1942, - /* 460 */ 1822, 1947, 1824, 1949, 1968, 1828, 1841, 1938, 1842, 1912, - /* 470 */ 1939, 1938, 1826, 1921, 1922, 1925, 1926, 1850, 1865, 1948, - /* 480 */ 1843, 1982, 1980, 1964, 1872, 1827, 1928, 1970, 1929, 1923, - /* 490 */ 1958, 1848, 1885, 1977, 1983, 1985, 1871, 1880, 1984, 1943, - /* 500 */ 1986, 1987, 1988, 1990, 1946, 1955, 1991, 1911, 1989, 1994, - /* 510 */ 1951, 1992, 1996, 1873, 1998, 2000, 2001, 2002, 2003, 2004, - /* 520 */ 1999, 1933, 1890, 2009, 2010, 1910, 2005, 2012, 1892, 2011, - /* 530 */ 2006, 2007, 2008, 2013, 1950, 1962, 1957, 2014, 1969, 1952, - /* 540 */ 2015, 2023, 2026, 2027, 2025, 2028, 2018, 1913, 1915, 2031, - /* 550 */ 2011, 2033, 2036, 2037, 2038, 2039, 2040, 2043, 2051, 2044, - /* 560 */ 2045, 2046, 2047, 2049, 2050, 2048, 1944, 1935, 1953, 1954, - /* 570 */ 2052, 2055, 2053, 2073, 2074, + /* 130 */ 1837, 137, 181, 181, 181, 181, 181, 181, 181, 94, + /* 140 */ 430, 66, 65, 112, 366, 533, 533, 740, 1257, 533, + /* 150 */ 533, 79, 79, 533, 412, 412, 412, 77, 412, 123, + /* 160 */ 113, 113, 113, 22, 22, 2100, 2100, 328, 328, 328, + /* 170 */ 239, 468, 468, 468, 468, 1015, 1015, 409, 366, 1187, + /* 180 */ 1232, 533, 533, 533, 533, 533, 533, 533, 533, 533, + /* 190 */ 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, + /* 200 */ 533, 969, 621, 621, 533, 642, 788, 788, 1133, 1133, + /* 210 */ 822, 822, 67, 1193, 2100, 2100, 2100, 2100, 2100, 2100, + /* 220 */ 2100, 1307, 954, 954, 585, 472, 640, 387, 695, 538, + /* 230 */ 541, 700, 533, 533, 533, 533, 533, 533, 533, 533, + /* 240 */ 533, 533, 222, 533, 533, 533, 533, 533, 533, 533, + /* 250 */ 533, 533, 533, 533, 533, 1213, 1213, 1213, 533, 533, + /* 260 */ 533, 565, 533, 533, 533, 916, 1147, 533, 533, 1288, + /* 270 */ 533, 533, 533, 533, 533, 533, 533, 533, 639, 1280, + /* 280 */ 209, 1129, 1129, 1129, 1129, 580, 209, 209, 1209, 768, + /* 290 */ 917, 649, 1315, 1334, 405, 1334, 1383, 249, 1315, 1315, + /* 300 */ 249, 1315, 405, 1383, 1441, 464, 1245, 1417, 1417, 1417, + /* 310 */ 1323, 1323, 1323, 1323, 184, 184, 1335, 1476, 856, 1482, + /* 320 */ 1744, 1744, 1665, 1665, 1773, 1773, 1665, 1669, 1671, 1802, + /* 330 */ 1782, 1809, 1809, 1809, 1809, 1665, 1817, 1690, 1671, 1671, + /* 340 */ 1690, 1802, 1782, 1690, 1782, 1690, 1665, 1817, 1693, 1791, + /* 350 */ 1665, 1817, 1832, 1665, 1817, 1665, 1817, 1832, 1752, 1752, + /* 360 */ 1752, 1805, 1850, 1850, 1832, 1752, 1749, 1752, 1805, 1752, + /* 370 */ 1752, 1713, 1858, 1775, 1775, 1832, 1665, 1799, 1799, 1823, + /* 380 */ 1823, 1761, 1765, 1890, 1665, 1757, 1761, 1771, 1774, 1690, + /* 390 */ 1894, 1913, 1913, 1929, 1929, 1929, 2100, 2100, 2100, 2100, + /* 400 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, + /* 410 */ 2100, 207, 1220, 331, 620, 967, 806, 1074, 1499, 1432, + /* 420 */ 1463, 1479, 1419, 1422, 1557, 1512, 1598, 1599, 1644, 1645, + /* 430 */ 1654, 1660, 1555, 1505, 1684, 1462, 1670, 1563, 1619, 1593, + /* 440 */ 1676, 1679, 1613, 1680, 1554, 1558, 1689, 1692, 1605, 1589, + /* 450 */ 1955, 1959, 1941, 1803, 1950, 1951, 1945, 1946, 1831, 1820, + /* 460 */ 1842, 1948, 1948, 1952, 1833, 1954, 1834, 1961, 1978, 1838, + /* 470 */ 1851, 1948, 1852, 1922, 1947, 1948, 1836, 1932, 1935, 1936, + /* 480 */ 1942, 1866, 1881, 1964, 1859, 1998, 1996, 1980, 1888, 1843, + /* 490 */ 1937, 1981, 1939, 1933, 1968, 1869, 1896, 1988, 1993, 1995, + /* 500 */ 1884, 1891, 1997, 1953, 1999, 2000, 1994, 2001, 1957, 1966, + /* 510 */ 2002, 1931, 1990, 2006, 1962, 2003, 2007, 2004, 1882, 2010, + /* 520 */ 2011, 2012, 2008, 2013, 2015, 1944, 1898, 2019, 2020, 1928, + /* 530 */ 2014, 2023, 1903, 2022, 2016, 2017, 2018, 2021, 1965, 1974, + /* 540 */ 1970, 2024, 1979, 1967, 2025, 2034, 2036, 2037, 2038, 2039, + /* 550 */ 2028, 1923, 1924, 2044, 2022, 2046, 2047, 2048, 2049, 2050, + /* 560 */ 2051, 2054, 2062, 2055, 2056, 2057, 2058, 2060, 2061, 2059, + /* 570 */ 1956, 1938, 1949, 1958, 2063, 2064, 2070, 2085, 2088, }; -#define YY_REDUCE_COUNT (408) +#define YY_REDUCE_COUNT (410) #define YY_REDUCE_MIN (-271) -#define YY_REDUCE_MAX (1740) +#define YY_REDUCE_MAX (1753) static const short yy_reduce_ofst[] = { /* 0 */ -125, 733, 789, 241, 293, -123, -193, -191, -183, -187, /* 10 */ 166, 238, 133, -207, -199, -267, -176, -6, 204, 489, - /* 20 */ 576, -175, 598, 686, 615, 725, 860, 778, 781, 857, - /* 30 */ 616, 887, 87, 240, -192, 408, 626, 796, 843, 854, - /* 40 */ 1003, -271, -271, -271, -271, -271, -271, -271, -271, -271, + /* 20 */ 576, 598, -175, 686, 860, 615, 725, 1014, 778, 781, + /* 30 */ 857, 616, 887, 87, 240, -192, 408, 626, 796, 843, + /* 40 */ 854, 1004, -271, -271, -271, -271, -271, -271, -271, -271, /* 50 */ -271, -271, -271, -271, -271, -271, -271, -271, -271, -271, /* 60 */ -271, -271, -271, -271, -271, -271, -271, -271, -271, -271, - /* 70 */ -271, -271, -271, -271, -271, -271, -271, -271, 80, 83, - /* 80 */ 313, 886, 888, 996, 1034, 1059, 1081, 1100, 1117, 1152, - /* 90 */ 1155, 1163, 1165, 1167, 1169, 1172, 1180, 1182, 1184, 1198, - /* 100 */ 1200, 1213, 1215, 1225, 1227, 1252, 1254, 1264, 1299, 1303, - /* 110 */ 1308, 1312, 1325, 1328, 1337, 1340, 1343, 1371, 1373, 1384, - /* 120 */ 1386, 1411, 1420, 1424, 1426, 1458, 1470, 1473, 1475, 1479, - /* 130 */ -271, -271, -271, -271, -271, -271, -271, -271, -271, -271, - /* 140 */ -271, 138, 459, 396, -158, 470, 302, -212, 521, 201, - /* 150 */ -195, -92, 559, 630, 632, 630, -271, 632, 901, 63, - /* 160 */ 407, -271, -271, -271, -271, 161, 161, 161, 251, 335, - /* 170 */ 847, 960, 980, 537, 588, 618, 628, 688, 688, -166, - /* 180 */ -161, 674, 790, 794, 799, 851, 852, -122, 680, -120, - /* 190 */ 995, 1038, 415, 1051, 893, 798, 962, 400, 1086, 779, - /* 200 */ 923, 924, 263, 1041, 979, 990, 1083, 1097, 1031, 1194, - /* 210 */ 362, 994, 1139, 1005, 1037, 1202, 1205, 1195, 1210, -194, - /* 220 */ 56, 185, -135, 232, 522, 560, 601, 617, 669, 683, - /* 230 */ 711, 856, 908, 941, 1048, 1101, 1147, 1257, 1262, 1265, - /* 240 */ 392, 1292, 1333, 1339, 1342, 1346, 1350, 1359, 1374, 1418, - /* 250 */ 1421, 1436, 1437, 593, 755, 770, 997, 1445, 1459, 1209, - /* 260 */ 1500, 1504, 1516, 1132, 1243, 1518, 1519, 1440, 1520, 560, - /* 270 */ 1522, 1523, 1524, 1526, 1527, 1529, 1382, 1438, 1431, 1468, - /* 280 */ 1469, 1472, 1476, 1209, 1431, 1431, 1485, 1525, 1539, 1435, - /* 290 */ 1463, 1471, 1492, 1487, 1443, 1494, 1474, 1484, 1498, 1486, - /* 300 */ 1502, 1455, 1530, 1531, 1533, 1540, 1542, 1544, 1505, 1506, - /* 310 */ 1507, 1508, 1521, 1528, 1493, 1537, 1532, 1575, 1488, 1496, - /* 320 */ 1584, 1594, 1509, 1510, 1600, 1538, 1534, 1541, 1574, 1577, - /* 330 */ 1583, 1585, 1586, 1612, 1626, 1581, 1556, 1558, 1587, 1559, - /* 340 */ 1601, 1588, 1603, 1592, 1631, 1640, 1550, 1553, 1643, 1645, - /* 350 */ 1625, 1649, 1652, 1650, 1653, 1632, 1636, 1637, 1642, 1634, - /* 360 */ 1639, 1641, 1646, 1656, 1655, 1658, 1659, 1661, 1663, 1560, - /* 370 */ 1564, 1596, 1605, 1664, 1670, 1565, 1571, 1627, 1638, 1657, - /* 380 */ 1665, 1623, 1702, 1630, 1666, 1667, 1671, 1673, 1703, 1718, - /* 390 */ 1719, 1729, 1730, 1731, 1621, 1622, 1628, 1720, 1713, 1716, - /* 400 */ 1722, 1723, 1733, 1717, 1724, 1727, 1728, 1725, 1740, + /* 70 */ -271, -271, -271, -271, -271, -271, -271, -271, -271, 80, + /* 80 */ 83, 313, 886, 888, 918, 938, 1021, 1034, 1036, 1141, + /* 90 */ 1159, 1163, 1166, 1168, 1170, 1176, 1178, 1180, 1184, 1196, + /* 100 */ 1198, 1205, 1215, 1225, 1227, 1236, 1252, 1254, 1264, 1303, + /* 110 */ 1309, 1312, 1322, 1325, 1328, 1337, 1340, 1343, 1353, 1371, + /* 120 */ 1373, 1384, 1386, 1411, 1413, 1420, 1424, 1426, 1458, 1470, + /* 130 */ 1473, -271, -271, -271, -271, -271, -271, -271, -271, -271, + /* 140 */ -271, -271, 138, 459, 396, -158, 470, 302, -212, 521, + /* 150 */ 201, -195, -92, 559, 630, 632, 630, -271, 632, 901, + /* 160 */ 63, 407, 670, -271, -271, -271, -271, 161, 161, 161, + /* 170 */ 251, 335, 847, 979, 1097, 537, 588, 618, 628, 688, + /* 180 */ 688, -166, -161, 674, 787, 794, 799, 852, 996, -122, + /* 190 */ 837, -120, 1018, 1035, 415, 1047, 1001, 958, 1082, 400, + /* 200 */ 1099, 779, 1137, 1142, 263, 1083, 1145, 1150, 1041, 1139, + /* 210 */ 965, 1050, 362, 849, 752, 629, 675, 1162, 1173, 1090, + /* 220 */ 1195, -194, 56, 185, -135, 232, 522, 560, 571, 601, + /* 230 */ 617, 669, 683, 711, 850, 893, 1000, 1040, 1049, 1081, + /* 240 */ 1087, 1101, 392, 1114, 1123, 1155, 1161, 1175, 1271, 1293, + /* 250 */ 1299, 1330, 1339, 1342, 1347, 593, 1282, 1286, 1350, 1359, + /* 260 */ 1368, 1314, 1480, 1483, 1507, 1085, 1338, 1526, 1527, 1487, + /* 270 */ 1531, 560, 1532, 1534, 1535, 1538, 1539, 1541, 1448, 1450, + /* 280 */ 1496, 1484, 1485, 1489, 1490, 1314, 1496, 1496, 1504, 1536, + /* 290 */ 1564, 1451, 1486, 1492, 1509, 1493, 1465, 1515, 1494, 1495, + /* 300 */ 1517, 1500, 1519, 1474, 1550, 1543, 1548, 1556, 1565, 1566, + /* 310 */ 1518, 1523, 1542, 1544, 1525, 1545, 1513, 1553, 1552, 1604, + /* 320 */ 1508, 1510, 1608, 1609, 1520, 1528, 1612, 1540, 1559, 1560, + /* 330 */ 1592, 1591, 1595, 1596, 1597, 1629, 1638, 1594, 1569, 1570, + /* 340 */ 1600, 1568, 1610, 1601, 1611, 1603, 1643, 1651, 1562, 1571, + /* 350 */ 1655, 1659, 1640, 1663, 1666, 1664, 1667, 1641, 1650, 1652, + /* 360 */ 1653, 1647, 1656, 1657, 1658, 1668, 1672, 1681, 1649, 1682, + /* 370 */ 1683, 1573, 1582, 1607, 1615, 1685, 1702, 1586, 1587, 1642, + /* 380 */ 1646, 1673, 1675, 1636, 1714, 1637, 1677, 1674, 1678, 1694, + /* 390 */ 1719, 1734, 1735, 1746, 1747, 1750, 1633, 1661, 1686, 1738, + /* 400 */ 1728, 1733, 1736, 1737, 1740, 1726, 1730, 1742, 1743, 1748, + /* 410 */ 1753, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1639, 1639, 1639, 1469, 1236, 1347, 1236, 1236, 1236, 1469, - /* 10 */ 1469, 1469, 1236, 1377, 1377, 1522, 1269, 1236, 1236, 1236, - /* 20 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1468, 1236, 1236, - /* 30 */ 1236, 1236, 1555, 1555, 1236, 1236, 1236, 1236, 1236, 1236, - /* 40 */ 1236, 1236, 1386, 1236, 1393, 1236, 1236, 1236, 1236, 1236, - /* 50 */ 1470, 1471, 1236, 1236, 1236, 1521, 1523, 1486, 1400, 1399, - /* 60 */ 1398, 1397, 1504, 1365, 1391, 1384, 1388, 1465, 1466, 1464, - /* 70 */ 1617, 1471, 1470, 1236, 1387, 1433, 1449, 1432, 1236, 1236, - /* 80 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, - /* 90 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, - /* 100 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, - /* 110 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, - /* 120 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, - /* 130 */ 1441, 1448, 1447, 1446, 1455, 1445, 1442, 1435, 1434, 1436, - /* 140 */ 1437, 1236, 1236, 1260, 1236, 1236, 1257, 1311, 1236, 1236, - /* 150 */ 1236, 1236, 1236, 1541, 1540, 1236, 1438, 1236, 1269, 1427, - /* 160 */ 1426, 1452, 1439, 1451, 1450, 1529, 1591, 1590, 1487, 1236, - /* 170 */ 1236, 1236, 1236, 1236, 1236, 1555, 1236, 1236, 1236, 1236, - /* 180 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, - /* 190 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1367, - /* 200 */ 1555, 1555, 1236, 1269, 1555, 1555, 1368, 1368, 1265, 1265, - /* 210 */ 1371, 1236, 1536, 1338, 1338, 1338, 1338, 1347, 1338, 1236, - /* 220 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, - /* 230 */ 1236, 1236, 1236, 1236, 1526, 1524, 1236, 1236, 1236, 1236, - /* 240 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, - /* 250 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, - /* 260 */ 1236, 1236, 1236, 1343, 1236, 1236, 1236, 1236, 1236, 1236, - /* 270 */ 1236, 1236, 1236, 1236, 1236, 1584, 1236, 1499, 1325, 1343, - /* 280 */ 1343, 1343, 1343, 1345, 1326, 1324, 1337, 1270, 1243, 1631, - /* 290 */ 1403, 1392, 1344, 1392, 1628, 1390, 1403, 1403, 1390, 1403, - /* 300 */ 1344, 1628, 1286, 1606, 1281, 1377, 1377, 1377, 1367, 1367, - /* 310 */ 1367, 1367, 1371, 1371, 1467, 1344, 1337, 1236, 1631, 1631, - /* 320 */ 1353, 1353, 1630, 1630, 1353, 1487, 1614, 1412, 1314, 1320, - /* 330 */ 1320, 1320, 1320, 1353, 1254, 1390, 1614, 1614, 1390, 1412, - /* 340 */ 1314, 1390, 1314, 1390, 1353, 1254, 1503, 1625, 1353, 1254, - /* 350 */ 1477, 1353, 1254, 1353, 1254, 1477, 1312, 1312, 1312, 1301, - /* 360 */ 1236, 1236, 1477, 1312, 1286, 1312, 1301, 1312, 1312, 1573, - /* 370 */ 1236, 1481, 1481, 1477, 1353, 1565, 1565, 1380, 1380, 1385, - /* 380 */ 1371, 1472, 1353, 1236, 1385, 1383, 1381, 1390, 1304, 1587, - /* 390 */ 1587, 1583, 1583, 1583, 1636, 1636, 1536, 1599, 1269, 1269, - /* 400 */ 1269, 1269, 1599, 1288, 1288, 1270, 1270, 1269, 1599, 1236, - /* 410 */ 1236, 1236, 1236, 1236, 1236, 1594, 1236, 1531, 1488, 1357, - /* 420 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, - /* 430 */ 1236, 1236, 1236, 1236, 1542, 1236, 1236, 1236, 1236, 1236, - /* 440 */ 1236, 1236, 1236, 1236, 1236, 1417, 1236, 1239, 1533, 1236, - /* 450 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1394, 1395, 1358, - /* 460 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1409, 1236, 1236, - /* 470 */ 1236, 1404, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, - /* 480 */ 1627, 1236, 1236, 1236, 1236, 1236, 1236, 1502, 1501, 1236, - /* 490 */ 1236, 1355, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, - /* 500 */ 1236, 1236, 1236, 1236, 1236, 1284, 1236, 1236, 1236, 1236, - /* 510 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, - /* 520 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1382, - /* 530 */ 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, - /* 540 */ 1236, 1236, 1236, 1236, 1570, 1372, 1236, 1236, 1236, 1236, - /* 550 */ 1618, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, - /* 560 */ 1236, 1236, 1236, 1236, 1236, 1610, 1328, 1418, 1236, 1421, - /* 570 */ 1258, 1236, 1248, 1236, 1236, + /* 0 */ 1648, 1648, 1648, 1478, 1243, 1354, 1243, 1243, 1243, 1478, + /* 10 */ 1478, 1478, 1243, 1384, 1384, 1531, 1276, 1243, 1243, 1243, + /* 20 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1477, 1243, + /* 30 */ 1243, 1243, 1243, 1564, 1564, 1243, 1243, 1243, 1243, 1243, + /* 40 */ 1243, 1243, 1243, 1393, 1243, 1400, 1243, 1243, 1243, 1243, + /* 50 */ 1243, 1479, 1480, 1243, 1243, 1243, 1530, 1532, 1495, 1407, + /* 60 */ 1406, 1405, 1404, 1513, 1372, 1398, 1391, 1395, 1474, 1475, + /* 70 */ 1473, 1626, 1480, 1479, 1243, 1394, 1442, 1458, 1441, 1243, + /* 80 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, + /* 90 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, + /* 100 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, + /* 110 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, + /* 120 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, + /* 130 */ 1243, 1450, 1457, 1456, 1455, 1464, 1454, 1451, 1444, 1443, + /* 140 */ 1445, 1446, 1243, 1243, 1267, 1243, 1243, 1264, 1318, 1243, + /* 150 */ 1243, 1243, 1243, 1243, 1550, 1549, 1243, 1447, 1243, 1276, + /* 160 */ 1435, 1434, 1433, 1461, 1448, 1460, 1459, 1538, 1600, 1599, + /* 170 */ 1496, 1243, 1243, 1243, 1243, 1243, 1243, 1564, 1243, 1243, + /* 180 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, + /* 190 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, + /* 200 */ 1243, 1374, 1564, 1564, 1243, 1276, 1564, 1564, 1375, 1375, + /* 210 */ 1272, 1272, 1378, 1243, 1545, 1345, 1345, 1345, 1345, 1354, + /* 220 */ 1345, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, + /* 230 */ 1243, 1243, 1243, 1243, 1243, 1243, 1535, 1533, 1243, 1243, + /* 240 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, + /* 250 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, + /* 260 */ 1243, 1243, 1243, 1243, 1243, 1350, 1243, 1243, 1243, 1243, + /* 270 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1593, 1243, 1508, + /* 280 */ 1332, 1350, 1350, 1350, 1350, 1352, 1333, 1331, 1344, 1277, + /* 290 */ 1250, 1640, 1410, 1399, 1351, 1399, 1637, 1397, 1410, 1410, + /* 300 */ 1397, 1410, 1351, 1637, 1293, 1615, 1288, 1384, 1384, 1384, + /* 310 */ 1374, 1374, 1374, 1374, 1378, 1378, 1476, 1351, 1344, 1243, + /* 320 */ 1640, 1640, 1360, 1360, 1639, 1639, 1360, 1496, 1623, 1419, + /* 330 */ 1321, 1327, 1327, 1327, 1327, 1360, 1261, 1397, 1623, 1623, + /* 340 */ 1397, 1419, 1321, 1397, 1321, 1397, 1360, 1261, 1512, 1634, + /* 350 */ 1360, 1261, 1486, 1360, 1261, 1360, 1261, 1486, 1319, 1319, + /* 360 */ 1319, 1308, 1243, 1243, 1486, 1319, 1293, 1319, 1308, 1319, + /* 370 */ 1319, 1582, 1243, 1490, 1490, 1486, 1360, 1574, 1574, 1387, + /* 380 */ 1387, 1392, 1378, 1481, 1360, 1243, 1392, 1390, 1388, 1397, + /* 390 */ 1311, 1596, 1596, 1592, 1592, 1592, 1645, 1645, 1545, 1608, + /* 400 */ 1276, 1276, 1276, 1276, 1608, 1295, 1295, 1277, 1277, 1276, + /* 410 */ 1608, 1243, 1243, 1243, 1243, 1243, 1243, 1603, 1243, 1540, + /* 420 */ 1497, 1364, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, + /* 430 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1551, 1243, + /* 440 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1424, + /* 450 */ 1243, 1246, 1542, 1243, 1243, 1243, 1243, 1243, 1243, 1243, + /* 460 */ 1243, 1401, 1402, 1365, 1243, 1243, 1243, 1243, 1243, 1243, + /* 470 */ 1243, 1416, 1243, 1243, 1243, 1411, 1243, 1243, 1243, 1243, + /* 480 */ 1243, 1243, 1243, 1243, 1636, 1243, 1243, 1243, 1243, 1243, + /* 490 */ 1243, 1511, 1510, 1243, 1243, 1362, 1243, 1243, 1243, 1243, + /* 500 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1291, + /* 510 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, + /* 520 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, + /* 530 */ 1243, 1243, 1243, 1389, 1243, 1243, 1243, 1243, 1243, 1243, + /* 540 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1579, 1379, + /* 550 */ 1243, 1243, 1243, 1243, 1627, 1243, 1243, 1243, 1243, 1243, + /* 560 */ 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1619, + /* 570 */ 1335, 1425, 1243, 1428, 1265, 1243, 1255, 1243, 1243, }; /********** End of lemon-generated parsing tables *****************************/ @@ -171230,221 +172315,223 @@ static const char *const yyRuleName[] = { /* 185 */ "expr ::= expr COLLATE ID|STRING", /* 186 */ "expr ::= CAST LP expr AS typetoken RP", /* 187 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP", - /* 188 */ "expr ::= ID|INDEXED|JOIN_KW LP STAR RP", - /* 189 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over", - /* 190 */ "expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over", - /* 191 */ "term ::= CTIME_KW", - /* 192 */ "expr ::= LP nexprlist COMMA expr RP", - /* 193 */ "expr ::= expr AND expr", - /* 194 */ "expr ::= expr OR expr", - /* 195 */ "expr ::= expr LT|GT|GE|LE expr", - /* 196 */ "expr ::= expr EQ|NE expr", - /* 197 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr", - /* 198 */ "expr ::= expr PLUS|MINUS expr", - /* 199 */ "expr ::= expr STAR|SLASH|REM expr", - /* 200 */ "expr ::= expr CONCAT expr", - /* 201 */ "likeop ::= NOT LIKE_KW|MATCH", - /* 202 */ "expr ::= expr likeop expr", - /* 203 */ "expr ::= expr likeop expr ESCAPE expr", - /* 204 */ "expr ::= expr ISNULL|NOTNULL", - /* 205 */ "expr ::= expr NOT NULL", - /* 206 */ "expr ::= expr IS expr", - /* 207 */ "expr ::= expr IS NOT expr", - /* 208 */ "expr ::= expr IS NOT DISTINCT FROM expr", - /* 209 */ "expr ::= expr IS DISTINCT FROM expr", - /* 210 */ "expr ::= NOT expr", - /* 211 */ "expr ::= BITNOT expr", - /* 212 */ "expr ::= PLUS|MINUS expr", - /* 213 */ "expr ::= expr PTR expr", - /* 214 */ "between_op ::= BETWEEN", - /* 215 */ "between_op ::= NOT BETWEEN", - /* 216 */ "expr ::= expr between_op expr AND expr", - /* 217 */ "in_op ::= IN", - /* 218 */ "in_op ::= NOT IN", - /* 219 */ "expr ::= expr in_op LP exprlist RP", - /* 220 */ "expr ::= LP select RP", - /* 221 */ "expr ::= expr in_op LP select RP", - /* 222 */ "expr ::= expr in_op nm dbnm paren_exprlist", - /* 223 */ "expr ::= EXISTS LP select RP", - /* 224 */ "expr ::= CASE case_operand case_exprlist case_else END", - /* 225 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr", - /* 226 */ "case_exprlist ::= WHEN expr THEN expr", - /* 227 */ "case_else ::= ELSE expr", - /* 228 */ "case_else ::=", - /* 229 */ "case_operand ::=", - /* 230 */ "exprlist ::=", - /* 231 */ "nexprlist ::= nexprlist COMMA expr", - /* 232 */ "nexprlist ::= expr", - /* 233 */ "paren_exprlist ::=", - /* 234 */ "paren_exprlist ::= LP exprlist RP", - /* 235 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt", - /* 236 */ "uniqueflag ::= UNIQUE", - /* 237 */ "uniqueflag ::=", - /* 238 */ "eidlist_opt ::=", - /* 239 */ "eidlist_opt ::= LP eidlist RP", - /* 240 */ "eidlist ::= eidlist COMMA nm collate sortorder", - /* 241 */ "eidlist ::= nm collate sortorder", - /* 242 */ "collate ::=", - /* 243 */ "collate ::= COLLATE ID|STRING", - /* 244 */ "cmd ::= DROP INDEX ifexists fullname", - /* 245 */ "cmd ::= VACUUM vinto", - /* 246 */ "cmd ::= VACUUM nm vinto", - /* 247 */ "vinto ::= INTO expr", - /* 248 */ "vinto ::=", - /* 249 */ "cmd ::= PRAGMA nm dbnm", - /* 250 */ "cmd ::= PRAGMA nm dbnm EQ nmnum", - /* 251 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP", - /* 252 */ "cmd ::= PRAGMA nm dbnm EQ minus_num", - /* 253 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP", - /* 254 */ "plus_num ::= PLUS INTEGER|FLOAT", - /* 255 */ "minus_num ::= MINUS INTEGER|FLOAT", - /* 256 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END", - /* 257 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause", - /* 258 */ "trigger_time ::= BEFORE|AFTER", - /* 259 */ "trigger_time ::= INSTEAD OF", - /* 260 */ "trigger_time ::=", - /* 261 */ "trigger_event ::= DELETE|INSERT", - /* 262 */ "trigger_event ::= UPDATE", - /* 263 */ "trigger_event ::= UPDATE OF idlist", - /* 264 */ "when_clause ::=", - /* 265 */ "when_clause ::= WHEN expr", - /* 266 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI", - /* 267 */ "trigger_cmd_list ::= trigger_cmd SEMI", - /* 268 */ "trnm ::= nm DOT nm", - /* 269 */ "tridxby ::= INDEXED BY nm", - /* 270 */ "tridxby ::= NOT INDEXED", - /* 271 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt", - /* 272 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt", - /* 273 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt", - /* 274 */ "trigger_cmd ::= scanpt select scanpt", - /* 275 */ "expr ::= RAISE LP IGNORE RP", - /* 276 */ "expr ::= RAISE LP raisetype COMMA nm RP", - /* 277 */ "raisetype ::= ROLLBACK", - /* 278 */ "raisetype ::= ABORT", - /* 279 */ "raisetype ::= FAIL", - /* 280 */ "cmd ::= DROP TRIGGER ifexists fullname", - /* 281 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt", - /* 282 */ "cmd ::= DETACH database_kw_opt expr", - /* 283 */ "key_opt ::=", - /* 284 */ "key_opt ::= KEY expr", - /* 285 */ "cmd ::= REINDEX", - /* 286 */ "cmd ::= REINDEX nm dbnm", - /* 287 */ "cmd ::= ANALYZE", - /* 288 */ "cmd ::= ANALYZE nm dbnm", - /* 289 */ "cmd ::= ALTER TABLE fullname RENAME TO nm", - /* 290 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist", - /* 291 */ "cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm", - /* 292 */ "add_column_fullname ::= fullname", - /* 293 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm", - /* 294 */ "cmd ::= create_vtab", - /* 295 */ "cmd ::= create_vtab LP vtabarglist RP", - /* 296 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm", - /* 297 */ "vtabarg ::=", - /* 298 */ "vtabargtoken ::= ANY", - /* 299 */ "vtabargtoken ::= lp anylist RP", - /* 300 */ "lp ::= LP", - /* 301 */ "with ::= WITH wqlist", - /* 302 */ "with ::= WITH RECURSIVE wqlist", - /* 303 */ "wqas ::= AS", - /* 304 */ "wqas ::= AS MATERIALIZED", - /* 305 */ "wqas ::= AS NOT MATERIALIZED", - /* 306 */ "wqitem ::= nm eidlist_opt wqas LP select RP", - /* 307 */ "wqlist ::= wqitem", - /* 308 */ "wqlist ::= wqlist COMMA wqitem", - /* 309 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn", - /* 310 */ "windowdefn ::= nm AS LP window RP", - /* 311 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt", - /* 312 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt", - /* 313 */ "window ::= ORDER BY sortlist frame_opt", - /* 314 */ "window ::= nm ORDER BY sortlist frame_opt", - /* 315 */ "window ::= nm frame_opt", - /* 316 */ "frame_opt ::=", - /* 317 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt", - /* 318 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt", - /* 319 */ "range_or_rows ::= RANGE|ROWS|GROUPS", - /* 320 */ "frame_bound_s ::= frame_bound", - /* 321 */ "frame_bound_s ::= UNBOUNDED PRECEDING", - /* 322 */ "frame_bound_e ::= frame_bound", - /* 323 */ "frame_bound_e ::= UNBOUNDED FOLLOWING", - /* 324 */ "frame_bound ::= expr PRECEDING|FOLLOWING", - /* 325 */ "frame_bound ::= CURRENT ROW", - /* 326 */ "frame_exclude_opt ::=", - /* 327 */ "frame_exclude_opt ::= EXCLUDE frame_exclude", - /* 328 */ "frame_exclude ::= NO OTHERS", - /* 329 */ "frame_exclude ::= CURRENT ROW", - /* 330 */ "frame_exclude ::= GROUP|TIES", - /* 331 */ "window_clause ::= WINDOW windowdefn_list", - /* 332 */ "filter_over ::= filter_clause over_clause", - /* 333 */ "filter_over ::= over_clause", - /* 334 */ "filter_over ::= filter_clause", - /* 335 */ "over_clause ::= OVER LP window RP", - /* 336 */ "over_clause ::= OVER nm", - /* 337 */ "filter_clause ::= FILTER LP WHERE expr RP", - /* 338 */ "input ::= cmdlist", - /* 339 */ "cmdlist ::= cmdlist ecmd", - /* 340 */ "cmdlist ::= ecmd", - /* 341 */ "ecmd ::= SEMI", - /* 342 */ "ecmd ::= cmdx SEMI", - /* 343 */ "ecmd ::= explain cmdx SEMI", - /* 344 */ "trans_opt ::=", - /* 345 */ "trans_opt ::= TRANSACTION", - /* 346 */ "trans_opt ::= TRANSACTION nm", - /* 347 */ "savepoint_opt ::= SAVEPOINT", - /* 348 */ "savepoint_opt ::=", - /* 349 */ "cmd ::= create_table create_table_args", - /* 350 */ "table_option_set ::= table_option", - /* 351 */ "columnlist ::= columnlist COMMA columnname carglist", - /* 352 */ "columnlist ::= columnname carglist", - /* 353 */ "nm ::= ID|INDEXED|JOIN_KW", - /* 354 */ "nm ::= STRING", - /* 355 */ "typetoken ::= typename", - /* 356 */ "typename ::= ID|STRING", - /* 357 */ "signed ::= plus_num", - /* 358 */ "signed ::= minus_num", - /* 359 */ "carglist ::= carglist ccons", - /* 360 */ "carglist ::=", - /* 361 */ "ccons ::= NULL onconf", - /* 362 */ "ccons ::= GENERATED ALWAYS AS generated", - /* 363 */ "ccons ::= AS generated", - /* 364 */ "conslist_opt ::= COMMA conslist", - /* 365 */ "conslist ::= conslist tconscomma tcons", - /* 366 */ "conslist ::= tcons", - /* 367 */ "tconscomma ::=", - /* 368 */ "defer_subclause_opt ::= defer_subclause", - /* 369 */ "resolvetype ::= raisetype", - /* 370 */ "selectnowith ::= oneselect", - /* 371 */ "oneselect ::= values", - /* 372 */ "sclp ::= selcollist COMMA", - /* 373 */ "as ::= ID|STRING", - /* 374 */ "indexed_opt ::= indexed_by", - /* 375 */ "returning ::=", - /* 376 */ "expr ::= term", - /* 377 */ "likeop ::= LIKE_KW|MATCH", - /* 378 */ "case_operand ::= expr", - /* 379 */ "exprlist ::= nexprlist", - /* 380 */ "nmnum ::= plus_num", - /* 381 */ "nmnum ::= nm", - /* 382 */ "nmnum ::= ON", - /* 383 */ "nmnum ::= DELETE", - /* 384 */ "nmnum ::= DEFAULT", - /* 385 */ "plus_num ::= INTEGER|FLOAT", - /* 386 */ "foreach_clause ::=", - /* 387 */ "foreach_clause ::= FOR EACH ROW", - /* 388 */ "trnm ::= nm", - /* 389 */ "tridxby ::=", - /* 390 */ "database_kw_opt ::= DATABASE", - /* 391 */ "database_kw_opt ::=", - /* 392 */ "kwcolumn_opt ::=", - /* 393 */ "kwcolumn_opt ::= COLUMNKW", - /* 394 */ "vtabarglist ::= vtabarg", - /* 395 */ "vtabarglist ::= vtabarglist COMMA vtabarg", - /* 396 */ "vtabarg ::= vtabarg vtabargtoken", - /* 397 */ "anylist ::=", - /* 398 */ "anylist ::= anylist LP anylist RP", - /* 399 */ "anylist ::= anylist ANY", - /* 400 */ "with ::=", - /* 401 */ "windowdefn_list ::= windowdefn", - /* 402 */ "window ::= frame_opt", + /* 188 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP", + /* 189 */ "expr ::= ID|INDEXED|JOIN_KW LP STAR RP", + /* 190 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over", + /* 191 */ "expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over", + /* 192 */ "expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over", + /* 193 */ "term ::= CTIME_KW", + /* 194 */ "expr ::= LP nexprlist COMMA expr RP", + /* 195 */ "expr ::= expr AND expr", + /* 196 */ "expr ::= expr OR expr", + /* 197 */ "expr ::= expr LT|GT|GE|LE expr", + /* 198 */ "expr ::= expr EQ|NE expr", + /* 199 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr", + /* 200 */ "expr ::= expr PLUS|MINUS expr", + /* 201 */ "expr ::= expr STAR|SLASH|REM expr", + /* 202 */ "expr ::= expr CONCAT expr", + /* 203 */ "likeop ::= NOT LIKE_KW|MATCH", + /* 204 */ "expr ::= expr likeop expr", + /* 205 */ "expr ::= expr likeop expr ESCAPE expr", + /* 206 */ "expr ::= expr ISNULL|NOTNULL", + /* 207 */ "expr ::= expr NOT NULL", + /* 208 */ "expr ::= expr IS expr", + /* 209 */ "expr ::= expr IS NOT expr", + /* 210 */ "expr ::= expr IS NOT DISTINCT FROM expr", + /* 211 */ "expr ::= expr IS DISTINCT FROM expr", + /* 212 */ "expr ::= NOT expr", + /* 213 */ "expr ::= BITNOT expr", + /* 214 */ "expr ::= PLUS|MINUS expr", + /* 215 */ "expr ::= expr PTR expr", + /* 216 */ "between_op ::= BETWEEN", + /* 217 */ "between_op ::= NOT BETWEEN", + /* 218 */ "expr ::= expr between_op expr AND expr", + /* 219 */ "in_op ::= IN", + /* 220 */ "in_op ::= NOT IN", + /* 221 */ "expr ::= expr in_op LP exprlist RP", + /* 222 */ "expr ::= LP select RP", + /* 223 */ "expr ::= expr in_op LP select RP", + /* 224 */ "expr ::= expr in_op nm dbnm paren_exprlist", + /* 225 */ "expr ::= EXISTS LP select RP", + /* 226 */ "expr ::= CASE case_operand case_exprlist case_else END", + /* 227 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr", + /* 228 */ "case_exprlist ::= WHEN expr THEN expr", + /* 229 */ "case_else ::= ELSE expr", + /* 230 */ "case_else ::=", + /* 231 */ "case_operand ::=", + /* 232 */ "exprlist ::=", + /* 233 */ "nexprlist ::= nexprlist COMMA expr", + /* 234 */ "nexprlist ::= expr", + /* 235 */ "paren_exprlist ::=", + /* 236 */ "paren_exprlist ::= LP exprlist RP", + /* 237 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt", + /* 238 */ "uniqueflag ::= UNIQUE", + /* 239 */ "uniqueflag ::=", + /* 240 */ "eidlist_opt ::=", + /* 241 */ "eidlist_opt ::= LP eidlist RP", + /* 242 */ "eidlist ::= eidlist COMMA nm collate sortorder", + /* 243 */ "eidlist ::= nm collate sortorder", + /* 244 */ "collate ::=", + /* 245 */ "collate ::= COLLATE ID|STRING", + /* 246 */ "cmd ::= DROP INDEX ifexists fullname", + /* 247 */ "cmd ::= VACUUM vinto", + /* 248 */ "cmd ::= VACUUM nm vinto", + /* 249 */ "vinto ::= INTO expr", + /* 250 */ "vinto ::=", + /* 251 */ "cmd ::= PRAGMA nm dbnm", + /* 252 */ "cmd ::= PRAGMA nm dbnm EQ nmnum", + /* 253 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP", + /* 254 */ "cmd ::= PRAGMA nm dbnm EQ minus_num", + /* 255 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP", + /* 256 */ "plus_num ::= PLUS INTEGER|FLOAT", + /* 257 */ "minus_num ::= MINUS INTEGER|FLOAT", + /* 258 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END", + /* 259 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause", + /* 260 */ "trigger_time ::= BEFORE|AFTER", + /* 261 */ "trigger_time ::= INSTEAD OF", + /* 262 */ "trigger_time ::=", + /* 263 */ "trigger_event ::= DELETE|INSERT", + /* 264 */ "trigger_event ::= UPDATE", + /* 265 */ "trigger_event ::= UPDATE OF idlist", + /* 266 */ "when_clause ::=", + /* 267 */ "when_clause ::= WHEN expr", + /* 268 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI", + /* 269 */ "trigger_cmd_list ::= trigger_cmd SEMI", + /* 270 */ "trnm ::= nm DOT nm", + /* 271 */ "tridxby ::= INDEXED BY nm", + /* 272 */ "tridxby ::= NOT INDEXED", + /* 273 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt", + /* 274 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt", + /* 275 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt", + /* 276 */ "trigger_cmd ::= scanpt select scanpt", + /* 277 */ "expr ::= RAISE LP IGNORE RP", + /* 278 */ "expr ::= RAISE LP raisetype COMMA nm RP", + /* 279 */ "raisetype ::= ROLLBACK", + /* 280 */ "raisetype ::= ABORT", + /* 281 */ "raisetype ::= FAIL", + /* 282 */ "cmd ::= DROP TRIGGER ifexists fullname", + /* 283 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt", + /* 284 */ "cmd ::= DETACH database_kw_opt expr", + /* 285 */ "key_opt ::=", + /* 286 */ "key_opt ::= KEY expr", + /* 287 */ "cmd ::= REINDEX", + /* 288 */ "cmd ::= REINDEX nm dbnm", + /* 289 */ "cmd ::= ANALYZE", + /* 290 */ "cmd ::= ANALYZE nm dbnm", + /* 291 */ "cmd ::= ALTER TABLE fullname RENAME TO nm", + /* 292 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist", + /* 293 */ "cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm", + /* 294 */ "add_column_fullname ::= fullname", + /* 295 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm", + /* 296 */ "cmd ::= create_vtab", + /* 297 */ "cmd ::= create_vtab LP vtabarglist RP", + /* 298 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm", + /* 299 */ "vtabarg ::=", + /* 300 */ "vtabargtoken ::= ANY", + /* 301 */ "vtabargtoken ::= lp anylist RP", + /* 302 */ "lp ::= LP", + /* 303 */ "with ::= WITH wqlist", + /* 304 */ "with ::= WITH RECURSIVE wqlist", + /* 305 */ "wqas ::= AS", + /* 306 */ "wqas ::= AS MATERIALIZED", + /* 307 */ "wqas ::= AS NOT MATERIALIZED", + /* 308 */ "wqitem ::= nm eidlist_opt wqas LP select RP", + /* 309 */ "wqlist ::= wqitem", + /* 310 */ "wqlist ::= wqlist COMMA wqitem", + /* 311 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn", + /* 312 */ "windowdefn ::= nm AS LP window RP", + /* 313 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt", + /* 314 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt", + /* 315 */ "window ::= ORDER BY sortlist frame_opt", + /* 316 */ "window ::= nm ORDER BY sortlist frame_opt", + /* 317 */ "window ::= nm frame_opt", + /* 318 */ "frame_opt ::=", + /* 319 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt", + /* 320 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt", + /* 321 */ "range_or_rows ::= RANGE|ROWS|GROUPS", + /* 322 */ "frame_bound_s ::= frame_bound", + /* 323 */ "frame_bound_s ::= UNBOUNDED PRECEDING", + /* 324 */ "frame_bound_e ::= frame_bound", + /* 325 */ "frame_bound_e ::= UNBOUNDED FOLLOWING", + /* 326 */ "frame_bound ::= expr PRECEDING|FOLLOWING", + /* 327 */ "frame_bound ::= CURRENT ROW", + /* 328 */ "frame_exclude_opt ::=", + /* 329 */ "frame_exclude_opt ::= EXCLUDE frame_exclude", + /* 330 */ "frame_exclude ::= NO OTHERS", + /* 331 */ "frame_exclude ::= CURRENT ROW", + /* 332 */ "frame_exclude ::= GROUP|TIES", + /* 333 */ "window_clause ::= WINDOW windowdefn_list", + /* 334 */ "filter_over ::= filter_clause over_clause", + /* 335 */ "filter_over ::= over_clause", + /* 336 */ "filter_over ::= filter_clause", + /* 337 */ "over_clause ::= OVER LP window RP", + /* 338 */ "over_clause ::= OVER nm", + /* 339 */ "filter_clause ::= FILTER LP WHERE expr RP", + /* 340 */ "input ::= cmdlist", + /* 341 */ "cmdlist ::= cmdlist ecmd", + /* 342 */ "cmdlist ::= ecmd", + /* 343 */ "ecmd ::= SEMI", + /* 344 */ "ecmd ::= cmdx SEMI", + /* 345 */ "ecmd ::= explain cmdx SEMI", + /* 346 */ "trans_opt ::=", + /* 347 */ "trans_opt ::= TRANSACTION", + /* 348 */ "trans_opt ::= TRANSACTION nm", + /* 349 */ "savepoint_opt ::= SAVEPOINT", + /* 350 */ "savepoint_opt ::=", + /* 351 */ "cmd ::= create_table create_table_args", + /* 352 */ "table_option_set ::= table_option", + /* 353 */ "columnlist ::= columnlist COMMA columnname carglist", + /* 354 */ "columnlist ::= columnname carglist", + /* 355 */ "nm ::= ID|INDEXED|JOIN_KW", + /* 356 */ "nm ::= STRING", + /* 357 */ "typetoken ::= typename", + /* 358 */ "typename ::= ID|STRING", + /* 359 */ "signed ::= plus_num", + /* 360 */ "signed ::= minus_num", + /* 361 */ "carglist ::= carglist ccons", + /* 362 */ "carglist ::=", + /* 363 */ "ccons ::= NULL onconf", + /* 364 */ "ccons ::= GENERATED ALWAYS AS generated", + /* 365 */ "ccons ::= AS generated", + /* 366 */ "conslist_opt ::= COMMA conslist", + /* 367 */ "conslist ::= conslist tconscomma tcons", + /* 368 */ "conslist ::= tcons", + /* 369 */ "tconscomma ::=", + /* 370 */ "defer_subclause_opt ::= defer_subclause", + /* 371 */ "resolvetype ::= raisetype", + /* 372 */ "selectnowith ::= oneselect", + /* 373 */ "oneselect ::= values", + /* 374 */ "sclp ::= selcollist COMMA", + /* 375 */ "as ::= ID|STRING", + /* 376 */ "indexed_opt ::= indexed_by", + /* 377 */ "returning ::=", + /* 378 */ "expr ::= term", + /* 379 */ "likeop ::= LIKE_KW|MATCH", + /* 380 */ "case_operand ::= expr", + /* 381 */ "exprlist ::= nexprlist", + /* 382 */ "nmnum ::= plus_num", + /* 383 */ "nmnum ::= nm", + /* 384 */ "nmnum ::= ON", + /* 385 */ "nmnum ::= DELETE", + /* 386 */ "nmnum ::= DEFAULT", + /* 387 */ "plus_num ::= INTEGER|FLOAT", + /* 388 */ "foreach_clause ::=", + /* 389 */ "foreach_clause ::= FOR EACH ROW", + /* 390 */ "trnm ::= nm", + /* 391 */ "tridxby ::=", + /* 392 */ "database_kw_opt ::= DATABASE", + /* 393 */ "database_kw_opt ::=", + /* 394 */ "kwcolumn_opt ::=", + /* 395 */ "kwcolumn_opt ::= COLUMNKW", + /* 396 */ "vtabarglist ::= vtabarg", + /* 397 */ "vtabarglist ::= vtabarglist COMMA vtabarg", + /* 398 */ "vtabarg ::= vtabarg vtabargtoken", + /* 399 */ "anylist ::=", + /* 400 */ "anylist ::= anylist LP anylist RP", + /* 401 */ "anylist ::= anylist ANY", + /* 402 */ "with ::=", + /* 403 */ "windowdefn_list ::= windowdefn", + /* 404 */ "window ::= frame_opt", }; #endif /* NDEBUG */ @@ -172139,221 +173226,223 @@ static const YYCODETYPE yyRuleInfoLhs[] = { 217, /* (185) expr ::= expr COLLATE ID|STRING */ 217, /* (186) expr ::= CAST LP expr AS typetoken RP */ 217, /* (187) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */ - 217, /* (188) expr ::= ID|INDEXED|JOIN_KW LP STAR RP */ - 217, /* (189) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */ - 217, /* (190) expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */ - 216, /* (191) term ::= CTIME_KW */ - 217, /* (192) expr ::= LP nexprlist COMMA expr RP */ - 217, /* (193) expr ::= expr AND expr */ - 217, /* (194) expr ::= expr OR expr */ - 217, /* (195) expr ::= expr LT|GT|GE|LE expr */ - 217, /* (196) expr ::= expr EQ|NE expr */ - 217, /* (197) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ - 217, /* (198) expr ::= expr PLUS|MINUS expr */ - 217, /* (199) expr ::= expr STAR|SLASH|REM expr */ - 217, /* (200) expr ::= expr CONCAT expr */ - 274, /* (201) likeop ::= NOT LIKE_KW|MATCH */ - 217, /* (202) expr ::= expr likeop expr */ - 217, /* (203) expr ::= expr likeop expr ESCAPE expr */ - 217, /* (204) expr ::= expr ISNULL|NOTNULL */ - 217, /* (205) expr ::= expr NOT NULL */ - 217, /* (206) expr ::= expr IS expr */ - 217, /* (207) expr ::= expr IS NOT expr */ - 217, /* (208) expr ::= expr IS NOT DISTINCT FROM expr */ - 217, /* (209) expr ::= expr IS DISTINCT FROM expr */ - 217, /* (210) expr ::= NOT expr */ - 217, /* (211) expr ::= BITNOT expr */ - 217, /* (212) expr ::= PLUS|MINUS expr */ - 217, /* (213) expr ::= expr PTR expr */ - 275, /* (214) between_op ::= BETWEEN */ - 275, /* (215) between_op ::= NOT BETWEEN */ - 217, /* (216) expr ::= expr between_op expr AND expr */ - 276, /* (217) in_op ::= IN */ - 276, /* (218) in_op ::= NOT IN */ - 217, /* (219) expr ::= expr in_op LP exprlist RP */ - 217, /* (220) expr ::= LP select RP */ - 217, /* (221) expr ::= expr in_op LP select RP */ - 217, /* (222) expr ::= expr in_op nm dbnm paren_exprlist */ - 217, /* (223) expr ::= EXISTS LP select RP */ - 217, /* (224) expr ::= CASE case_operand case_exprlist case_else END */ - 279, /* (225) case_exprlist ::= case_exprlist WHEN expr THEN expr */ - 279, /* (226) case_exprlist ::= WHEN expr THEN expr */ - 280, /* (227) case_else ::= ELSE expr */ - 280, /* (228) case_else ::= */ - 278, /* (229) case_operand ::= */ - 261, /* (230) exprlist ::= */ - 253, /* (231) nexprlist ::= nexprlist COMMA expr */ - 253, /* (232) nexprlist ::= expr */ - 277, /* (233) paren_exprlist ::= */ - 277, /* (234) paren_exprlist ::= LP exprlist RP */ - 190, /* (235) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ - 281, /* (236) uniqueflag ::= UNIQUE */ - 281, /* (237) uniqueflag ::= */ - 221, /* (238) eidlist_opt ::= */ - 221, /* (239) eidlist_opt ::= LP eidlist RP */ - 232, /* (240) eidlist ::= eidlist COMMA nm collate sortorder */ - 232, /* (241) eidlist ::= nm collate sortorder */ - 282, /* (242) collate ::= */ - 282, /* (243) collate ::= COLLATE ID|STRING */ - 190, /* (244) cmd ::= DROP INDEX ifexists fullname */ - 190, /* (245) cmd ::= VACUUM vinto */ - 190, /* (246) cmd ::= VACUUM nm vinto */ - 283, /* (247) vinto ::= INTO expr */ - 283, /* (248) vinto ::= */ - 190, /* (249) cmd ::= PRAGMA nm dbnm */ - 190, /* (250) cmd ::= PRAGMA nm dbnm EQ nmnum */ - 190, /* (251) cmd ::= PRAGMA nm dbnm LP nmnum RP */ - 190, /* (252) cmd ::= PRAGMA nm dbnm EQ minus_num */ - 190, /* (253) cmd ::= PRAGMA nm dbnm LP minus_num RP */ - 211, /* (254) plus_num ::= PLUS INTEGER|FLOAT */ - 212, /* (255) minus_num ::= MINUS INTEGER|FLOAT */ - 190, /* (256) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ - 285, /* (257) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ - 287, /* (258) trigger_time ::= BEFORE|AFTER */ - 287, /* (259) trigger_time ::= INSTEAD OF */ - 287, /* (260) trigger_time ::= */ - 288, /* (261) trigger_event ::= DELETE|INSERT */ - 288, /* (262) trigger_event ::= UPDATE */ - 288, /* (263) trigger_event ::= UPDATE OF idlist */ - 290, /* (264) when_clause ::= */ - 290, /* (265) when_clause ::= WHEN expr */ - 286, /* (266) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ - 286, /* (267) trigger_cmd_list ::= trigger_cmd SEMI */ - 292, /* (268) trnm ::= nm DOT nm */ - 293, /* (269) tridxby ::= INDEXED BY nm */ - 293, /* (270) tridxby ::= NOT INDEXED */ - 291, /* (271) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ - 291, /* (272) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ - 291, /* (273) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ - 291, /* (274) trigger_cmd ::= scanpt select scanpt */ - 217, /* (275) expr ::= RAISE LP IGNORE RP */ - 217, /* (276) expr ::= RAISE LP raisetype COMMA nm RP */ - 236, /* (277) raisetype ::= ROLLBACK */ - 236, /* (278) raisetype ::= ABORT */ - 236, /* (279) raisetype ::= FAIL */ - 190, /* (280) cmd ::= DROP TRIGGER ifexists fullname */ - 190, /* (281) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ - 190, /* (282) cmd ::= DETACH database_kw_opt expr */ - 295, /* (283) key_opt ::= */ - 295, /* (284) key_opt ::= KEY expr */ - 190, /* (285) cmd ::= REINDEX */ - 190, /* (286) cmd ::= REINDEX nm dbnm */ - 190, /* (287) cmd ::= ANALYZE */ - 190, /* (288) cmd ::= ANALYZE nm dbnm */ - 190, /* (289) cmd ::= ALTER TABLE fullname RENAME TO nm */ - 190, /* (290) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ - 190, /* (291) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ - 296, /* (292) add_column_fullname ::= fullname */ - 190, /* (293) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ - 190, /* (294) cmd ::= create_vtab */ - 190, /* (295) cmd ::= create_vtab LP vtabarglist RP */ - 298, /* (296) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ - 300, /* (297) vtabarg ::= */ - 301, /* (298) vtabargtoken ::= ANY */ - 301, /* (299) vtabargtoken ::= lp anylist RP */ - 302, /* (300) lp ::= LP */ - 266, /* (301) with ::= WITH wqlist */ - 266, /* (302) with ::= WITH RECURSIVE wqlist */ - 305, /* (303) wqas ::= AS */ - 305, /* (304) wqas ::= AS MATERIALIZED */ - 305, /* (305) wqas ::= AS NOT MATERIALIZED */ - 304, /* (306) wqitem ::= nm eidlist_opt wqas LP select RP */ - 241, /* (307) wqlist ::= wqitem */ - 241, /* (308) wqlist ::= wqlist COMMA wqitem */ - 306, /* (309) windowdefn_list ::= windowdefn_list COMMA windowdefn */ - 307, /* (310) windowdefn ::= nm AS LP window RP */ - 308, /* (311) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ - 308, /* (312) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ - 308, /* (313) window ::= ORDER BY sortlist frame_opt */ - 308, /* (314) window ::= nm ORDER BY sortlist frame_opt */ - 308, /* (315) window ::= nm frame_opt */ - 309, /* (316) frame_opt ::= */ - 309, /* (317) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ - 309, /* (318) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ - 313, /* (319) range_or_rows ::= RANGE|ROWS|GROUPS */ - 315, /* (320) frame_bound_s ::= frame_bound */ - 315, /* (321) frame_bound_s ::= UNBOUNDED PRECEDING */ - 316, /* (322) frame_bound_e ::= frame_bound */ - 316, /* (323) frame_bound_e ::= UNBOUNDED FOLLOWING */ - 314, /* (324) frame_bound ::= expr PRECEDING|FOLLOWING */ - 314, /* (325) frame_bound ::= CURRENT ROW */ - 317, /* (326) frame_exclude_opt ::= */ - 317, /* (327) frame_exclude_opt ::= EXCLUDE frame_exclude */ - 318, /* (328) frame_exclude ::= NO OTHERS */ - 318, /* (329) frame_exclude ::= CURRENT ROW */ - 318, /* (330) frame_exclude ::= GROUP|TIES */ - 251, /* (331) window_clause ::= WINDOW windowdefn_list */ - 273, /* (332) filter_over ::= filter_clause over_clause */ - 273, /* (333) filter_over ::= over_clause */ - 273, /* (334) filter_over ::= filter_clause */ - 312, /* (335) over_clause ::= OVER LP window RP */ - 312, /* (336) over_clause ::= OVER nm */ - 311, /* (337) filter_clause ::= FILTER LP WHERE expr RP */ - 185, /* (338) input ::= cmdlist */ - 186, /* (339) cmdlist ::= cmdlist ecmd */ - 186, /* (340) cmdlist ::= ecmd */ - 187, /* (341) ecmd ::= SEMI */ - 187, /* (342) ecmd ::= cmdx SEMI */ - 187, /* (343) ecmd ::= explain cmdx SEMI */ - 192, /* (344) trans_opt ::= */ - 192, /* (345) trans_opt ::= TRANSACTION */ - 192, /* (346) trans_opt ::= TRANSACTION nm */ - 194, /* (347) savepoint_opt ::= SAVEPOINT */ - 194, /* (348) savepoint_opt ::= */ - 190, /* (349) cmd ::= create_table create_table_args */ - 203, /* (350) table_option_set ::= table_option */ - 201, /* (351) columnlist ::= columnlist COMMA columnname carglist */ - 201, /* (352) columnlist ::= columnname carglist */ - 193, /* (353) nm ::= ID|INDEXED|JOIN_KW */ - 193, /* (354) nm ::= STRING */ - 208, /* (355) typetoken ::= typename */ - 209, /* (356) typename ::= ID|STRING */ - 210, /* (357) signed ::= plus_num */ - 210, /* (358) signed ::= minus_num */ - 207, /* (359) carglist ::= carglist ccons */ - 207, /* (360) carglist ::= */ - 215, /* (361) ccons ::= NULL onconf */ - 215, /* (362) ccons ::= GENERATED ALWAYS AS generated */ - 215, /* (363) ccons ::= AS generated */ - 202, /* (364) conslist_opt ::= COMMA conslist */ - 228, /* (365) conslist ::= conslist tconscomma tcons */ - 228, /* (366) conslist ::= tcons */ - 229, /* (367) tconscomma ::= */ - 233, /* (368) defer_subclause_opt ::= defer_subclause */ - 235, /* (369) resolvetype ::= raisetype */ - 239, /* (370) selectnowith ::= oneselect */ - 240, /* (371) oneselect ::= values */ - 254, /* (372) sclp ::= selcollist COMMA */ - 255, /* (373) as ::= ID|STRING */ - 264, /* (374) indexed_opt ::= indexed_by */ - 272, /* (375) returning ::= */ - 217, /* (376) expr ::= term */ - 274, /* (377) likeop ::= LIKE_KW|MATCH */ - 278, /* (378) case_operand ::= expr */ - 261, /* (379) exprlist ::= nexprlist */ - 284, /* (380) nmnum ::= plus_num */ - 284, /* (381) nmnum ::= nm */ - 284, /* (382) nmnum ::= ON */ - 284, /* (383) nmnum ::= DELETE */ - 284, /* (384) nmnum ::= DEFAULT */ - 211, /* (385) plus_num ::= INTEGER|FLOAT */ - 289, /* (386) foreach_clause ::= */ - 289, /* (387) foreach_clause ::= FOR EACH ROW */ - 292, /* (388) trnm ::= nm */ - 293, /* (389) tridxby ::= */ - 294, /* (390) database_kw_opt ::= DATABASE */ - 294, /* (391) database_kw_opt ::= */ - 297, /* (392) kwcolumn_opt ::= */ - 297, /* (393) kwcolumn_opt ::= COLUMNKW */ - 299, /* (394) vtabarglist ::= vtabarg */ - 299, /* (395) vtabarglist ::= vtabarglist COMMA vtabarg */ - 300, /* (396) vtabarg ::= vtabarg vtabargtoken */ - 303, /* (397) anylist ::= */ - 303, /* (398) anylist ::= anylist LP anylist RP */ - 303, /* (399) anylist ::= anylist ANY */ - 266, /* (400) with ::= */ - 306, /* (401) windowdefn_list ::= windowdefn */ - 308, /* (402) window ::= frame_opt */ + 217, /* (188) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */ + 217, /* (189) expr ::= ID|INDEXED|JOIN_KW LP STAR RP */ + 217, /* (190) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */ + 217, /* (191) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */ + 217, /* (192) expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */ + 216, /* (193) term ::= CTIME_KW */ + 217, /* (194) expr ::= LP nexprlist COMMA expr RP */ + 217, /* (195) expr ::= expr AND expr */ + 217, /* (196) expr ::= expr OR expr */ + 217, /* (197) expr ::= expr LT|GT|GE|LE expr */ + 217, /* (198) expr ::= expr EQ|NE expr */ + 217, /* (199) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ + 217, /* (200) expr ::= expr PLUS|MINUS expr */ + 217, /* (201) expr ::= expr STAR|SLASH|REM expr */ + 217, /* (202) expr ::= expr CONCAT expr */ + 274, /* (203) likeop ::= NOT LIKE_KW|MATCH */ + 217, /* (204) expr ::= expr likeop expr */ + 217, /* (205) expr ::= expr likeop expr ESCAPE expr */ + 217, /* (206) expr ::= expr ISNULL|NOTNULL */ + 217, /* (207) expr ::= expr NOT NULL */ + 217, /* (208) expr ::= expr IS expr */ + 217, /* (209) expr ::= expr IS NOT expr */ + 217, /* (210) expr ::= expr IS NOT DISTINCT FROM expr */ + 217, /* (211) expr ::= expr IS DISTINCT FROM expr */ + 217, /* (212) expr ::= NOT expr */ + 217, /* (213) expr ::= BITNOT expr */ + 217, /* (214) expr ::= PLUS|MINUS expr */ + 217, /* (215) expr ::= expr PTR expr */ + 275, /* (216) between_op ::= BETWEEN */ + 275, /* (217) between_op ::= NOT BETWEEN */ + 217, /* (218) expr ::= expr between_op expr AND expr */ + 276, /* (219) in_op ::= IN */ + 276, /* (220) in_op ::= NOT IN */ + 217, /* (221) expr ::= expr in_op LP exprlist RP */ + 217, /* (222) expr ::= LP select RP */ + 217, /* (223) expr ::= expr in_op LP select RP */ + 217, /* (224) expr ::= expr in_op nm dbnm paren_exprlist */ + 217, /* (225) expr ::= EXISTS LP select RP */ + 217, /* (226) expr ::= CASE case_operand case_exprlist case_else END */ + 279, /* (227) case_exprlist ::= case_exprlist WHEN expr THEN expr */ + 279, /* (228) case_exprlist ::= WHEN expr THEN expr */ + 280, /* (229) case_else ::= ELSE expr */ + 280, /* (230) case_else ::= */ + 278, /* (231) case_operand ::= */ + 261, /* (232) exprlist ::= */ + 253, /* (233) nexprlist ::= nexprlist COMMA expr */ + 253, /* (234) nexprlist ::= expr */ + 277, /* (235) paren_exprlist ::= */ + 277, /* (236) paren_exprlist ::= LP exprlist RP */ + 190, /* (237) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ + 281, /* (238) uniqueflag ::= UNIQUE */ + 281, /* (239) uniqueflag ::= */ + 221, /* (240) eidlist_opt ::= */ + 221, /* (241) eidlist_opt ::= LP eidlist RP */ + 232, /* (242) eidlist ::= eidlist COMMA nm collate sortorder */ + 232, /* (243) eidlist ::= nm collate sortorder */ + 282, /* (244) collate ::= */ + 282, /* (245) collate ::= COLLATE ID|STRING */ + 190, /* (246) cmd ::= DROP INDEX ifexists fullname */ + 190, /* (247) cmd ::= VACUUM vinto */ + 190, /* (248) cmd ::= VACUUM nm vinto */ + 283, /* (249) vinto ::= INTO expr */ + 283, /* (250) vinto ::= */ + 190, /* (251) cmd ::= PRAGMA nm dbnm */ + 190, /* (252) cmd ::= PRAGMA nm dbnm EQ nmnum */ + 190, /* (253) cmd ::= PRAGMA nm dbnm LP nmnum RP */ + 190, /* (254) cmd ::= PRAGMA nm dbnm EQ minus_num */ + 190, /* (255) cmd ::= PRAGMA nm dbnm LP minus_num RP */ + 211, /* (256) plus_num ::= PLUS INTEGER|FLOAT */ + 212, /* (257) minus_num ::= MINUS INTEGER|FLOAT */ + 190, /* (258) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ + 285, /* (259) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ + 287, /* (260) trigger_time ::= BEFORE|AFTER */ + 287, /* (261) trigger_time ::= INSTEAD OF */ + 287, /* (262) trigger_time ::= */ + 288, /* (263) trigger_event ::= DELETE|INSERT */ + 288, /* (264) trigger_event ::= UPDATE */ + 288, /* (265) trigger_event ::= UPDATE OF idlist */ + 290, /* (266) when_clause ::= */ + 290, /* (267) when_clause ::= WHEN expr */ + 286, /* (268) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ + 286, /* (269) trigger_cmd_list ::= trigger_cmd SEMI */ + 292, /* (270) trnm ::= nm DOT nm */ + 293, /* (271) tridxby ::= INDEXED BY nm */ + 293, /* (272) tridxby ::= NOT INDEXED */ + 291, /* (273) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ + 291, /* (274) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ + 291, /* (275) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ + 291, /* (276) trigger_cmd ::= scanpt select scanpt */ + 217, /* (277) expr ::= RAISE LP IGNORE RP */ + 217, /* (278) expr ::= RAISE LP raisetype COMMA nm RP */ + 236, /* (279) raisetype ::= ROLLBACK */ + 236, /* (280) raisetype ::= ABORT */ + 236, /* (281) raisetype ::= FAIL */ + 190, /* (282) cmd ::= DROP TRIGGER ifexists fullname */ + 190, /* (283) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ + 190, /* (284) cmd ::= DETACH database_kw_opt expr */ + 295, /* (285) key_opt ::= */ + 295, /* (286) key_opt ::= KEY expr */ + 190, /* (287) cmd ::= REINDEX */ + 190, /* (288) cmd ::= REINDEX nm dbnm */ + 190, /* (289) cmd ::= ANALYZE */ + 190, /* (290) cmd ::= ANALYZE nm dbnm */ + 190, /* (291) cmd ::= ALTER TABLE fullname RENAME TO nm */ + 190, /* (292) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ + 190, /* (293) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ + 296, /* (294) add_column_fullname ::= fullname */ + 190, /* (295) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ + 190, /* (296) cmd ::= create_vtab */ + 190, /* (297) cmd ::= create_vtab LP vtabarglist RP */ + 298, /* (298) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ + 300, /* (299) vtabarg ::= */ + 301, /* (300) vtabargtoken ::= ANY */ + 301, /* (301) vtabargtoken ::= lp anylist RP */ + 302, /* (302) lp ::= LP */ + 266, /* (303) with ::= WITH wqlist */ + 266, /* (304) with ::= WITH RECURSIVE wqlist */ + 305, /* (305) wqas ::= AS */ + 305, /* (306) wqas ::= AS MATERIALIZED */ + 305, /* (307) wqas ::= AS NOT MATERIALIZED */ + 304, /* (308) wqitem ::= nm eidlist_opt wqas LP select RP */ + 241, /* (309) wqlist ::= wqitem */ + 241, /* (310) wqlist ::= wqlist COMMA wqitem */ + 306, /* (311) windowdefn_list ::= windowdefn_list COMMA windowdefn */ + 307, /* (312) windowdefn ::= nm AS LP window RP */ + 308, /* (313) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ + 308, /* (314) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ + 308, /* (315) window ::= ORDER BY sortlist frame_opt */ + 308, /* (316) window ::= nm ORDER BY sortlist frame_opt */ + 308, /* (317) window ::= nm frame_opt */ + 309, /* (318) frame_opt ::= */ + 309, /* (319) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ + 309, /* (320) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ + 313, /* (321) range_or_rows ::= RANGE|ROWS|GROUPS */ + 315, /* (322) frame_bound_s ::= frame_bound */ + 315, /* (323) frame_bound_s ::= UNBOUNDED PRECEDING */ + 316, /* (324) frame_bound_e ::= frame_bound */ + 316, /* (325) frame_bound_e ::= UNBOUNDED FOLLOWING */ + 314, /* (326) frame_bound ::= expr PRECEDING|FOLLOWING */ + 314, /* (327) frame_bound ::= CURRENT ROW */ + 317, /* (328) frame_exclude_opt ::= */ + 317, /* (329) frame_exclude_opt ::= EXCLUDE frame_exclude */ + 318, /* (330) frame_exclude ::= NO OTHERS */ + 318, /* (331) frame_exclude ::= CURRENT ROW */ + 318, /* (332) frame_exclude ::= GROUP|TIES */ + 251, /* (333) window_clause ::= WINDOW windowdefn_list */ + 273, /* (334) filter_over ::= filter_clause over_clause */ + 273, /* (335) filter_over ::= over_clause */ + 273, /* (336) filter_over ::= filter_clause */ + 312, /* (337) over_clause ::= OVER LP window RP */ + 312, /* (338) over_clause ::= OVER nm */ + 311, /* (339) filter_clause ::= FILTER LP WHERE expr RP */ + 185, /* (340) input ::= cmdlist */ + 186, /* (341) cmdlist ::= cmdlist ecmd */ + 186, /* (342) cmdlist ::= ecmd */ + 187, /* (343) ecmd ::= SEMI */ + 187, /* (344) ecmd ::= cmdx SEMI */ + 187, /* (345) ecmd ::= explain cmdx SEMI */ + 192, /* (346) trans_opt ::= */ + 192, /* (347) trans_opt ::= TRANSACTION */ + 192, /* (348) trans_opt ::= TRANSACTION nm */ + 194, /* (349) savepoint_opt ::= SAVEPOINT */ + 194, /* (350) savepoint_opt ::= */ + 190, /* (351) cmd ::= create_table create_table_args */ + 203, /* (352) table_option_set ::= table_option */ + 201, /* (353) columnlist ::= columnlist COMMA columnname carglist */ + 201, /* (354) columnlist ::= columnname carglist */ + 193, /* (355) nm ::= ID|INDEXED|JOIN_KW */ + 193, /* (356) nm ::= STRING */ + 208, /* (357) typetoken ::= typename */ + 209, /* (358) typename ::= ID|STRING */ + 210, /* (359) signed ::= plus_num */ + 210, /* (360) signed ::= minus_num */ + 207, /* (361) carglist ::= carglist ccons */ + 207, /* (362) carglist ::= */ + 215, /* (363) ccons ::= NULL onconf */ + 215, /* (364) ccons ::= GENERATED ALWAYS AS generated */ + 215, /* (365) ccons ::= AS generated */ + 202, /* (366) conslist_opt ::= COMMA conslist */ + 228, /* (367) conslist ::= conslist tconscomma tcons */ + 228, /* (368) conslist ::= tcons */ + 229, /* (369) tconscomma ::= */ + 233, /* (370) defer_subclause_opt ::= defer_subclause */ + 235, /* (371) resolvetype ::= raisetype */ + 239, /* (372) selectnowith ::= oneselect */ + 240, /* (373) oneselect ::= values */ + 254, /* (374) sclp ::= selcollist COMMA */ + 255, /* (375) as ::= ID|STRING */ + 264, /* (376) indexed_opt ::= indexed_by */ + 272, /* (377) returning ::= */ + 217, /* (378) expr ::= term */ + 274, /* (379) likeop ::= LIKE_KW|MATCH */ + 278, /* (380) case_operand ::= expr */ + 261, /* (381) exprlist ::= nexprlist */ + 284, /* (382) nmnum ::= plus_num */ + 284, /* (383) nmnum ::= nm */ + 284, /* (384) nmnum ::= ON */ + 284, /* (385) nmnum ::= DELETE */ + 284, /* (386) nmnum ::= DEFAULT */ + 211, /* (387) plus_num ::= INTEGER|FLOAT */ + 289, /* (388) foreach_clause ::= */ + 289, /* (389) foreach_clause ::= FOR EACH ROW */ + 292, /* (390) trnm ::= nm */ + 293, /* (391) tridxby ::= */ + 294, /* (392) database_kw_opt ::= DATABASE */ + 294, /* (393) database_kw_opt ::= */ + 297, /* (394) kwcolumn_opt ::= */ + 297, /* (395) kwcolumn_opt ::= COLUMNKW */ + 299, /* (396) vtabarglist ::= vtabarg */ + 299, /* (397) vtabarglist ::= vtabarglist COMMA vtabarg */ + 300, /* (398) vtabarg ::= vtabarg vtabargtoken */ + 303, /* (399) anylist ::= */ + 303, /* (400) anylist ::= anylist LP anylist RP */ + 303, /* (401) anylist ::= anylist ANY */ + 266, /* (402) with ::= */ + 306, /* (403) windowdefn_list ::= windowdefn */ + 308, /* (404) window ::= frame_opt */ }; /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number @@ -172547,221 +173636,223 @@ static const signed char yyRuleInfoNRhs[] = { -3, /* (185) expr ::= expr COLLATE ID|STRING */ -6, /* (186) expr ::= CAST LP expr AS typetoken RP */ -5, /* (187) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */ - -4, /* (188) expr ::= ID|INDEXED|JOIN_KW LP STAR RP */ - -6, /* (189) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */ - -5, /* (190) expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */ - -1, /* (191) term ::= CTIME_KW */ - -5, /* (192) expr ::= LP nexprlist COMMA expr RP */ - -3, /* (193) expr ::= expr AND expr */ - -3, /* (194) expr ::= expr OR expr */ - -3, /* (195) expr ::= expr LT|GT|GE|LE expr */ - -3, /* (196) expr ::= expr EQ|NE expr */ - -3, /* (197) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ - -3, /* (198) expr ::= expr PLUS|MINUS expr */ - -3, /* (199) expr ::= expr STAR|SLASH|REM expr */ - -3, /* (200) expr ::= expr CONCAT expr */ - -2, /* (201) likeop ::= NOT LIKE_KW|MATCH */ - -3, /* (202) expr ::= expr likeop expr */ - -5, /* (203) expr ::= expr likeop expr ESCAPE expr */ - -2, /* (204) expr ::= expr ISNULL|NOTNULL */ - -3, /* (205) expr ::= expr NOT NULL */ - -3, /* (206) expr ::= expr IS expr */ - -4, /* (207) expr ::= expr IS NOT expr */ - -6, /* (208) expr ::= expr IS NOT DISTINCT FROM expr */ - -5, /* (209) expr ::= expr IS DISTINCT FROM expr */ - -2, /* (210) expr ::= NOT expr */ - -2, /* (211) expr ::= BITNOT expr */ - -2, /* (212) expr ::= PLUS|MINUS expr */ - -3, /* (213) expr ::= expr PTR expr */ - -1, /* (214) between_op ::= BETWEEN */ - -2, /* (215) between_op ::= NOT BETWEEN */ - -5, /* (216) expr ::= expr between_op expr AND expr */ - -1, /* (217) in_op ::= IN */ - -2, /* (218) in_op ::= NOT IN */ - -5, /* (219) expr ::= expr in_op LP exprlist RP */ - -3, /* (220) expr ::= LP select RP */ - -5, /* (221) expr ::= expr in_op LP select RP */ - -5, /* (222) expr ::= expr in_op nm dbnm paren_exprlist */ - -4, /* (223) expr ::= EXISTS LP select RP */ - -5, /* (224) expr ::= CASE case_operand case_exprlist case_else END */ - -5, /* (225) case_exprlist ::= case_exprlist WHEN expr THEN expr */ - -4, /* (226) case_exprlist ::= WHEN expr THEN expr */ - -2, /* (227) case_else ::= ELSE expr */ - 0, /* (228) case_else ::= */ - 0, /* (229) case_operand ::= */ - 0, /* (230) exprlist ::= */ - -3, /* (231) nexprlist ::= nexprlist COMMA expr */ - -1, /* (232) nexprlist ::= expr */ - 0, /* (233) paren_exprlist ::= */ - -3, /* (234) paren_exprlist ::= LP exprlist RP */ - -12, /* (235) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ - -1, /* (236) uniqueflag ::= UNIQUE */ - 0, /* (237) uniqueflag ::= */ - 0, /* (238) eidlist_opt ::= */ - -3, /* (239) eidlist_opt ::= LP eidlist RP */ - -5, /* (240) eidlist ::= eidlist COMMA nm collate sortorder */ - -3, /* (241) eidlist ::= nm collate sortorder */ - 0, /* (242) collate ::= */ - -2, /* (243) collate ::= COLLATE ID|STRING */ - -4, /* (244) cmd ::= DROP INDEX ifexists fullname */ - -2, /* (245) cmd ::= VACUUM vinto */ - -3, /* (246) cmd ::= VACUUM nm vinto */ - -2, /* (247) vinto ::= INTO expr */ - 0, /* (248) vinto ::= */ - -3, /* (249) cmd ::= PRAGMA nm dbnm */ - -5, /* (250) cmd ::= PRAGMA nm dbnm EQ nmnum */ - -6, /* (251) cmd ::= PRAGMA nm dbnm LP nmnum RP */ - -5, /* (252) cmd ::= PRAGMA nm dbnm EQ minus_num */ - -6, /* (253) cmd ::= PRAGMA nm dbnm LP minus_num RP */ - -2, /* (254) plus_num ::= PLUS INTEGER|FLOAT */ - -2, /* (255) minus_num ::= MINUS INTEGER|FLOAT */ - -5, /* (256) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ - -11, /* (257) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ - -1, /* (258) trigger_time ::= BEFORE|AFTER */ - -2, /* (259) trigger_time ::= INSTEAD OF */ - 0, /* (260) trigger_time ::= */ - -1, /* (261) trigger_event ::= DELETE|INSERT */ - -1, /* (262) trigger_event ::= UPDATE */ - -3, /* (263) trigger_event ::= UPDATE OF idlist */ - 0, /* (264) when_clause ::= */ - -2, /* (265) when_clause ::= WHEN expr */ - -3, /* (266) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ - -2, /* (267) trigger_cmd_list ::= trigger_cmd SEMI */ - -3, /* (268) trnm ::= nm DOT nm */ - -3, /* (269) tridxby ::= INDEXED BY nm */ - -2, /* (270) tridxby ::= NOT INDEXED */ - -9, /* (271) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ - -8, /* (272) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ - -6, /* (273) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ - -3, /* (274) trigger_cmd ::= scanpt select scanpt */ - -4, /* (275) expr ::= RAISE LP IGNORE RP */ - -6, /* (276) expr ::= RAISE LP raisetype COMMA nm RP */ - -1, /* (277) raisetype ::= ROLLBACK */ - -1, /* (278) raisetype ::= ABORT */ - -1, /* (279) raisetype ::= FAIL */ - -4, /* (280) cmd ::= DROP TRIGGER ifexists fullname */ - -6, /* (281) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ - -3, /* (282) cmd ::= DETACH database_kw_opt expr */ - 0, /* (283) key_opt ::= */ - -2, /* (284) key_opt ::= KEY expr */ - -1, /* (285) cmd ::= REINDEX */ - -3, /* (286) cmd ::= REINDEX nm dbnm */ - -1, /* (287) cmd ::= ANALYZE */ - -3, /* (288) cmd ::= ANALYZE nm dbnm */ - -6, /* (289) cmd ::= ALTER TABLE fullname RENAME TO nm */ - -7, /* (290) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ - -6, /* (291) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ - -1, /* (292) add_column_fullname ::= fullname */ - -8, /* (293) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ - -1, /* (294) cmd ::= create_vtab */ - -4, /* (295) cmd ::= create_vtab LP vtabarglist RP */ - -8, /* (296) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ - 0, /* (297) vtabarg ::= */ - -1, /* (298) vtabargtoken ::= ANY */ - -3, /* (299) vtabargtoken ::= lp anylist RP */ - -1, /* (300) lp ::= LP */ - -2, /* (301) with ::= WITH wqlist */ - -3, /* (302) with ::= WITH RECURSIVE wqlist */ - -1, /* (303) wqas ::= AS */ - -2, /* (304) wqas ::= AS MATERIALIZED */ - -3, /* (305) wqas ::= AS NOT MATERIALIZED */ - -6, /* (306) wqitem ::= nm eidlist_opt wqas LP select RP */ - -1, /* (307) wqlist ::= wqitem */ - -3, /* (308) wqlist ::= wqlist COMMA wqitem */ - -3, /* (309) windowdefn_list ::= windowdefn_list COMMA windowdefn */ - -5, /* (310) windowdefn ::= nm AS LP window RP */ - -5, /* (311) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ - -6, /* (312) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ - -4, /* (313) window ::= ORDER BY sortlist frame_opt */ - -5, /* (314) window ::= nm ORDER BY sortlist frame_opt */ - -2, /* (315) window ::= nm frame_opt */ - 0, /* (316) frame_opt ::= */ - -3, /* (317) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ - -6, /* (318) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ - -1, /* (319) range_or_rows ::= RANGE|ROWS|GROUPS */ - -1, /* (320) frame_bound_s ::= frame_bound */ - -2, /* (321) frame_bound_s ::= UNBOUNDED PRECEDING */ - -1, /* (322) frame_bound_e ::= frame_bound */ - -2, /* (323) frame_bound_e ::= UNBOUNDED FOLLOWING */ - -2, /* (324) frame_bound ::= expr PRECEDING|FOLLOWING */ - -2, /* (325) frame_bound ::= CURRENT ROW */ - 0, /* (326) frame_exclude_opt ::= */ - -2, /* (327) frame_exclude_opt ::= EXCLUDE frame_exclude */ - -2, /* (328) frame_exclude ::= NO OTHERS */ - -2, /* (329) frame_exclude ::= CURRENT ROW */ - -1, /* (330) frame_exclude ::= GROUP|TIES */ - -2, /* (331) window_clause ::= WINDOW windowdefn_list */ - -2, /* (332) filter_over ::= filter_clause over_clause */ - -1, /* (333) filter_over ::= over_clause */ - -1, /* (334) filter_over ::= filter_clause */ - -4, /* (335) over_clause ::= OVER LP window RP */ - -2, /* (336) over_clause ::= OVER nm */ - -5, /* (337) filter_clause ::= FILTER LP WHERE expr RP */ - -1, /* (338) input ::= cmdlist */ - -2, /* (339) cmdlist ::= cmdlist ecmd */ - -1, /* (340) cmdlist ::= ecmd */ - -1, /* (341) ecmd ::= SEMI */ - -2, /* (342) ecmd ::= cmdx SEMI */ - -3, /* (343) ecmd ::= explain cmdx SEMI */ - 0, /* (344) trans_opt ::= */ - -1, /* (345) trans_opt ::= TRANSACTION */ - -2, /* (346) trans_opt ::= TRANSACTION nm */ - -1, /* (347) savepoint_opt ::= SAVEPOINT */ - 0, /* (348) savepoint_opt ::= */ - -2, /* (349) cmd ::= create_table create_table_args */ - -1, /* (350) table_option_set ::= table_option */ - -4, /* (351) columnlist ::= columnlist COMMA columnname carglist */ - -2, /* (352) columnlist ::= columnname carglist */ - -1, /* (353) nm ::= ID|INDEXED|JOIN_KW */ - -1, /* (354) nm ::= STRING */ - -1, /* (355) typetoken ::= typename */ - -1, /* (356) typename ::= ID|STRING */ - -1, /* (357) signed ::= plus_num */ - -1, /* (358) signed ::= minus_num */ - -2, /* (359) carglist ::= carglist ccons */ - 0, /* (360) carglist ::= */ - -2, /* (361) ccons ::= NULL onconf */ - -4, /* (362) ccons ::= GENERATED ALWAYS AS generated */ - -2, /* (363) ccons ::= AS generated */ - -2, /* (364) conslist_opt ::= COMMA conslist */ - -3, /* (365) conslist ::= conslist tconscomma tcons */ - -1, /* (366) conslist ::= tcons */ - 0, /* (367) tconscomma ::= */ - -1, /* (368) defer_subclause_opt ::= defer_subclause */ - -1, /* (369) resolvetype ::= raisetype */ - -1, /* (370) selectnowith ::= oneselect */ - -1, /* (371) oneselect ::= values */ - -2, /* (372) sclp ::= selcollist COMMA */ - -1, /* (373) as ::= ID|STRING */ - -1, /* (374) indexed_opt ::= indexed_by */ - 0, /* (375) returning ::= */ - -1, /* (376) expr ::= term */ - -1, /* (377) likeop ::= LIKE_KW|MATCH */ - -1, /* (378) case_operand ::= expr */ - -1, /* (379) exprlist ::= nexprlist */ - -1, /* (380) nmnum ::= plus_num */ - -1, /* (381) nmnum ::= nm */ - -1, /* (382) nmnum ::= ON */ - -1, /* (383) nmnum ::= DELETE */ - -1, /* (384) nmnum ::= DEFAULT */ - -1, /* (385) plus_num ::= INTEGER|FLOAT */ - 0, /* (386) foreach_clause ::= */ - -3, /* (387) foreach_clause ::= FOR EACH ROW */ - -1, /* (388) trnm ::= nm */ - 0, /* (389) tridxby ::= */ - -1, /* (390) database_kw_opt ::= DATABASE */ - 0, /* (391) database_kw_opt ::= */ - 0, /* (392) kwcolumn_opt ::= */ - -1, /* (393) kwcolumn_opt ::= COLUMNKW */ - -1, /* (394) vtabarglist ::= vtabarg */ - -3, /* (395) vtabarglist ::= vtabarglist COMMA vtabarg */ - -2, /* (396) vtabarg ::= vtabarg vtabargtoken */ - 0, /* (397) anylist ::= */ - -4, /* (398) anylist ::= anylist LP anylist RP */ - -2, /* (399) anylist ::= anylist ANY */ - 0, /* (400) with ::= */ - -1, /* (401) windowdefn_list ::= windowdefn */ - -1, /* (402) window ::= frame_opt */ + -8, /* (188) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */ + -4, /* (189) expr ::= ID|INDEXED|JOIN_KW LP STAR RP */ + -6, /* (190) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */ + -9, /* (191) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */ + -5, /* (192) expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */ + -1, /* (193) term ::= CTIME_KW */ + -5, /* (194) expr ::= LP nexprlist COMMA expr RP */ + -3, /* (195) expr ::= expr AND expr */ + -3, /* (196) expr ::= expr OR expr */ + -3, /* (197) expr ::= expr LT|GT|GE|LE expr */ + -3, /* (198) expr ::= expr EQ|NE expr */ + -3, /* (199) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ + -3, /* (200) expr ::= expr PLUS|MINUS expr */ + -3, /* (201) expr ::= expr STAR|SLASH|REM expr */ + -3, /* (202) expr ::= expr CONCAT expr */ + -2, /* (203) likeop ::= NOT LIKE_KW|MATCH */ + -3, /* (204) expr ::= expr likeop expr */ + -5, /* (205) expr ::= expr likeop expr ESCAPE expr */ + -2, /* (206) expr ::= expr ISNULL|NOTNULL */ + -3, /* (207) expr ::= expr NOT NULL */ + -3, /* (208) expr ::= expr IS expr */ + -4, /* (209) expr ::= expr IS NOT expr */ + -6, /* (210) expr ::= expr IS NOT DISTINCT FROM expr */ + -5, /* (211) expr ::= expr IS DISTINCT FROM expr */ + -2, /* (212) expr ::= NOT expr */ + -2, /* (213) expr ::= BITNOT expr */ + -2, /* (214) expr ::= PLUS|MINUS expr */ + -3, /* (215) expr ::= expr PTR expr */ + -1, /* (216) between_op ::= BETWEEN */ + -2, /* (217) between_op ::= NOT BETWEEN */ + -5, /* (218) expr ::= expr between_op expr AND expr */ + -1, /* (219) in_op ::= IN */ + -2, /* (220) in_op ::= NOT IN */ + -5, /* (221) expr ::= expr in_op LP exprlist RP */ + -3, /* (222) expr ::= LP select RP */ + -5, /* (223) expr ::= expr in_op LP select RP */ + -5, /* (224) expr ::= expr in_op nm dbnm paren_exprlist */ + -4, /* (225) expr ::= EXISTS LP select RP */ + -5, /* (226) expr ::= CASE case_operand case_exprlist case_else END */ + -5, /* (227) case_exprlist ::= case_exprlist WHEN expr THEN expr */ + -4, /* (228) case_exprlist ::= WHEN expr THEN expr */ + -2, /* (229) case_else ::= ELSE expr */ + 0, /* (230) case_else ::= */ + 0, /* (231) case_operand ::= */ + 0, /* (232) exprlist ::= */ + -3, /* (233) nexprlist ::= nexprlist COMMA expr */ + -1, /* (234) nexprlist ::= expr */ + 0, /* (235) paren_exprlist ::= */ + -3, /* (236) paren_exprlist ::= LP exprlist RP */ + -12, /* (237) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ + -1, /* (238) uniqueflag ::= UNIQUE */ + 0, /* (239) uniqueflag ::= */ + 0, /* (240) eidlist_opt ::= */ + -3, /* (241) eidlist_opt ::= LP eidlist RP */ + -5, /* (242) eidlist ::= eidlist COMMA nm collate sortorder */ + -3, /* (243) eidlist ::= nm collate sortorder */ + 0, /* (244) collate ::= */ + -2, /* (245) collate ::= COLLATE ID|STRING */ + -4, /* (246) cmd ::= DROP INDEX ifexists fullname */ + -2, /* (247) cmd ::= VACUUM vinto */ + -3, /* (248) cmd ::= VACUUM nm vinto */ + -2, /* (249) vinto ::= INTO expr */ + 0, /* (250) vinto ::= */ + -3, /* (251) cmd ::= PRAGMA nm dbnm */ + -5, /* (252) cmd ::= PRAGMA nm dbnm EQ nmnum */ + -6, /* (253) cmd ::= PRAGMA nm dbnm LP nmnum RP */ + -5, /* (254) cmd ::= PRAGMA nm dbnm EQ minus_num */ + -6, /* (255) cmd ::= PRAGMA nm dbnm LP minus_num RP */ + -2, /* (256) plus_num ::= PLUS INTEGER|FLOAT */ + -2, /* (257) minus_num ::= MINUS INTEGER|FLOAT */ + -5, /* (258) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ + -11, /* (259) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ + -1, /* (260) trigger_time ::= BEFORE|AFTER */ + -2, /* (261) trigger_time ::= INSTEAD OF */ + 0, /* (262) trigger_time ::= */ + -1, /* (263) trigger_event ::= DELETE|INSERT */ + -1, /* (264) trigger_event ::= UPDATE */ + -3, /* (265) trigger_event ::= UPDATE OF idlist */ + 0, /* (266) when_clause ::= */ + -2, /* (267) when_clause ::= WHEN expr */ + -3, /* (268) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ + -2, /* (269) trigger_cmd_list ::= trigger_cmd SEMI */ + -3, /* (270) trnm ::= nm DOT nm */ + -3, /* (271) tridxby ::= INDEXED BY nm */ + -2, /* (272) tridxby ::= NOT INDEXED */ + -9, /* (273) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ + -8, /* (274) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ + -6, /* (275) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ + -3, /* (276) trigger_cmd ::= scanpt select scanpt */ + -4, /* (277) expr ::= RAISE LP IGNORE RP */ + -6, /* (278) expr ::= RAISE LP raisetype COMMA nm RP */ + -1, /* (279) raisetype ::= ROLLBACK */ + -1, /* (280) raisetype ::= ABORT */ + -1, /* (281) raisetype ::= FAIL */ + -4, /* (282) cmd ::= DROP TRIGGER ifexists fullname */ + -6, /* (283) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ + -3, /* (284) cmd ::= DETACH database_kw_opt expr */ + 0, /* (285) key_opt ::= */ + -2, /* (286) key_opt ::= KEY expr */ + -1, /* (287) cmd ::= REINDEX */ + -3, /* (288) cmd ::= REINDEX nm dbnm */ + -1, /* (289) cmd ::= ANALYZE */ + -3, /* (290) cmd ::= ANALYZE nm dbnm */ + -6, /* (291) cmd ::= ALTER TABLE fullname RENAME TO nm */ + -7, /* (292) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ + -6, /* (293) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ + -1, /* (294) add_column_fullname ::= fullname */ + -8, /* (295) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ + -1, /* (296) cmd ::= create_vtab */ + -4, /* (297) cmd ::= create_vtab LP vtabarglist RP */ + -8, /* (298) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ + 0, /* (299) vtabarg ::= */ + -1, /* (300) vtabargtoken ::= ANY */ + -3, /* (301) vtabargtoken ::= lp anylist RP */ + -1, /* (302) lp ::= LP */ + -2, /* (303) with ::= WITH wqlist */ + -3, /* (304) with ::= WITH RECURSIVE wqlist */ + -1, /* (305) wqas ::= AS */ + -2, /* (306) wqas ::= AS MATERIALIZED */ + -3, /* (307) wqas ::= AS NOT MATERIALIZED */ + -6, /* (308) wqitem ::= nm eidlist_opt wqas LP select RP */ + -1, /* (309) wqlist ::= wqitem */ + -3, /* (310) wqlist ::= wqlist COMMA wqitem */ + -3, /* (311) windowdefn_list ::= windowdefn_list COMMA windowdefn */ + -5, /* (312) windowdefn ::= nm AS LP window RP */ + -5, /* (313) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ + -6, /* (314) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ + -4, /* (315) window ::= ORDER BY sortlist frame_opt */ + -5, /* (316) window ::= nm ORDER BY sortlist frame_opt */ + -2, /* (317) window ::= nm frame_opt */ + 0, /* (318) frame_opt ::= */ + -3, /* (319) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ + -6, /* (320) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ + -1, /* (321) range_or_rows ::= RANGE|ROWS|GROUPS */ + -1, /* (322) frame_bound_s ::= frame_bound */ + -2, /* (323) frame_bound_s ::= UNBOUNDED PRECEDING */ + -1, /* (324) frame_bound_e ::= frame_bound */ + -2, /* (325) frame_bound_e ::= UNBOUNDED FOLLOWING */ + -2, /* (326) frame_bound ::= expr PRECEDING|FOLLOWING */ + -2, /* (327) frame_bound ::= CURRENT ROW */ + 0, /* (328) frame_exclude_opt ::= */ + -2, /* (329) frame_exclude_opt ::= EXCLUDE frame_exclude */ + -2, /* (330) frame_exclude ::= NO OTHERS */ + -2, /* (331) frame_exclude ::= CURRENT ROW */ + -1, /* (332) frame_exclude ::= GROUP|TIES */ + -2, /* (333) window_clause ::= WINDOW windowdefn_list */ + -2, /* (334) filter_over ::= filter_clause over_clause */ + -1, /* (335) filter_over ::= over_clause */ + -1, /* (336) filter_over ::= filter_clause */ + -4, /* (337) over_clause ::= OVER LP window RP */ + -2, /* (338) over_clause ::= OVER nm */ + -5, /* (339) filter_clause ::= FILTER LP WHERE expr RP */ + -1, /* (340) input ::= cmdlist */ + -2, /* (341) cmdlist ::= cmdlist ecmd */ + -1, /* (342) cmdlist ::= ecmd */ + -1, /* (343) ecmd ::= SEMI */ + -2, /* (344) ecmd ::= cmdx SEMI */ + -3, /* (345) ecmd ::= explain cmdx SEMI */ + 0, /* (346) trans_opt ::= */ + -1, /* (347) trans_opt ::= TRANSACTION */ + -2, /* (348) trans_opt ::= TRANSACTION nm */ + -1, /* (349) savepoint_opt ::= SAVEPOINT */ + 0, /* (350) savepoint_opt ::= */ + -2, /* (351) cmd ::= create_table create_table_args */ + -1, /* (352) table_option_set ::= table_option */ + -4, /* (353) columnlist ::= columnlist COMMA columnname carglist */ + -2, /* (354) columnlist ::= columnname carglist */ + -1, /* (355) nm ::= ID|INDEXED|JOIN_KW */ + -1, /* (356) nm ::= STRING */ + -1, /* (357) typetoken ::= typename */ + -1, /* (358) typename ::= ID|STRING */ + -1, /* (359) signed ::= plus_num */ + -1, /* (360) signed ::= minus_num */ + -2, /* (361) carglist ::= carglist ccons */ + 0, /* (362) carglist ::= */ + -2, /* (363) ccons ::= NULL onconf */ + -4, /* (364) ccons ::= GENERATED ALWAYS AS generated */ + -2, /* (365) ccons ::= AS generated */ + -2, /* (366) conslist_opt ::= COMMA conslist */ + -3, /* (367) conslist ::= conslist tconscomma tcons */ + -1, /* (368) conslist ::= tcons */ + 0, /* (369) tconscomma ::= */ + -1, /* (370) defer_subclause_opt ::= defer_subclause */ + -1, /* (371) resolvetype ::= raisetype */ + -1, /* (372) selectnowith ::= oneselect */ + -1, /* (373) oneselect ::= values */ + -2, /* (374) sclp ::= selcollist COMMA */ + -1, /* (375) as ::= ID|STRING */ + -1, /* (376) indexed_opt ::= indexed_by */ + 0, /* (377) returning ::= */ + -1, /* (378) expr ::= term */ + -1, /* (379) likeop ::= LIKE_KW|MATCH */ + -1, /* (380) case_operand ::= expr */ + -1, /* (381) exprlist ::= nexprlist */ + -1, /* (382) nmnum ::= plus_num */ + -1, /* (383) nmnum ::= nm */ + -1, /* (384) nmnum ::= ON */ + -1, /* (385) nmnum ::= DELETE */ + -1, /* (386) nmnum ::= DEFAULT */ + -1, /* (387) plus_num ::= INTEGER|FLOAT */ + 0, /* (388) foreach_clause ::= */ + -3, /* (389) foreach_clause ::= FOR EACH ROW */ + -1, /* (390) trnm ::= nm */ + 0, /* (391) tridxby ::= */ + -1, /* (392) database_kw_opt ::= DATABASE */ + 0, /* (393) database_kw_opt ::= */ + 0, /* (394) kwcolumn_opt ::= */ + -1, /* (395) kwcolumn_opt ::= COLUMNKW */ + -1, /* (396) vtabarglist ::= vtabarg */ + -3, /* (397) vtabarglist ::= vtabarglist COMMA vtabarg */ + -2, /* (398) vtabarg ::= vtabarg vtabargtoken */ + 0, /* (399) anylist ::= */ + -4, /* (400) anylist ::= anylist LP anylist RP */ + -2, /* (401) anylist ::= anylist ANY */ + 0, /* (402) with ::= */ + -1, /* (403) windowdefn_list ::= windowdefn */ + -1, /* (404) window ::= frame_opt */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -172821,7 +173912,7 @@ static YYACTIONTYPE yy_reduce( case 5: /* transtype ::= DEFERRED */ case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6); case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7); - case 319: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==319); + case 321: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==321); {yymsp[0].minor.yy394 = yymsp[0].major; /*A-overwrites-X*/} break; case 8: /* cmd ::= COMMIT|END trans_opt */ @@ -172858,7 +173949,7 @@ static YYACTIONTYPE yy_reduce( case 72: /* defer_subclause_opt ::= */ yytestcase(yyruleno==72); case 81: /* ifexists ::= */ yytestcase(yyruleno==81); case 98: /* distinct ::= */ yytestcase(yyruleno==98); - case 242: /* collate ::= */ yytestcase(yyruleno==242); + case 244: /* collate ::= */ yytestcase(yyruleno==244); {yymsp[1].minor.yy394 = 0;} break; case 16: /* ifnotexists ::= IF NOT EXISTS */ @@ -173042,9 +174133,9 @@ static YYACTIONTYPE yy_reduce( break; case 63: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ case 80: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==80); - case 215: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==215); - case 218: /* in_op ::= NOT IN */ yytestcase(yyruleno==218); - case 243: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==243); + case 217: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==217); + case 220: /* in_op ::= NOT IN */ yytestcase(yyruleno==220); + case 245: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==245); {yymsp[-1].minor.yy394 = 1;} break; case 64: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ @@ -173193,9 +174284,9 @@ static YYACTIONTYPE yy_reduce( case 99: /* sclp ::= */ case 132: /* orderby_opt ::= */ yytestcase(yyruleno==132); case 142: /* groupby_opt ::= */ yytestcase(yyruleno==142); - case 230: /* exprlist ::= */ yytestcase(yyruleno==230); - case 233: /* paren_exprlist ::= */ yytestcase(yyruleno==233); - case 238: /* eidlist_opt ::= */ yytestcase(yyruleno==238); + case 232: /* exprlist ::= */ yytestcase(yyruleno==232); + case 235: /* paren_exprlist ::= */ yytestcase(yyruleno==235); + case 240: /* eidlist_opt ::= */ yytestcase(yyruleno==240); {yymsp[1].minor.yy322 = 0;} break; case 100: /* selcollist ::= sclp scanpt expr scanpt as */ @@ -173224,8 +174315,8 @@ static YYACTIONTYPE yy_reduce( break; case 103: /* as ::= AS nm */ case 115: /* dbnm ::= DOT nm */ yytestcase(yyruleno==115); - case 254: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==254); - case 255: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==255); + case 256: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==256); + case 257: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==257); {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;} break; case 105: /* from ::= */ @@ -173397,16 +174488,16 @@ static YYACTIONTYPE yy_reduce( case 146: /* limit_opt ::= */ yytestcase(yyruleno==146); case 151: /* where_opt ::= */ yytestcase(yyruleno==151); case 153: /* where_opt_ret ::= */ yytestcase(yyruleno==153); - case 228: /* case_else ::= */ yytestcase(yyruleno==228); - case 229: /* case_operand ::= */ yytestcase(yyruleno==229); - case 248: /* vinto ::= */ yytestcase(yyruleno==248); + case 230: /* case_else ::= */ yytestcase(yyruleno==230); + case 231: /* case_operand ::= */ yytestcase(yyruleno==231); + case 250: /* vinto ::= */ yytestcase(yyruleno==250); {yymsp[1].minor.yy528 = 0;} break; case 145: /* having_opt ::= HAVING expr */ case 152: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==152); case 154: /* where_opt_ret ::= WHERE expr */ yytestcase(yyruleno==154); - case 227: /* case_else ::= ELSE expr */ yytestcase(yyruleno==227); - case 247: /* vinto ::= INTO expr */ yytestcase(yyruleno==247); + case 229: /* case_else ::= ELSE expr */ yytestcase(yyruleno==229); + case 249: /* vinto ::= INTO expr */ yytestcase(yyruleno==249); {yymsp[-1].minor.yy528 = yymsp[0].minor.yy528;} break; case 147: /* limit_opt ::= LIMIT expr */ @@ -173592,33 +174683,48 @@ static YYACTIONTYPE yy_reduce( } yymsp[-4].minor.yy528 = yylhsminor.yy528; break; - case 188: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP */ + case 188: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */ +{ + yylhsminor.yy528 = sqlite3ExprFunction(pParse, yymsp[-4].minor.yy322, &yymsp[-7].minor.yy0, yymsp[-5].minor.yy394); + sqlite3ExprAddFunctionOrderBy(pParse, yylhsminor.yy528, yymsp[-1].minor.yy322); +} + yymsp[-7].minor.yy528 = yylhsminor.yy528; + break; + case 189: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP */ { yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0); } yymsp[-3].minor.yy528 = yylhsminor.yy528; break; - case 189: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */ + case 190: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */ { yylhsminor.yy528 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy322, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy394); sqlite3WindowAttach(pParse, yylhsminor.yy528, yymsp[0].minor.yy41); } yymsp[-5].minor.yy528 = yylhsminor.yy528; break; - case 190: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */ + case 191: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */ +{ + yylhsminor.yy528 = sqlite3ExprFunction(pParse, yymsp[-5].minor.yy322, &yymsp[-8].minor.yy0, yymsp[-6].minor.yy394); + sqlite3WindowAttach(pParse, yylhsminor.yy528, yymsp[0].minor.yy41); + sqlite3ExprAddFunctionOrderBy(pParse, yylhsminor.yy528, yymsp[-2].minor.yy322); +} + yymsp[-8].minor.yy528 = yylhsminor.yy528; + break; + case 192: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */ { yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0); sqlite3WindowAttach(pParse, yylhsminor.yy528, yymsp[0].minor.yy41); } yymsp[-4].minor.yy528 = yylhsminor.yy528; break; - case 191: /* term ::= CTIME_KW */ + case 193: /* term ::= CTIME_KW */ { yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0); } yymsp[0].minor.yy528 = yylhsminor.yy528; break; - case 192: /* expr ::= LP nexprlist COMMA expr RP */ + case 194: /* expr ::= LP nexprlist COMMA expr RP */ { ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy322, yymsp[-1].minor.yy528); yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0); @@ -173632,22 +174738,22 @@ static YYACTIONTYPE yy_reduce( } } break; - case 193: /* expr ::= expr AND expr */ + case 195: /* expr ::= expr AND expr */ {yymsp[-2].minor.yy528=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy528,yymsp[0].minor.yy528);} break; - case 194: /* expr ::= expr OR expr */ - case 195: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==195); - case 196: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==196); - case 197: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==197); - case 198: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==198); - case 199: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==199); - case 200: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==200); + case 196: /* expr ::= expr OR expr */ + case 197: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==197); + case 198: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==198); + case 199: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==199); + case 200: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==200); + case 201: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==201); + case 202: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==202); {yymsp[-2].minor.yy528=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy528,yymsp[0].minor.yy528);} break; - case 201: /* likeop ::= NOT LIKE_KW|MATCH */ + case 203: /* likeop ::= NOT LIKE_KW|MATCH */ {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/} break; - case 202: /* expr ::= expr likeop expr */ + case 204: /* expr ::= expr likeop expr */ { ExprList *pList; int bNot = yymsp[-1].minor.yy0.n & 0x80000000; @@ -173659,7 +174765,7 @@ static YYACTIONTYPE yy_reduce( if( yymsp[-2].minor.yy528 ) yymsp[-2].minor.yy528->flags |= EP_InfixFunc; } break; - case 203: /* expr ::= expr likeop expr ESCAPE expr */ + case 205: /* expr ::= expr likeop expr ESCAPE expr */ { ExprList *pList; int bNot = yymsp[-3].minor.yy0.n & 0x80000000; @@ -173672,47 +174778,47 @@ static YYACTIONTYPE yy_reduce( if( yymsp[-4].minor.yy528 ) yymsp[-4].minor.yy528->flags |= EP_InfixFunc; } break; - case 204: /* expr ::= expr ISNULL|NOTNULL */ + case 206: /* expr ::= expr ISNULL|NOTNULL */ {yymsp[-1].minor.yy528 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy528,0);} break; - case 205: /* expr ::= expr NOT NULL */ + case 207: /* expr ::= expr NOT NULL */ {yymsp[-2].minor.yy528 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy528,0);} break; - case 206: /* expr ::= expr IS expr */ + case 208: /* expr ::= expr IS expr */ { yymsp[-2].minor.yy528 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy528,yymsp[0].minor.yy528); binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-2].minor.yy528, TK_ISNULL); } break; - case 207: /* expr ::= expr IS NOT expr */ + case 209: /* expr ::= expr IS NOT expr */ { yymsp[-3].minor.yy528 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy528,yymsp[0].minor.yy528); binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-3].minor.yy528, TK_NOTNULL); } break; - case 208: /* expr ::= expr IS NOT DISTINCT FROM expr */ + case 210: /* expr ::= expr IS NOT DISTINCT FROM expr */ { yymsp[-5].minor.yy528 = sqlite3PExpr(pParse,TK_IS,yymsp[-5].minor.yy528,yymsp[0].minor.yy528); binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-5].minor.yy528, TK_ISNULL); } break; - case 209: /* expr ::= expr IS DISTINCT FROM expr */ + case 211: /* expr ::= expr IS DISTINCT FROM expr */ { yymsp[-4].minor.yy528 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-4].minor.yy528,yymsp[0].minor.yy528); binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-4].minor.yy528, TK_NOTNULL); } break; - case 210: /* expr ::= NOT expr */ - case 211: /* expr ::= BITNOT expr */ yytestcase(yyruleno==211); + case 212: /* expr ::= NOT expr */ + case 213: /* expr ::= BITNOT expr */ yytestcase(yyruleno==213); {yymsp[-1].minor.yy528 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy528, 0);/*A-overwrites-B*/} break; - case 212: /* expr ::= PLUS|MINUS expr */ + case 214: /* expr ::= PLUS|MINUS expr */ { yymsp[-1].minor.yy528 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy528, 0); /*A-overwrites-B*/ } break; - case 213: /* expr ::= expr PTR expr */ + case 215: /* expr ::= expr PTR expr */ { ExprList *pList = sqlite3ExprListAppend(pParse, 0, yymsp[-2].minor.yy528); pList = sqlite3ExprListAppend(pParse, pList, yymsp[0].minor.yy528); @@ -173720,11 +174826,11 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy528 = yylhsminor.yy528; break; - case 214: /* between_op ::= BETWEEN */ - case 217: /* in_op ::= IN */ yytestcase(yyruleno==217); + case 216: /* between_op ::= BETWEEN */ + case 219: /* in_op ::= IN */ yytestcase(yyruleno==219); {yymsp[0].minor.yy394 = 0;} break; - case 216: /* expr ::= expr between_op expr AND expr */ + case 218: /* expr ::= expr between_op expr AND expr */ { ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy528); pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy528); @@ -173737,7 +174843,7 @@ static YYACTIONTYPE yy_reduce( if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0); } break; - case 219: /* expr ::= expr in_op LP exprlist RP */ + case 221: /* expr ::= expr in_op LP exprlist RP */ { if( yymsp[-1].minor.yy322==0 ){ /* Expressions of the form @@ -173783,20 +174889,20 @@ static YYACTIONTYPE yy_reduce( } } break; - case 220: /* expr ::= LP select RP */ + case 222: /* expr ::= LP select RP */ { yymsp[-2].minor.yy528 = sqlite3PExpr(pParse, TK_SELECT, 0, 0); sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy528, yymsp[-1].minor.yy47); } break; - case 221: /* expr ::= expr in_op LP select RP */ + case 223: /* expr ::= expr in_op LP select RP */ { yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy528, 0); sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy528, yymsp[-1].minor.yy47); if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0); } break; - case 222: /* expr ::= expr in_op nm dbnm paren_exprlist */ + case 224: /* expr ::= expr in_op nm dbnm paren_exprlist */ { SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0); @@ -173806,14 +174912,14 @@ static YYACTIONTYPE yy_reduce( if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0); } break; - case 223: /* expr ::= EXISTS LP select RP */ + case 225: /* expr ::= EXISTS LP select RP */ { Expr *p; p = yymsp[-3].minor.yy528 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0); sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy47); } break; - case 224: /* expr ::= CASE case_operand case_exprlist case_else END */ + case 226: /* expr ::= CASE case_operand case_exprlist case_else END */ { yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy528, 0); if( yymsp[-4].minor.yy528 ){ @@ -173825,29 +174931,29 @@ static YYACTIONTYPE yy_reduce( } } break; - case 225: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ + case 227: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ { yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[-2].minor.yy528); yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[0].minor.yy528); } break; - case 226: /* case_exprlist ::= WHEN expr THEN expr */ + case 228: /* case_exprlist ::= WHEN expr THEN expr */ { yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy528); yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy322, yymsp[0].minor.yy528); } break; - case 231: /* nexprlist ::= nexprlist COMMA expr */ + case 233: /* nexprlist ::= nexprlist COMMA expr */ {yymsp[-2].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[0].minor.yy528);} break; - case 232: /* nexprlist ::= expr */ + case 234: /* nexprlist ::= expr */ {yymsp[0].minor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy528); /*A-overwrites-Y*/} break; - case 234: /* paren_exprlist ::= LP exprlist RP */ - case 239: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==239); + case 236: /* paren_exprlist ::= LP exprlist RP */ + case 241: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==241); {yymsp[-2].minor.yy322 = yymsp[-1].minor.yy322;} break; - case 235: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ + case 237: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ { sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy322, yymsp[-10].minor.yy394, @@ -173857,48 +174963,48 @@ static YYACTIONTYPE yy_reduce( } } break; - case 236: /* uniqueflag ::= UNIQUE */ - case 278: /* raisetype ::= ABORT */ yytestcase(yyruleno==278); + case 238: /* uniqueflag ::= UNIQUE */ + case 280: /* raisetype ::= ABORT */ yytestcase(yyruleno==280); {yymsp[0].minor.yy394 = OE_Abort;} break; - case 237: /* uniqueflag ::= */ + case 239: /* uniqueflag ::= */ {yymsp[1].minor.yy394 = OE_None;} break; - case 240: /* eidlist ::= eidlist COMMA nm collate sortorder */ + case 242: /* eidlist ::= eidlist COMMA nm collate sortorder */ { yymsp[-4].minor.yy322 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy322, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy394, yymsp[0].minor.yy394); } break; - case 241: /* eidlist ::= nm collate sortorder */ + case 243: /* eidlist ::= nm collate sortorder */ { yymsp[-2].minor.yy322 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy394, yymsp[0].minor.yy394); /*A-overwrites-Y*/ } break; - case 244: /* cmd ::= DROP INDEX ifexists fullname */ + case 246: /* cmd ::= DROP INDEX ifexists fullname */ {sqlite3DropIndex(pParse, yymsp[0].minor.yy131, yymsp[-1].minor.yy394);} break; - case 245: /* cmd ::= VACUUM vinto */ + case 247: /* cmd ::= VACUUM vinto */ {sqlite3Vacuum(pParse,0,yymsp[0].minor.yy528);} break; - case 246: /* cmd ::= VACUUM nm vinto */ + case 248: /* cmd ::= VACUUM nm vinto */ {sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy528);} break; - case 249: /* cmd ::= PRAGMA nm dbnm */ + case 251: /* cmd ::= PRAGMA nm dbnm */ {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);} break; - case 250: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ + case 252: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);} break; - case 251: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ + case 253: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);} break; - case 252: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ + case 254: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);} break; - case 253: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ + case 255: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);} break; - case 256: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ + case 258: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ { Token all; all.z = yymsp[-3].minor.yy0.z; @@ -173906,50 +175012,50 @@ static YYACTIONTYPE yy_reduce( sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy33, &all); } break; - case 257: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ + case 259: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ { sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy394, yymsp[-4].minor.yy180.a, yymsp[-4].minor.yy180.b, yymsp[-2].minor.yy131, yymsp[0].minor.yy528, yymsp[-10].minor.yy394, yymsp[-8].minor.yy394); yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/ } break; - case 258: /* trigger_time ::= BEFORE|AFTER */ + case 260: /* trigger_time ::= BEFORE|AFTER */ { yymsp[0].minor.yy394 = yymsp[0].major; /*A-overwrites-X*/ } break; - case 259: /* trigger_time ::= INSTEAD OF */ + case 261: /* trigger_time ::= INSTEAD OF */ { yymsp[-1].minor.yy394 = TK_INSTEAD;} break; - case 260: /* trigger_time ::= */ + case 262: /* trigger_time ::= */ { yymsp[1].minor.yy394 = TK_BEFORE; } break; - case 261: /* trigger_event ::= DELETE|INSERT */ - case 262: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==262); + case 263: /* trigger_event ::= DELETE|INSERT */ + case 264: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==264); {yymsp[0].minor.yy180.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy180.b = 0;} break; - case 263: /* trigger_event ::= UPDATE OF idlist */ + case 265: /* trigger_event ::= UPDATE OF idlist */ {yymsp[-2].minor.yy180.a = TK_UPDATE; yymsp[-2].minor.yy180.b = yymsp[0].minor.yy254;} break; - case 264: /* when_clause ::= */ - case 283: /* key_opt ::= */ yytestcase(yyruleno==283); + case 266: /* when_clause ::= */ + case 285: /* key_opt ::= */ yytestcase(yyruleno==285); { yymsp[1].minor.yy528 = 0; } break; - case 265: /* when_clause ::= WHEN expr */ - case 284: /* key_opt ::= KEY expr */ yytestcase(yyruleno==284); + case 267: /* when_clause ::= WHEN expr */ + case 286: /* key_opt ::= KEY expr */ yytestcase(yyruleno==286); { yymsp[-1].minor.yy528 = yymsp[0].minor.yy528; } break; - case 266: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ + case 268: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ { assert( yymsp[-2].minor.yy33!=0 ); yymsp[-2].minor.yy33->pLast->pNext = yymsp[-1].minor.yy33; yymsp[-2].minor.yy33->pLast = yymsp[-1].minor.yy33; } break; - case 267: /* trigger_cmd_list ::= trigger_cmd SEMI */ + case 269: /* trigger_cmd_list ::= trigger_cmd SEMI */ { assert( yymsp[-1].minor.yy33!=0 ); yymsp[-1].minor.yy33->pLast = yymsp[-1].minor.yy33; } break; - case 268: /* trnm ::= nm DOT nm */ + case 270: /* trnm ::= nm DOT nm */ { yymsp[-2].minor.yy0 = yymsp[0].minor.yy0; sqlite3ErrorMsg(pParse, @@ -173957,39 +175063,39 @@ static YYACTIONTYPE yy_reduce( "statements within triggers"); } break; - case 269: /* tridxby ::= INDEXED BY nm */ + case 271: /* tridxby ::= INDEXED BY nm */ { sqlite3ErrorMsg(pParse, "the INDEXED BY clause is not allowed on UPDATE or DELETE statements " "within triggers"); } break; - case 270: /* tridxby ::= NOT INDEXED */ + case 272: /* tridxby ::= NOT INDEXED */ { sqlite3ErrorMsg(pParse, "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements " "within triggers"); } break; - case 271: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ + case 273: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ {yylhsminor.yy33 = sqlite3TriggerUpdateStep(pParse, &yymsp[-6].minor.yy0, yymsp[-2].minor.yy131, yymsp[-3].minor.yy322, yymsp[-1].minor.yy528, yymsp[-7].minor.yy394, yymsp[-8].minor.yy0.z, yymsp[0].minor.yy522);} yymsp[-8].minor.yy33 = yylhsminor.yy33; break; - case 272: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ + case 274: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ { yylhsminor.yy33 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy254,yymsp[-2].minor.yy47,yymsp[-6].minor.yy394,yymsp[-1].minor.yy444,yymsp[-7].minor.yy522,yymsp[0].minor.yy522);/*yylhsminor.yy33-overwrites-yymsp[-6].minor.yy394*/ } yymsp[-7].minor.yy33 = yylhsminor.yy33; break; - case 273: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ + case 275: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ {yylhsminor.yy33 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy528, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy522);} yymsp[-5].minor.yy33 = yylhsminor.yy33; break; - case 274: /* trigger_cmd ::= scanpt select scanpt */ + case 276: /* trigger_cmd ::= scanpt select scanpt */ {yylhsminor.yy33 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy47, yymsp[-2].minor.yy522, yymsp[0].minor.yy522); /*yylhsminor.yy33-overwrites-yymsp[-1].minor.yy47*/} yymsp[-2].minor.yy33 = yylhsminor.yy33; break; - case 275: /* expr ::= RAISE LP IGNORE RP */ + case 277: /* expr ::= RAISE LP IGNORE RP */ { yymsp[-3].minor.yy528 = sqlite3PExpr(pParse, TK_RAISE, 0, 0); if( yymsp[-3].minor.yy528 ){ @@ -173997,7 +175103,7 @@ static YYACTIONTYPE yy_reduce( } } break; - case 276: /* expr ::= RAISE LP raisetype COMMA nm RP */ + case 278: /* expr ::= RAISE LP raisetype COMMA nm RP */ { yymsp[-5].minor.yy528 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1); if( yymsp[-5].minor.yy528 ) { @@ -174005,114 +175111,114 @@ static YYACTIONTYPE yy_reduce( } } break; - case 277: /* raisetype ::= ROLLBACK */ + case 279: /* raisetype ::= ROLLBACK */ {yymsp[0].minor.yy394 = OE_Rollback;} break; - case 279: /* raisetype ::= FAIL */ + case 281: /* raisetype ::= FAIL */ {yymsp[0].minor.yy394 = OE_Fail;} break; - case 280: /* cmd ::= DROP TRIGGER ifexists fullname */ + case 282: /* cmd ::= DROP TRIGGER ifexists fullname */ { sqlite3DropTrigger(pParse,yymsp[0].minor.yy131,yymsp[-1].minor.yy394); } break; - case 281: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ + case 283: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ { sqlite3Attach(pParse, yymsp[-3].minor.yy528, yymsp[-1].minor.yy528, yymsp[0].minor.yy528); } break; - case 282: /* cmd ::= DETACH database_kw_opt expr */ + case 284: /* cmd ::= DETACH database_kw_opt expr */ { sqlite3Detach(pParse, yymsp[0].minor.yy528); } break; - case 285: /* cmd ::= REINDEX */ + case 287: /* cmd ::= REINDEX */ {sqlite3Reindex(pParse, 0, 0);} break; - case 286: /* cmd ::= REINDEX nm dbnm */ + case 288: /* cmd ::= REINDEX nm dbnm */ {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} break; - case 287: /* cmd ::= ANALYZE */ + case 289: /* cmd ::= ANALYZE */ {sqlite3Analyze(pParse, 0, 0);} break; - case 288: /* cmd ::= ANALYZE nm dbnm */ + case 290: /* cmd ::= ANALYZE nm dbnm */ {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} break; - case 289: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ + case 291: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ { sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy131,&yymsp[0].minor.yy0); } break; - case 290: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ + case 292: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ { yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n; sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0); } break; - case 291: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ + case 293: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ { sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy131, &yymsp[0].minor.yy0); } break; - case 292: /* add_column_fullname ::= fullname */ + case 294: /* add_column_fullname ::= fullname */ { disableLookaside(pParse); sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy131); } break; - case 293: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ + case 295: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ { sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy131, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 294: /* cmd ::= create_vtab */ + case 296: /* cmd ::= create_vtab */ {sqlite3VtabFinishParse(pParse,0);} break; - case 295: /* cmd ::= create_vtab LP vtabarglist RP */ + case 297: /* cmd ::= create_vtab LP vtabarglist RP */ {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);} break; - case 296: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ + case 298: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ { sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy394); } break; - case 297: /* vtabarg ::= */ + case 299: /* vtabarg ::= */ {sqlite3VtabArgInit(pParse);} break; - case 298: /* vtabargtoken ::= ANY */ - case 299: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==299); - case 300: /* lp ::= LP */ yytestcase(yyruleno==300); + case 300: /* vtabargtoken ::= ANY */ + case 301: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==301); + case 302: /* lp ::= LP */ yytestcase(yyruleno==302); {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);} break; - case 301: /* with ::= WITH wqlist */ - case 302: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==302); + case 303: /* with ::= WITH wqlist */ + case 304: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==304); { sqlite3WithPush(pParse, yymsp[0].minor.yy521, 1); } break; - case 303: /* wqas ::= AS */ + case 305: /* wqas ::= AS */ {yymsp[0].minor.yy516 = M10d_Any;} break; - case 304: /* wqas ::= AS MATERIALIZED */ + case 306: /* wqas ::= AS MATERIALIZED */ {yymsp[-1].minor.yy516 = M10d_Yes;} break; - case 305: /* wqas ::= AS NOT MATERIALIZED */ + case 307: /* wqas ::= AS NOT MATERIALIZED */ {yymsp[-2].minor.yy516 = M10d_No;} break; - case 306: /* wqitem ::= nm eidlist_opt wqas LP select RP */ + case 308: /* wqitem ::= nm eidlist_opt wqas LP select RP */ { yymsp[-5].minor.yy385 = sqlite3CteNew(pParse, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy322, yymsp[-1].minor.yy47, yymsp[-3].minor.yy516); /*A-overwrites-X*/ } break; - case 307: /* wqlist ::= wqitem */ + case 309: /* wqlist ::= wqitem */ { yymsp[0].minor.yy521 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy385); /*A-overwrites-X*/ } break; - case 308: /* wqlist ::= wqlist COMMA wqitem */ + case 310: /* wqlist ::= wqlist COMMA wqitem */ { yymsp[-2].minor.yy521 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy521, yymsp[0].minor.yy385); } break; - case 309: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */ + case 311: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */ { assert( yymsp[0].minor.yy41!=0 ); sqlite3WindowChain(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy41); @@ -174121,7 +175227,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy41 = yylhsminor.yy41; break; - case 310: /* windowdefn ::= nm AS LP window RP */ + case 312: /* windowdefn ::= nm AS LP window RP */ { if( ALWAYS(yymsp[-1].minor.yy41) ){ yymsp[-1].minor.yy41->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n); @@ -174130,83 +175236,83 @@ static YYACTIONTYPE yy_reduce( } yymsp[-4].minor.yy41 = yylhsminor.yy41; break; - case 311: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */ + case 313: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */ { yymsp[-4].minor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy322, yymsp[-1].minor.yy322, 0); } break; - case 312: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ + case 314: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ { yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy322, yymsp[-1].minor.yy322, &yymsp[-5].minor.yy0); } yymsp[-5].minor.yy41 = yylhsminor.yy41; break; - case 313: /* window ::= ORDER BY sortlist frame_opt */ + case 315: /* window ::= ORDER BY sortlist frame_opt */ { yymsp[-3].minor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, yymsp[-1].minor.yy322, 0); } break; - case 314: /* window ::= nm ORDER BY sortlist frame_opt */ + case 316: /* window ::= nm ORDER BY sortlist frame_opt */ { yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, yymsp[-1].minor.yy322, &yymsp[-4].minor.yy0); } yymsp[-4].minor.yy41 = yylhsminor.yy41; break; - case 315: /* window ::= nm frame_opt */ + case 317: /* window ::= nm frame_opt */ { yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, 0, &yymsp[-1].minor.yy0); } yymsp[-1].minor.yy41 = yylhsminor.yy41; break; - case 316: /* frame_opt ::= */ + case 318: /* frame_opt ::= */ { yymsp[1].minor.yy41 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0); } break; - case 317: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ + case 319: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ { yylhsminor.yy41 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy394, yymsp[-1].minor.yy595.eType, yymsp[-1].minor.yy595.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy516); } yymsp[-2].minor.yy41 = yylhsminor.yy41; break; - case 318: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ + case 320: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ { yylhsminor.yy41 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy394, yymsp[-3].minor.yy595.eType, yymsp[-3].minor.yy595.pExpr, yymsp[-1].minor.yy595.eType, yymsp[-1].minor.yy595.pExpr, yymsp[0].minor.yy516); } yymsp[-5].minor.yy41 = yylhsminor.yy41; break; - case 320: /* frame_bound_s ::= frame_bound */ - case 322: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==322); + case 322: /* frame_bound_s ::= frame_bound */ + case 324: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==324); {yylhsminor.yy595 = yymsp[0].minor.yy595;} yymsp[0].minor.yy595 = yylhsminor.yy595; break; - case 321: /* frame_bound_s ::= UNBOUNDED PRECEDING */ - case 323: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==323); - case 325: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==325); + case 323: /* frame_bound_s ::= UNBOUNDED PRECEDING */ + case 325: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==325); + case 327: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==327); {yylhsminor.yy595.eType = yymsp[-1].major; yylhsminor.yy595.pExpr = 0;} yymsp[-1].minor.yy595 = yylhsminor.yy595; break; - case 324: /* frame_bound ::= expr PRECEDING|FOLLOWING */ + case 326: /* frame_bound ::= expr PRECEDING|FOLLOWING */ {yylhsminor.yy595.eType = yymsp[0].major; yylhsminor.yy595.pExpr = yymsp[-1].minor.yy528;} yymsp[-1].minor.yy595 = yylhsminor.yy595; break; - case 326: /* frame_exclude_opt ::= */ + case 328: /* frame_exclude_opt ::= */ {yymsp[1].minor.yy516 = 0;} break; - case 327: /* frame_exclude_opt ::= EXCLUDE frame_exclude */ + case 329: /* frame_exclude_opt ::= EXCLUDE frame_exclude */ {yymsp[-1].minor.yy516 = yymsp[0].minor.yy516;} break; - case 328: /* frame_exclude ::= NO OTHERS */ - case 329: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==329); + case 330: /* frame_exclude ::= NO OTHERS */ + case 331: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==331); {yymsp[-1].minor.yy516 = yymsp[-1].major; /*A-overwrites-X*/} break; - case 330: /* frame_exclude ::= GROUP|TIES */ + case 332: /* frame_exclude ::= GROUP|TIES */ {yymsp[0].minor.yy516 = yymsp[0].major; /*A-overwrites-X*/} break; - case 331: /* window_clause ::= WINDOW windowdefn_list */ + case 333: /* window_clause ::= WINDOW windowdefn_list */ { yymsp[-1].minor.yy41 = yymsp[0].minor.yy41; } break; - case 332: /* filter_over ::= filter_clause over_clause */ + case 334: /* filter_over ::= filter_clause over_clause */ { if( yymsp[0].minor.yy41 ){ yymsp[0].minor.yy41->pFilter = yymsp[-1].minor.yy528; @@ -174217,13 +175323,13 @@ static YYACTIONTYPE yy_reduce( } yymsp[-1].minor.yy41 = yylhsminor.yy41; break; - case 333: /* filter_over ::= over_clause */ + case 335: /* filter_over ::= over_clause */ { yylhsminor.yy41 = yymsp[0].minor.yy41; } yymsp[0].minor.yy41 = yylhsminor.yy41; break; - case 334: /* filter_over ::= filter_clause */ + case 336: /* filter_over ::= filter_clause */ { yylhsminor.yy41 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); if( yylhsminor.yy41 ){ @@ -174235,13 +175341,13 @@ static YYACTIONTYPE yy_reduce( } yymsp[0].minor.yy41 = yylhsminor.yy41; break; - case 335: /* over_clause ::= OVER LP window RP */ + case 337: /* over_clause ::= OVER LP window RP */ { yymsp[-3].minor.yy41 = yymsp[-1].minor.yy41; assert( yymsp[-3].minor.yy41!=0 ); } break; - case 336: /* over_clause ::= OVER nm */ + case 338: /* over_clause ::= OVER nm */ { yymsp[-1].minor.yy41 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); if( yymsp[-1].minor.yy41 ){ @@ -174249,75 +175355,75 @@ static YYACTIONTYPE yy_reduce( } } break; - case 337: /* filter_clause ::= FILTER LP WHERE expr RP */ + case 339: /* filter_clause ::= FILTER LP WHERE expr RP */ { yymsp[-4].minor.yy528 = yymsp[-1].minor.yy528; } break; default: - /* (338) input ::= cmdlist */ yytestcase(yyruleno==338); - /* (339) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==339); - /* (340) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=340); - /* (341) ecmd ::= SEMI */ yytestcase(yyruleno==341); - /* (342) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==342); - /* (343) ecmd ::= explain cmdx SEMI (NEVER REDUCES) */ assert(yyruleno!=343); - /* (344) trans_opt ::= */ yytestcase(yyruleno==344); - /* (345) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==345); - /* (346) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==346); - /* (347) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==347); - /* (348) savepoint_opt ::= */ yytestcase(yyruleno==348); - /* (349) cmd ::= create_table create_table_args */ yytestcase(yyruleno==349); - /* (350) table_option_set ::= table_option (OPTIMIZED OUT) */ assert(yyruleno!=350); - /* (351) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==351); - /* (352) columnlist ::= columnname carglist */ yytestcase(yyruleno==352); - /* (353) nm ::= ID|INDEXED|JOIN_KW */ yytestcase(yyruleno==353); - /* (354) nm ::= STRING */ yytestcase(yyruleno==354); - /* (355) typetoken ::= typename */ yytestcase(yyruleno==355); - /* (356) typename ::= ID|STRING */ yytestcase(yyruleno==356); - /* (357) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=357); - /* (358) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=358); - /* (359) carglist ::= carglist ccons */ yytestcase(yyruleno==359); - /* (360) carglist ::= */ yytestcase(yyruleno==360); - /* (361) ccons ::= NULL onconf */ yytestcase(yyruleno==361); - /* (362) ccons ::= GENERATED ALWAYS AS generated */ yytestcase(yyruleno==362); - /* (363) ccons ::= AS generated */ yytestcase(yyruleno==363); - /* (364) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==364); - /* (365) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==365); - /* (366) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=366); - /* (367) tconscomma ::= */ yytestcase(yyruleno==367); - /* (368) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=368); - /* (369) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=369); - /* (370) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=370); - /* (371) oneselect ::= values */ yytestcase(yyruleno==371); - /* (372) sclp ::= selcollist COMMA */ yytestcase(yyruleno==372); - /* (373) as ::= ID|STRING */ yytestcase(yyruleno==373); - /* (374) indexed_opt ::= indexed_by (OPTIMIZED OUT) */ assert(yyruleno!=374); - /* (375) returning ::= */ yytestcase(yyruleno==375); - /* (376) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=376); - /* (377) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==377); - /* (378) case_operand ::= expr */ yytestcase(yyruleno==378); - /* (379) exprlist ::= nexprlist */ yytestcase(yyruleno==379); - /* (380) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=380); - /* (381) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=381); - /* (382) nmnum ::= ON */ yytestcase(yyruleno==382); - /* (383) nmnum ::= DELETE */ yytestcase(yyruleno==383); - /* (384) nmnum ::= DEFAULT */ yytestcase(yyruleno==384); - /* (385) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==385); - /* (386) foreach_clause ::= */ yytestcase(yyruleno==386); - /* (387) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==387); - /* (388) trnm ::= nm */ yytestcase(yyruleno==388); - /* (389) tridxby ::= */ yytestcase(yyruleno==389); - /* (390) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==390); - /* (391) database_kw_opt ::= */ yytestcase(yyruleno==391); - /* (392) kwcolumn_opt ::= */ yytestcase(yyruleno==392); - /* (393) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==393); - /* (394) vtabarglist ::= vtabarg */ yytestcase(yyruleno==394); - /* (395) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==395); - /* (396) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==396); - /* (397) anylist ::= */ yytestcase(yyruleno==397); - /* (398) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==398); - /* (399) anylist ::= anylist ANY */ yytestcase(yyruleno==399); - /* (400) with ::= */ yytestcase(yyruleno==400); - /* (401) windowdefn_list ::= windowdefn (OPTIMIZED OUT) */ assert(yyruleno!=401); - /* (402) window ::= frame_opt (OPTIMIZED OUT) */ assert(yyruleno!=402); + /* (340) input ::= cmdlist */ yytestcase(yyruleno==340); + /* (341) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==341); + /* (342) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=342); + /* (343) ecmd ::= SEMI */ yytestcase(yyruleno==343); + /* (344) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==344); + /* (345) ecmd ::= explain cmdx SEMI (NEVER REDUCES) */ assert(yyruleno!=345); + /* (346) trans_opt ::= */ yytestcase(yyruleno==346); + /* (347) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==347); + /* (348) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==348); + /* (349) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==349); + /* (350) savepoint_opt ::= */ yytestcase(yyruleno==350); + /* (351) cmd ::= create_table create_table_args */ yytestcase(yyruleno==351); + /* (352) table_option_set ::= table_option (OPTIMIZED OUT) */ assert(yyruleno!=352); + /* (353) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==353); + /* (354) columnlist ::= columnname carglist */ yytestcase(yyruleno==354); + /* (355) nm ::= ID|INDEXED|JOIN_KW */ yytestcase(yyruleno==355); + /* (356) nm ::= STRING */ yytestcase(yyruleno==356); + /* (357) typetoken ::= typename */ yytestcase(yyruleno==357); + /* (358) typename ::= ID|STRING */ yytestcase(yyruleno==358); + /* (359) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=359); + /* (360) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=360); + /* (361) carglist ::= carglist ccons */ yytestcase(yyruleno==361); + /* (362) carglist ::= */ yytestcase(yyruleno==362); + /* (363) ccons ::= NULL onconf */ yytestcase(yyruleno==363); + /* (364) ccons ::= GENERATED ALWAYS AS generated */ yytestcase(yyruleno==364); + /* (365) ccons ::= AS generated */ yytestcase(yyruleno==365); + /* (366) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==366); + /* (367) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==367); + /* (368) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=368); + /* (369) tconscomma ::= */ yytestcase(yyruleno==369); + /* (370) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=370); + /* (371) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=371); + /* (372) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=372); + /* (373) oneselect ::= values */ yytestcase(yyruleno==373); + /* (374) sclp ::= selcollist COMMA */ yytestcase(yyruleno==374); + /* (375) as ::= ID|STRING */ yytestcase(yyruleno==375); + /* (376) indexed_opt ::= indexed_by (OPTIMIZED OUT) */ assert(yyruleno!=376); + /* (377) returning ::= */ yytestcase(yyruleno==377); + /* (378) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=378); + /* (379) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==379); + /* (380) case_operand ::= expr */ yytestcase(yyruleno==380); + /* (381) exprlist ::= nexprlist */ yytestcase(yyruleno==381); + /* (382) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=382); + /* (383) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=383); + /* (384) nmnum ::= ON */ yytestcase(yyruleno==384); + /* (385) nmnum ::= DELETE */ yytestcase(yyruleno==385); + /* (386) nmnum ::= DEFAULT */ yytestcase(yyruleno==386); + /* (387) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==387); + /* (388) foreach_clause ::= */ yytestcase(yyruleno==388); + /* (389) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==389); + /* (390) trnm ::= nm */ yytestcase(yyruleno==390); + /* (391) tridxby ::= */ yytestcase(yyruleno==391); + /* (392) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==392); + /* (393) database_kw_opt ::= */ yytestcase(yyruleno==393); + /* (394) kwcolumn_opt ::= */ yytestcase(yyruleno==394); + /* (395) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==395); + /* (396) vtabarglist ::= vtabarg */ yytestcase(yyruleno==396); + /* (397) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==397); + /* (398) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==398); + /* (399) anylist ::= */ yytestcase(yyruleno==399); + /* (400) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==400); + /* (401) anylist ::= anylist ANY */ yytestcase(yyruleno==401); + /* (402) with ::= */ yytestcase(yyruleno==402); + /* (403) windowdefn_list ::= windowdefn (OPTIMIZED OUT) */ assert(yyruleno!=403); + /* (404) window ::= frame_opt (OPTIMIZED OUT) */ assert(yyruleno!=404); break; /********** End reduce actions ************************************************/ }; @@ -176441,7 +177547,9 @@ SQLITE_PRIVATE int sqlite3Fts5Init(sqlite3*); #ifdef SQLITE_ENABLE_STMTVTAB SQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3*); #endif - +#ifdef SQLITE_EXTRA_AUTOEXT +int SQLITE_EXTRA_AUTOEXT(sqlite3*); +#endif /* ** An array of pointers to extension initializer functions for ** built-in extensions. @@ -176475,6 +177583,9 @@ static int (*const sqlite3BuiltinExtensions[])(sqlite3*) = { #ifdef SQLITE_ENABLE_BYTECODE_VTAB sqlite3VdbeBytecodeVtabInit, #endif +#ifdef SQLITE_EXTRA_AUTOEXT + SQLITE_EXTRA_AUTOEXT, +#endif }; #ifndef SQLITE_AMALGAMATION @@ -176548,6 +177659,32 @@ SQLITE_API char *sqlite3_temp_directory = 0; */ SQLITE_API char *sqlite3_data_directory = 0; +/* +** Determine whether or not high-precision (long double) floating point +** math works correctly on CPU currently running. +*/ +static SQLITE_NOINLINE int hasHighPrecisionDouble(int rc){ + if( sizeof(LONGDOUBLE_TYPE)<=8 ){ + /* If the size of "long double" is not more than 8, then + ** high-precision math is not possible. */ + return 0; + }else{ + /* Just because sizeof(long double)>8 does not mean that the underlying + ** hardware actually supports high-precision floating point. For example, + ** clearing the 0x100 bit in the floating-point control word on Intel + ** processors will make long double work like double, even though long + ** double takes up more space. The only way to determine if long double + ** actually works is to run an experiment. */ + LONGDOUBLE_TYPE a, b, c; + rc++; + a = 1.0+rc*0.1; + b = 1.0e+18+rc*25.0; + c = a+b; + return b!=c; + } +} + + /* ** Initialize SQLite. ** @@ -176743,6 +177880,12 @@ SQLITE_API int sqlite3_initialize(void){ } #endif + /* Experimentally determine if high-precision floating point is + ** available. */ +#ifndef SQLITE_OMIT_WSD + sqlite3Config.bUseLongDouble = hasHighPrecisionDouble(rc); +#endif + return rc; } @@ -177313,6 +178456,10 @@ SQLITE_API int sqlite3_db_cacheflush(sqlite3 *db){ SQLITE_API int sqlite3_db_config(sqlite3 *db, int op, ...){ va_list ap; int rc; + +#ifdef SQLITE_ENABLE_API_ARMOR + if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT; +#endif sqlite3_mutex_enter(db->mutex); va_start(ap, op); switch( op ){ @@ -177642,6 +178789,14 @@ static int sqlite3Close(sqlite3 *db, int forceZombie){ } #endif + while( db->pDbData ){ + DbClientData *p = db->pDbData; + db->pDbData = p->pNext; + assert( p->pData!=0 ); + if( p->xDestructor ) p->xDestructor(p->pData); + sqlite3_free(p); + } + /* Convert the connection into a zombie and then close it. */ db->eOpenState = SQLITE_STATE_ZOMBIE; @@ -178716,6 +179871,12 @@ SQLITE_API void *sqlite3_preupdate_hook( void *pArg /* First callback argument */ ){ void *pRet; + +#ifdef SQLITE_ENABLE_API_ARMOR + if( db==0 ){ + return 0; + } +#endif sqlite3_mutex_enter(db->mutex); pRet = db->pPreUpdateArg; db->xPreUpdateCallback = xCallback; @@ -178862,7 +180023,7 @@ SQLITE_API int sqlite3_wal_checkpoint_v2( if( eModeSQLITE_CHECKPOINT_TRUNCATE ){ /* EVIDENCE-OF: R-03996-12088 The M parameter must be a valid checkpoint ** mode: */ - return SQLITE_MISUSE; + return SQLITE_MISUSE_BKPT; } sqlite3_mutex_enter(db->mutex); @@ -180099,6 +181260,69 @@ SQLITE_API int sqlite3_collation_needed16( } #endif /* SQLITE_OMIT_UTF16 */ +/* +** Find existing client data. +*/ +SQLITE_API void *sqlite3_get_clientdata(sqlite3 *db, const char *zName){ + DbClientData *p; + sqlite3_mutex_enter(db->mutex); + for(p=db->pDbData; p; p=p->pNext){ + if( strcmp(p->zName, zName)==0 ){ + void *pResult = p->pData; + sqlite3_mutex_leave(db->mutex); + return pResult; + } + } + sqlite3_mutex_leave(db->mutex); + return 0; +} + +/* +** Add new client data to a database connection. +*/ +SQLITE_API int sqlite3_set_clientdata( + sqlite3 *db, /* Attach client data to this connection */ + const char *zName, /* Name of the client data */ + void *pData, /* The client data itself */ + void (*xDestructor)(void*) /* Destructor */ +){ + DbClientData *p, **pp; + sqlite3_mutex_enter(db->mutex); + pp = &db->pDbData; + for(p=db->pDbData; p && strcmp(p->zName,zName); p=p->pNext){ + pp = &p->pNext; + } + if( p ){ + assert( p->pData!=0 ); + if( p->xDestructor ) p->xDestructor(p->pData); + if( pData==0 ){ + *pp = p->pNext; + sqlite3_free(p); + sqlite3_mutex_leave(db->mutex); + return SQLITE_OK; + } + }else if( pData==0 ){ + sqlite3_mutex_leave(db->mutex); + return SQLITE_OK; + }else{ + size_t n = strlen(zName); + p = sqlite3_malloc64( sizeof(DbClientData)+n+1 ); + if( p==0 ){ + if( xDestructor ) xDestructor(pData); + sqlite3_mutex_leave(db->mutex); + return SQLITE_NOMEM; + } + memcpy(p->zName, zName, n+1); + p->pNext = db->pDbData; + db->pDbData = p; + } + p->pData = pData; + p->xDestructor = xDestructor; + sqlite3_mutex_leave(db->mutex); + return SQLITE_OK; +} + + #ifndef SQLITE_OMIT_DEPRECATED /* ** This function is now an anachronism. It used to be used to recover from a @@ -180448,6 +181672,28 @@ SQLITE_API int sqlite3_test_control(int op, ...){ } #endif + /* sqlite3_test_control(SQLITE_TESTCTRL_FK_NO_ACTION, sqlite3 *db, int b); + ** + ** If b is true, then activate the SQLITE_FkNoAction setting. If b is + ** false then clearn that setting. If the SQLITE_FkNoAction setting is + ** abled, all foreign key ON DELETE and ON UPDATE actions behave as if + ** they were NO ACTION, regardless of how they are defined. + ** + ** NB: One must usually run "PRAGMA writable_schema=RESET" after + ** using this test-control, before it will take full effect. failing + ** to reset the schema can result in some unexpected behavior. + */ + case SQLITE_TESTCTRL_FK_NO_ACTION: { + sqlite3 *db = va_arg(ap, sqlite3*); + int b = va_arg(ap, int); + if( b ){ + db->flags |= SQLITE_FkNoAction; + }else{ + db->flags &= ~SQLITE_FkNoAction; + } + break; + } + /* ** sqlite3_test_control(BITVEC_TEST, size, program) ** @@ -180872,11 +182118,11 @@ SQLITE_API int sqlite3_test_control(int op, ...){ ** X<0 Make no changes to the bUseLongDouble. Just report value. ** X==0 Disable bUseLongDouble ** X==1 Enable bUseLongDouble - ** X==2 Set bUseLongDouble to its default value for this platform + ** X>=2 Set bUseLongDouble to its default value for this platform */ case SQLITE_TESTCTRL_USELONGDOUBLE: { int b = va_arg(ap, int); - if( b==2 ) b = sizeof(LONGDOUBLE_TYPE)>8; + if( b>=2 ) b = hasHighPrecisionDouble(b); if( b>=0 ) sqlite3Config.bUseLongDouble = b>0; rc = sqlite3Config.bUseLongDouble!=0; break; @@ -181290,7 +182536,7 @@ SQLITE_API int sqlite3_compileoption_used(const char *zOptName){ int nOpt; const char **azCompileOpt; -#if SQLITE_ENABLE_API_ARMOR +#ifdef SQLITE_ENABLE_API_ARMOR if( zOptName==0 ){ (void)SQLITE_MISUSE_BKPT; return 0; @@ -181485,6 +182731,9 @@ SQLITE_API int sqlite3_unlock_notify( ){ int rc = SQLITE_OK; +#ifdef SQLITE_ENABLE_API_ARMOR + if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT; +#endif sqlite3_mutex_enter(db->mutex); enterMutex(); @@ -182506,6 +183755,7 @@ struct Fts3Table { int nPgsz; /* Page size for host database */ char *zSegmentsTbl; /* Name of %_segments table */ sqlite3_blob *pSegments; /* Blob handle open on %_segments table */ + int iSavepoint; /* ** The following array of hash tables is used to buffer pending index @@ -183249,6 +184499,7 @@ static void fts3DeclareVtab(int *pRc, Fts3Table *p){ zLanguageid = (p->zLanguageid ? p->zLanguageid : "__langid"); sqlite3_vtab_config(p->db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1); + sqlite3_vtab_config(p->db, SQLITE_VTAB_INNOCUOUS); /* Create a list of user columns for the virtual table */ zCols = sqlite3_mprintf("%Q, ", p->azColumn[0]); @@ -186498,6 +187749,8 @@ static int fts3RenameMethod( rc = sqlite3Fts3PendingTermsFlush(p); } + p->bIgnoreSavepoint = 1; + if( p->zContentTbl==0 ){ fts3DbExec(&rc, db, "ALTER TABLE %Q.'%q_content' RENAME TO '%q_content';", @@ -186525,6 +187778,8 @@ static int fts3RenameMethod( "ALTER TABLE %Q.'%q_segdir' RENAME TO '%q_segdir';", p->zDb, p->zName, zName ); + + p->bIgnoreSavepoint = 0; return rc; } @@ -186535,12 +187790,28 @@ static int fts3RenameMethod( */ static int fts3SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){ int rc = SQLITE_OK; - UNUSED_PARAMETER(iSavepoint); - assert( ((Fts3Table *)pVtab)->inTransaction ); - assert( ((Fts3Table *)pVtab)->mxSavepoint <= iSavepoint ); - TESTONLY( ((Fts3Table *)pVtab)->mxSavepoint = iSavepoint ); - if( ((Fts3Table *)pVtab)->bIgnoreSavepoint==0 ){ - rc = fts3SyncMethod(pVtab); + Fts3Table *pTab = (Fts3Table*)pVtab; + assert( pTab->inTransaction ); + assert( pTab->mxSavepoint<=iSavepoint ); + TESTONLY( pTab->mxSavepoint = iSavepoint ); + + if( pTab->bIgnoreSavepoint==0 ){ + if( fts3HashCount(&pTab->aIndex[0].hPending)>0 ){ + char *zSql = sqlite3_mprintf("INSERT INTO %Q.%Q(%Q) VALUES('flush')", + pTab->zDb, pTab->zName, pTab->zName + ); + if( zSql ){ + pTab->bIgnoreSavepoint = 1; + rc = sqlite3_exec(pTab->db, zSql, 0, 0, 0); + pTab->bIgnoreSavepoint = 0; + sqlite3_free(zSql); + }else{ + rc = SQLITE_NOMEM; + } + } + if( rc==SQLITE_OK ){ + pTab->iSavepoint = iSavepoint+1; + } } return rc; } @@ -186551,12 +187822,11 @@ static int fts3SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){ ** This is a no-op. */ static int fts3ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){ - TESTONLY( Fts3Table *p = (Fts3Table*)pVtab ); - UNUSED_PARAMETER(iSavepoint); - UNUSED_PARAMETER(pVtab); - assert( p->inTransaction ); - assert( p->mxSavepoint >= iSavepoint ); - TESTONLY( p->mxSavepoint = iSavepoint-1 ); + Fts3Table *pTab = (Fts3Table*)pVtab; + assert( pTab->inTransaction ); + assert( pTab->mxSavepoint >= iSavepoint ); + TESTONLY( pTab->mxSavepoint = iSavepoint-1 ); + pTab->iSavepoint = iSavepoint; return SQLITE_OK; } @@ -186566,11 +187836,13 @@ static int fts3ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){ ** Discard the contents of the pending terms table. */ static int fts3RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){ - Fts3Table *p = (Fts3Table*)pVtab; + Fts3Table *pTab = (Fts3Table*)pVtab; UNUSED_PARAMETER(iSavepoint); - assert( p->inTransaction ); - TESTONLY( p->mxSavepoint = iSavepoint ); - sqlite3Fts3PendingTermsClear(p); + assert( pTab->inTransaction ); + TESTONLY( pTab->mxSavepoint = iSavepoint ); + if( (iSavepoint+1)<=pTab->iSavepoint ){ + sqlite3Fts3PendingTermsClear(pTab); + } return SQLITE_OK; } @@ -186589,8 +187861,49 @@ static int fts3ShadowName(const char *zName){ return 0; } +/* +** Implementation of the xIntegrity() method on the FTS3/FTS4 virtual +** table. +*/ +static int fts3Integrity( + sqlite3_vtab *pVtab, /* The virtual table to be checked */ + const char *zSchema, /* Name of schema in which pVtab lives */ + const char *zTabname, /* Name of the pVTab table */ + int isQuick, /* True if this is a quick_check */ + char **pzErr /* Write error message here */ +){ + Fts3Table *p = (Fts3Table*)pVtab; + char *zSql; + int rc; + char *zErr = 0; + + assert( pzErr!=0 ); + assert( *pzErr==0 ); + UNUSED_PARAMETER(isQuick); + zSql = sqlite3_mprintf( + "INSERT INTO \"%w\".\"%w\"(\"%w\") VALUES('integrity-check');", + zSchema, zTabname, zTabname); + if( zSql==0 ){ + return SQLITE_NOMEM; + } + rc = sqlite3_exec(p->db, zSql, 0, 0, &zErr); + sqlite3_free(zSql); + if( (rc&0xff)==SQLITE_CORRUPT ){ + *pzErr = sqlite3_mprintf("malformed inverted index for FTS%d table %s.%s", + p->bFts4 ? 4 : 3, zSchema, zTabname); + }else if( rc!=SQLITE_OK ){ + *pzErr = sqlite3_mprintf("unable to validate the inverted index for" + " FTS%d table %s.%s: %s", + p->bFts4 ? 4 : 3, zSchema, zTabname, zErr); + } + sqlite3_free(zErr); + return SQLITE_OK; +} + + + static const sqlite3_module fts3Module = { - /* iVersion */ 3, + /* iVersion */ 4, /* xCreate */ fts3CreateMethod, /* xConnect */ fts3ConnectMethod, /* xBestIndex */ fts3BestIndexMethod, @@ -186614,6 +187927,7 @@ static const sqlite3_module fts3Module = { /* xRelease */ fts3ReleaseMethod, /* xRollbackTo */ fts3RollbackToMethod, /* xShadowName */ fts3ShadowName, + /* xIntegrity */ fts3Integrity, }; /* @@ -189289,7 +190603,8 @@ SQLITE_PRIVATE int sqlite3Fts3InitAux(sqlite3 *db){ 0, /* xSavepoint */ 0, /* xRelease */ 0, /* xRollbackTo */ - 0 /* xShadowName */ + 0, /* xShadowName */ + 0 /* xIntegrity */ }; int rc; /* Return code */ @@ -192855,7 +194170,8 @@ SQLITE_PRIVATE int sqlite3Fts3InitTok(sqlite3 *db, Fts3Hash *pHash, void(*xDestr 0, /* xSavepoint */ 0, /* xRelease */ 0, /* xRollbackTo */ - 0 /* xShadowName */ + 0, /* xShadowName */ + 0 /* xIntegrity */ }; int rc; /* Return code */ @@ -196196,7 +197512,6 @@ SQLITE_PRIVATE int sqlite3Fts3PendingTermsFlush(Fts3Table *p){ rc = fts3SegmentMerge(p, p->iPrevLangid, i, FTS3_SEGCURSOR_PENDING); if( rc==SQLITE_DONE ) rc = SQLITE_OK; } - sqlite3Fts3PendingTermsClear(p); /* Determine the auto-incr-merge setting if unknown. If enabled, ** estimate the number of leaf blocks of content to be written @@ -196218,6 +197533,10 @@ SQLITE_PRIVATE int sqlite3Fts3PendingTermsFlush(Fts3Table *p){ rc = sqlite3_reset(pStmt); } } + + if( rc==SQLITE_OK ){ + sqlite3Fts3PendingTermsClear(p); + } return rc; } @@ -196849,6 +198168,8 @@ static int fts3AppendToNode( blobGrowBuffer(pPrev, nTerm, &rc); if( rc!=SQLITE_OK ) return rc; + assert( pPrev!=0 ); + assert( pPrev->a!=0 ); nPrefix = fts3PrefixCompress(pPrev->a, pPrev->n, zTerm, nTerm); nSuffix = nTerm - nPrefix; @@ -196905,9 +198226,13 @@ static int fts3IncrmergeAppend( nSpace += sqlite3Fts3VarintLen(nDoclist) + nDoclist; /* If the current block is not empty, and if adding this term/doclist - ** to the current block would make it larger than Fts3Table.nNodeSize - ** bytes, write this block out to the database. */ - if( pLeaf->block.n>0 && (pLeaf->block.n + nSpace)>p->nNodeSize ){ + ** to the current block would make it larger than Fts3Table.nNodeSize bytes, + ** and if there is still room for another leaf page, write this block out to + ** the database. */ + if( pLeaf->block.n>0 + && (pLeaf->block.n + nSpace)>p->nNodeSize + && pLeaf->iBlock < (pWriter->iStart + pWriter->nLeafEst) + ){ rc = fts3WriteSegment(p, pLeaf->iBlock, pLeaf->block.a, pLeaf->block.n); pWriter->nWork++; @@ -197239,7 +198564,7 @@ static int fts3IncrmergeLoad( rc = sqlite3Fts3ReadBlock(p, reader.iChild, &aBlock, &nBlock,0); blobGrowBuffer(&pNode->block, MAX(nBlock, p->nNodeSize)+FTS3_NODE_PADDING, &rc - ); + ); if( rc==SQLITE_OK ){ memcpy(pNode->block.a, aBlock, nBlock); pNode->block.n = nBlock; @@ -198304,8 +199629,11 @@ static int fts3SpecialInsert(Fts3Table *p, sqlite3_value *pVal){ rc = fts3DoIncrmerge(p, &zVal[6]); }else if( nVal>10 && 0==sqlite3_strnicmp(zVal, "automerge=", 10) ){ rc = fts3DoAutoincrmerge(p, &zVal[10]); + }else if( nVal==5 && 0==sqlite3_strnicmp(zVal, "flush", 5) ){ + rc = sqlite3Fts3PendingTermsFlush(p); + } #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) - }else{ + else{ int v; if( nVal>9 && 0==sqlite3_strnicmp(zVal, "nodesize=", 9) ){ v = atoi(&zVal[9]); @@ -198323,8 +199651,8 @@ static int fts3SpecialInsert(Fts3Table *p, sqlite3_value *pVal){ if( v>=4 && v<=FTS3_MERGE_COUNT && (v&1)==0 ) p->nMergeCount = v; rc = SQLITE_OK; } -#endif } +#endif return rc; } @@ -201837,7 +203165,7 @@ static void jsonResult(JsonString *p){ }else if( jsonForceRCStr(p) ){ sqlite3RCStrRef(p->zBuf); sqlite3_result_text64(p->pCtx, p->zBuf, p->nUsed, - (void(*)(void*))sqlite3RCStrUnref, + sqlite3RCStrUnref, SQLITE_UTF8); } } @@ -203177,7 +204505,7 @@ static JsonParse *jsonParseCached( /* The input JSON was not found anywhere in the cache. We will need ** to parse it ourselves and generate a new JsonParse object. */ - bJsonRCStr = sqlite3ValueIsOfClass(pJson,(void(*)(void*))sqlite3RCStrUnref); + bJsonRCStr = sqlite3ValueIsOfClass(pJson,sqlite3RCStrUnref); p = sqlite3_malloc64( sizeof(*p) + (bJsonRCStr ? 0 : nJson+1) ); if( p==0 ){ sqlite3_result_error_nomem(pCtx); @@ -203391,6 +204719,7 @@ static JsonNode *jsonLookupStep( if( (pRoot[j].jnFlags & JNODE_REMOVE)==0 || pParse->useMod==0 ) i--; j += jsonNodeSize(&pRoot[j]); } + if( i==0 && j<=pRoot->n ) break; if( (pRoot->jnFlags & JNODE_APPEND)==0 ) break; if( pParse->useMod==0 ) break; assert( pRoot->eU==2 ); @@ -204078,11 +205407,13 @@ static void jsonReplaceNode( break; } if( sqlite3_value_subtype(pValue)!=JSON_SUBTYPE ){ - char *zCopy = sqlite3DbStrDup(0, z); + char *zCopy = sqlite3_malloc64( n+1 ); int k; if( zCopy ){ + memcpy(zCopy, z, n); + zCopy[n] = 0; jsonParseAddCleanup(p, sqlite3_free, zCopy); - }else{ + }else{ p->oom = 1; sqlite3_result_error_nomem(pCtx); } @@ -204359,7 +205690,7 @@ static void jsonArrayCompute(sqlite3_context *ctx, int isFinal){ }else if( isFinal ){ sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, pStr->bStatic ? SQLITE_TRANSIENT : - (void(*)(void*))sqlite3RCStrUnref); + sqlite3RCStrUnref); pStr->bStatic = 1; }else{ sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT); @@ -204468,7 +205799,7 @@ static void jsonObjectCompute(sqlite3_context *ctx, int isFinal){ }else if( isFinal ){ sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, pStr->bStatic ? SQLITE_TRANSIENT : - (void(*)(void*))sqlite3RCStrUnref); + sqlite3RCStrUnref); pStr->bStatic = 1; }else{ sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT); @@ -204900,7 +206231,7 @@ static int jsonEachFilter( if( z==0 ) return SQLITE_OK; memset(&p->sParse, 0, sizeof(p->sParse)); p->sParse.nJPRef = 1; - if( sqlite3ValueIsOfClass(argv[0], (void(*)(void*))sqlite3RCStrUnref) ){ + if( sqlite3ValueIsOfClass(argv[0], sqlite3RCStrUnref) ){ p->sParse.zJson = sqlite3RCStrRef((char*)z); }else{ n = sqlite3_value_bytes(argv[0]); @@ -204995,7 +206326,8 @@ static sqlite3_module jsonEachModule = { 0, /* xSavepoint */ 0, /* xRelease */ 0, /* xRollbackTo */ - 0 /* xShadowName */ + 0, /* xShadowName */ + 0 /* xIntegrity */ }; /* The methods of the json_tree virtual table. */ @@ -205023,7 +206355,8 @@ static sqlite3_module jsonTreeModule = { 0, /* xSavepoint */ 0, /* xRelease */ 0, /* xRollbackTo */ - 0 /* xShadowName */ + 0, /* xShadowName */ + 0 /* xIntegrity */ }; #endif /* SQLITE_OMIT_VIRTUALTABLE */ #endif /* !defined(SQLITE_OMIT_JSON) */ @@ -205258,6 +206591,7 @@ struct Rtree { int iDepth; /* Current depth of the r-tree structure */ char *zDb; /* Name of database containing r-tree table */ char *zName; /* Name of r-tree table */ + char *zNodeName; /* Name of the %_node table */ u32 nBusy; /* Current number of users of this structure */ i64 nRowEst; /* Estimated number of rows in this table */ u32 nCursor; /* Number of open cursors */ @@ -205270,7 +206604,6 @@ struct Rtree { ** headed by the node (leaf nodes have RtreeNode.iNode==0). */ RtreeNode *pDeleted; - int iReinsertHeight; /* Height of sub-trees Reinsert() has run on */ /* Blob I/O on xxx_node */ sqlite3_blob *pNodeBlob; @@ -205567,15 +206900,20 @@ struct RtreeMatchArg { ** -DSQLITE_RUNTIME_BYTEORDER=1 is set, then byte-order is determined ** at run-time. */ -#ifndef SQLITE_BYTEORDER -# if defined(i386) || defined(__i386__) || defined(_M_IX86) || \ +#ifndef SQLITE_BYTEORDER /* Replicate changes at tag-20230904a */ +# if defined(__BYTE_ORDER__) && __BYTE_ORDER__==__ORDER_BIG_ENDIAN__ +# define SQLITE_BYTEORDER 4321 +# elif defined(__BYTE_ORDER__) && __BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__ +# define SQLITE_BYTEORDER 1234 +# elif defined(__BIG_ENDIAN__) && __BIG_ENDIAN__==1 +# define SQLITE_BYTEORDER 4321 +# elif defined(i386) || defined(__i386__) || defined(_M_IX86) || \ defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \ defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \ defined(__ARMEL__) || defined(__AARCH64EL__) || defined(_M_ARM64) -# define SQLITE_BYTEORDER 1234 -# elif defined(sparc) || defined(__ppc__) || \ - defined(__ARMEB__) || defined(__AARCH64EB__) -# define SQLITE_BYTEORDER 4321 +# define SQLITE_BYTEORDER 1234 +# elif defined(sparc) || defined(__ARMEB__) || defined(__AARCH64EB__) +# define SQLITE_BYTEORDER 4321 # else # define SQLITE_BYTEORDER 0 # endif @@ -205824,11 +207162,9 @@ static int nodeAcquire( } } if( pRtree->pNodeBlob==0 ){ - char *zTab = sqlite3_mprintf("%s_node", pRtree->zName); - if( zTab==0 ) return SQLITE_NOMEM; - rc = sqlite3_blob_open(pRtree->db, pRtree->zDb, zTab, "data", iNode, 0, + rc = sqlite3_blob_open(pRtree->db, pRtree->zDb, pRtree->zNodeName, + "data", iNode, 0, &pRtree->pNodeBlob); - sqlite3_free(zTab); } if( rc ){ nodeBlobReset(pRtree); @@ -207169,8 +208505,12 @@ static int rtreeBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ pIdxInfo->idxNum = 2; pIdxInfo->needToFreeIdxStr = 1; - if( iIdx>0 && 0==(pIdxInfo->idxStr = sqlite3_mprintf("%s", zIdxStr)) ){ - return SQLITE_NOMEM; + if( iIdx>0 ){ + pIdxInfo->idxStr = sqlite3_malloc( iIdx+1 ); + if( pIdxInfo->idxStr==0 ){ + return SQLITE_NOMEM; + } + memcpy(pIdxInfo->idxStr, zIdxStr, iIdx+1); } nRow = pRtree->nRowEst >> (iIdx/2); @@ -207249,31 +208589,22 @@ static void cellUnion(Rtree *pRtree, RtreeCell *p1, RtreeCell *p2){ */ static int cellContains(Rtree *pRtree, RtreeCell *p1, RtreeCell *p2){ int ii; - int isInt = (pRtree->eCoordType==RTREE_COORD_INT32); - for(ii=0; iinDim2; ii+=2){ - RtreeCoord *a1 = &p1->aCoord[ii]; - RtreeCoord *a2 = &p2->aCoord[ii]; - if( (!isInt && (a2[0].fa1[1].f)) - || ( isInt && (a2[0].ia1[1].i)) - ){ - return 0; + if( pRtree->eCoordType==RTREE_COORD_INT32 ){ + for(ii=0; iinDim2; ii+=2){ + RtreeCoord *a1 = &p1->aCoord[ii]; + RtreeCoord *a2 = &p2->aCoord[ii]; + if( a2[0].ia1[1].i ) return 0; + } + }else{ + for(ii=0; iinDim2; ii+=2){ + RtreeCoord *a1 = &p1->aCoord[ii]; + RtreeCoord *a2 = &p2->aCoord[ii]; + if( a2[0].fa1[1].f ) return 0; } } return 1; } -/* -** Return the amount cell p would grow by if it were unioned with pCell. -*/ -static RtreeDValue cellGrowth(Rtree *pRtree, RtreeCell *p, RtreeCell *pCell){ - RtreeDValue area; - RtreeCell cell; - memcpy(&cell, p, sizeof(RtreeCell)); - area = cellArea(pRtree, &cell); - cellUnion(pRtree, &cell, pCell); - return (cellArea(pRtree, &cell)-area); -} - static RtreeDValue cellOverlap( Rtree *pRtree, RtreeCell *p, @@ -207320,38 +208651,52 @@ static int ChooseLeaf( for(ii=0; rc==SQLITE_OK && ii<(pRtree->iDepth-iHeight); ii++){ int iCell; sqlite3_int64 iBest = 0; - + int bFound = 0; RtreeDValue fMinGrowth = RTREE_ZERO; RtreeDValue fMinArea = RTREE_ZERO; - int nCell = NCELL(pNode); - RtreeCell cell; RtreeNode *pChild = 0; - RtreeCell *aCell = 0; - - /* Select the child node which will be enlarged the least if pCell - ** is inserted into it. Resolve ties by choosing the entry with - ** the smallest area. + /* First check to see if there is are any cells in pNode that completely + ** contains pCell. If two or more cells in pNode completely contain pCell + ** then pick the smallest. */ for(iCell=0; iCell1 ){ - int iLeft = 0; - int iRight = 0; - - int nLeft = nIdx/2; - int nRight = nIdx-nLeft; - int *aLeft = aIdx; - int *aRight = &aIdx[nLeft]; - - SortByDistance(aLeft, nLeft, aDistance, aSpare); - SortByDistance(aRight, nRight, aDistance, aSpare); - - memcpy(aSpare, aLeft, sizeof(int)*nLeft); - aLeft = aSpare; - - while( iLeftnDim; iDim++){ - aCenterCoord[iDim] += DCOORD(aCell[ii].aCoord[iDim*2]); - aCenterCoord[iDim] += DCOORD(aCell[ii].aCoord[iDim*2+1]); - } - } - for(iDim=0; iDimnDim; iDim++){ - aCenterCoord[iDim] = (aCenterCoord[iDim]/(nCell*(RtreeDValue)2)); - } - - for(ii=0; iinDim; iDim++){ - RtreeDValue coord = (DCOORD(aCell[ii].aCoord[iDim*2+1]) - - DCOORD(aCell[ii].aCoord[iDim*2])); - aDistance[ii] += (coord-aCenterCoord[iDim])*(coord-aCenterCoord[iDim]); - } - } - - SortByDistance(aOrder, nCell, aDistance, aSpare); - nodeZero(pRtree, pNode); - - for(ii=0; rc==SQLITE_OK && ii<(nCell-(RTREE_MINCELLS(pRtree)+1)); ii++){ - RtreeCell *p = &aCell[aOrder[ii]]; - nodeInsertCell(pRtree, pNode, p); - if( p->iRowid==pCell->iRowid ){ - if( iHeight==0 ){ - rc = rowidWrite(pRtree, p->iRowid, pNode->iNode); - }else{ - rc = parentWrite(pRtree, p->iRowid, pNode->iNode); - } - } - } - if( rc==SQLITE_OK ){ - rc = fixBoundingBox(pRtree, pNode); - } - for(; rc==SQLITE_OK && iiiNode currently contains - ** the height of the sub-tree headed by the cell. - */ - RtreeNode *pInsert; - RtreeCell *p = &aCell[aOrder[ii]]; - rc = ChooseLeaf(pRtree, p, iHeight, &pInsert); - if( rc==SQLITE_OK ){ - int rc2; - rc = rtreeInsertCell(pRtree, pInsert, p, iHeight); - rc2 = nodeRelease(pRtree, pInsert); - if( rc==SQLITE_OK ){ - rc = rc2; - } - } - } - - sqlite3_free(aCell); - return rc; -} - /* ** Insert cell pCell into node pNode. Node pNode is the head of a ** subtree iHeight high (leaf nodes have iHeight==0). @@ -208100,12 +209273,7 @@ static int rtreeInsertCell( } } if( nodeInsertCell(pRtree, pNode, pCell) ){ - if( iHeight<=pRtree->iReinsertHeight || pNode->iNode==1){ - rc = SplitNode(pRtree, pNode, pCell, iHeight); - }else{ - pRtree->iReinsertHeight = iHeight; - rc = Reinsert(pRtree, pNode, pCell, iHeight); - } + rc = SplitNode(pRtree, pNode, pCell, iHeight); }else{ rc = AdjustTree(pRtree, pNode, pCell); if( ALWAYS(rc==SQLITE_OK) ){ @@ -208448,7 +209616,6 @@ static int rtreeUpdate( } if( rc==SQLITE_OK ){ int rc2; - pRtree->iReinsertHeight = -1; rc = rtreeInsertCell(pRtree, pLeaf, &cell, 0); rc2 = nodeRelease(pRtree, pLeaf); if( rc==SQLITE_OK ){ @@ -208589,8 +209756,11 @@ static int rtreeShadowName(const char *zName){ return 0; } +/* Forward declaration */ +static int rtreeIntegrity(sqlite3_vtab*, const char*, const char*, int, char**); + static sqlite3_module rtreeModule = { - 3, /* iVersion */ + 4, /* iVersion */ rtreeCreate, /* xCreate - create a table */ rtreeConnect, /* xConnect - connect to an existing table */ rtreeBestIndex, /* xBestIndex - Determine search strategy */ @@ -208613,7 +209783,8 @@ static sqlite3_module rtreeModule = { rtreeSavepoint, /* xSavepoint */ 0, /* xRelease */ 0, /* xRollbackTo */ - rtreeShadowName /* xShadowName */ + rtreeShadowName, /* xShadowName */ + rtreeIntegrity /* xIntegrity */ }; static int rtreeSqlInit( @@ -208869,22 +210040,27 @@ static int rtreeInit( } sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1); + sqlite3_vtab_config(db, SQLITE_VTAB_INNOCUOUS); + /* Allocate the sqlite3_vtab structure */ nDb = (int)strlen(argv[1]); nName = (int)strlen(argv[2]); - pRtree = (Rtree *)sqlite3_malloc64(sizeof(Rtree)+nDb+nName+2); + pRtree = (Rtree *)sqlite3_malloc64(sizeof(Rtree)+nDb+nName*2+8); if( !pRtree ){ return SQLITE_NOMEM; } - memset(pRtree, 0, sizeof(Rtree)+nDb+nName+2); + memset(pRtree, 0, sizeof(Rtree)+nDb+nName*2+8); pRtree->nBusy = 1; pRtree->base.pModule = &rtreeModule; pRtree->zDb = (char *)&pRtree[1]; pRtree->zName = &pRtree->zDb[nDb+1]; + pRtree->zNodeName = &pRtree->zName[nName+1]; pRtree->eCoordType = (u8)eCoordType; memcpy(pRtree->zDb, argv[1], nDb); memcpy(pRtree->zName, argv[2], nName); + memcpy(pRtree->zNodeName, argv[2], nName); + memcpy(&pRtree->zNodeName[nName], "_node", 6); /* Create/Connect to the underlying relational database schema. If @@ -209381,7 +210557,6 @@ static int rtreeCheckTable( ){ RtreeCheck check; /* Common context for various routines */ sqlite3_stmt *pStmt = 0; /* Used to find column count of rtree table */ - int bEnd = 0; /* True if transaction should be closed */ int nAux = 0; /* Number of extra columns. */ /* Initialize the context object */ @@ -209390,14 +210565,6 @@ static int rtreeCheckTable( check.zDb = zDb; check.zTab = zTab; - /* If there is not already an open transaction, open one now. This is - ** to ensure that the queries run as part of this integrity-check operate - ** on a consistent snapshot. */ - if( sqlite3_get_autocommit(db) ){ - check.rc = sqlite3_exec(db, "BEGIN", 0, 0, 0); - bEnd = 1; - } - /* Find the number of auxiliary columns */ if( check.rc==SQLITE_OK ){ pStmt = rtreeCheckPrepare(&check, "SELECT * FROM %Q.'%q_rowid'", zDb, zTab); @@ -209438,15 +210605,34 @@ static int rtreeCheckTable( sqlite3_finalize(check.aCheckMapping[0]); sqlite3_finalize(check.aCheckMapping[1]); - /* If one was opened, close the transaction */ - if( bEnd ){ - int rc = sqlite3_exec(db, "END", 0, 0, 0); - if( check.rc==SQLITE_OK ) check.rc = rc; - } *pzReport = check.zReport; return check.rc; } +/* +** Implementation of the xIntegrity method for Rtree. +*/ +static int rtreeIntegrity( + sqlite3_vtab *pVtab, /* The virtual table to check */ + const char *zSchema, /* Schema in which the virtual table lives */ + const char *zName, /* Name of the virtual table */ + int isQuick, /* True for a quick_check */ + char **pzErr /* Write results here */ +){ + Rtree *pRtree = (Rtree*)pVtab; + int rc; + assert( pzErr!=0 && *pzErr==0 ); + UNUSED_PARAMETER(zSchema); + UNUSED_PARAMETER(zName); + UNUSED_PARAMETER(isQuick); + rc = rtreeCheckTable(pRtree->db, pRtree->zDb, pRtree->zName, pzErr); + if( rc==SQLITE_OK && *pzErr ){ + *pzErr = sqlite3_mprintf("In RTree %s.%s:\n%z", + pRtree->zDb, pRtree->zName, *pzErr); + } + return rc; +} + /* ** Usage: ** @@ -210768,24 +211954,28 @@ static int geopolyInit( (void)pAux; sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1); + sqlite3_vtab_config(db, SQLITE_VTAB_INNOCUOUS); /* Allocate the sqlite3_vtab structure */ nDb = strlen(argv[1]); nName = strlen(argv[2]); - pRtree = (Rtree *)sqlite3_malloc64(sizeof(Rtree)+nDb+nName+2); + pRtree = (Rtree *)sqlite3_malloc64(sizeof(Rtree)+nDb+nName*2+8); if( !pRtree ){ return SQLITE_NOMEM; } - memset(pRtree, 0, sizeof(Rtree)+nDb+nName+2); + memset(pRtree, 0, sizeof(Rtree)+nDb+nName*2+8); pRtree->nBusy = 1; pRtree->base.pModule = &rtreeModule; pRtree->zDb = (char *)&pRtree[1]; pRtree->zName = &pRtree->zDb[nDb+1]; + pRtree->zNodeName = &pRtree->zName[nName+1]; pRtree->eCoordType = RTREE_COORD_REAL32; pRtree->nDim = 2; pRtree->nDim2 = 4; memcpy(pRtree->zDb, argv[1], nDb); memcpy(pRtree->zName, argv[2], nName); + memcpy(pRtree->zNodeName, argv[2], nName); + memcpy(&pRtree->zNodeName[nName], "_node", 6); /* Create/Connect to the underlying relational database schema. If @@ -211199,7 +212389,6 @@ static int geopolyUpdate( } if( rc==SQLITE_OK ){ int rc2; - pRtree->iReinsertHeight = -1; rc = rtreeInsertCell(pRtree, pLeaf, &cell, 0); rc2 = nodeRelease(pRtree, pLeaf); if( rc==SQLITE_OK ){ @@ -211296,7 +212485,8 @@ static sqlite3_module geopolyModule = { rtreeSavepoint, /* xSavepoint */ 0, /* xRelease */ 0, /* xRollbackTo */ - rtreeShadowName /* xShadowName */ + rtreeShadowName, /* xShadowName */ + rtreeIntegrity /* xIntegrity */ }; static int sqlite3_geopoly_init(sqlite3 *db){ @@ -219310,7 +220500,8 @@ SQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3 *db){ 0, /* xSavepoint */ 0, /* xRelease */ 0, /* xRollbackTo */ - 0 /* xShadowName */ + 0, /* xShadowName */ + 0 /* xIntegrity */ }; return sqlite3_create_module(db, "dbstat", &dbstat_module, 0); } @@ -219747,7 +220938,8 @@ SQLITE_PRIVATE int sqlite3DbpageRegister(sqlite3 *db){ 0, /* xSavepoint */ 0, /* xRelease */ 0, /* xRollbackTo */ - 0 /* xShadowName */ + 0, /* xShadowName */ + 0 /* xIntegrity */ }; return sqlite3_create_module(db, "sqlite_dbpage", &dbpage_module, 0); } @@ -219878,6 +221070,18 @@ struct sqlite3_changeset_iter { ** The data associated with each hash-table entry is a structure containing ** a subset of the initial values that the modified row contained at the ** start of the session. Or no initial values if the row was inserted. +** +** pDfltStmt: +** This is only used by the sqlite3changegroup_xxx() APIs, not by +** regular sqlite3_session objects. It is a SELECT statement that +** selects the default value for each table column. For example, +** if the table is +** +** CREATE TABLE xx(a DEFAULT 1, b, c DEFAULT 'abc') +** +** then this variable is the compiled version of: +** +** SELECT 1, NULL, 'abc' */ struct SessionTable { SessionTable *pNext; @@ -219886,10 +221090,12 @@ struct SessionTable { int bStat1; /* True if this is sqlite_stat1 */ int bRowid; /* True if this table uses rowid for PK */ const char **azCol; /* Column names */ + const char **azDflt; /* Default value expressions */ u8 *abPK; /* Array of primary key flags */ int nEntry; /* Total number of entries in hash table */ int nChange; /* Size of apChange[] array */ SessionChange **apChange; /* Hash table buckets */ + sqlite3_stmt *pDfltStmt; }; /* @@ -220058,6 +221264,7 @@ struct SessionTable { struct SessionChange { u8 op; /* One of UPDATE, DELETE, INSERT */ u8 bIndirect; /* True if this change is "indirect" */ + u16 nRecordField; /* Number of fields in aRecord[] */ int nMaxSize; /* Max size of eventual changeset record */ int nRecord; /* Number of bytes in buffer aRecord[] */ u8 *aRecord; /* Buffer containing old.* record */ @@ -220083,7 +221290,7 @@ static int sessionVarintLen(int iVal){ ** Read a varint value from aBuf[] into *piVal. Return the number of ** bytes read. */ -static int sessionVarintGet(u8 *aBuf, int *piVal){ +static int sessionVarintGet(const u8 *aBuf, int *piVal){ return getVarint32(aBuf, *piVal); } @@ -220346,9 +221553,11 @@ static int sessionPreupdateHash( ** Return the number of bytes of space occupied by the value (including ** the type byte). */ -static int sessionSerialLen(u8 *a){ - int e = *a; +static int sessionSerialLen(const u8 *a){ + int e; int n; + assert( a!=0 ); + e = *a; if( e==0 || e==0xFF ) return 1; if( e==SQLITE_NULL ) return 1; if( e==SQLITE_INTEGER || e==SQLITE_FLOAT ) return 9; @@ -220753,13 +221962,14 @@ static int sessionGrowHash( ** ** For example, if the table is declared as: ** -** CREATE TABLE tbl1(w, x, y, z, PRIMARY KEY(w, z)); +** CREATE TABLE tbl1(w, x DEFAULT 'abc', y, z, PRIMARY KEY(w, z)); ** -** Then the four output variables are populated as follows: +** Then the five output variables are populated as follows: ** ** *pnCol = 4 ** *pzTab = "tbl1" ** *pazCol = {"w", "x", "y", "z"} +** *pazDflt = {NULL, 'abc', NULL, NULL} ** *pabPK = {1, 0, 0, 1} ** ** All returned buffers are part of the same single allocation, which must @@ -220773,6 +221983,7 @@ static int sessionTableInfo( int *pnCol, /* OUT: number of columns */ const char **pzTab, /* OUT: Copy of zThis */ const char ***pazCol, /* OUT: Array of column names for table */ + const char ***pazDflt, /* OUT: Array of default value expressions */ u8 **pabPK, /* OUT: Array of booleans - true for PK col */ int *pbRowid /* OUT: True if only PK is a rowid */ ){ @@ -220785,11 +221996,18 @@ static int sessionTableInfo( int i; u8 *pAlloc = 0; char **azCol = 0; + char **azDflt = 0; u8 *abPK = 0; int bRowid = 0; /* Set to true to use rowid as PK */ assert( pazCol && pabPK ); + *pazCol = 0; + *pabPK = 0; + *pnCol = 0; + if( pzTab ) *pzTab = 0; + if( pazDflt ) *pazDflt = 0; + nThis = sqlite3Strlen30(zThis); if( nThis==12 && 0==sqlite3_stricmp("sqlite_stat1", zThis) ){ rc = sqlite3_table_column_metadata(db, zDb, zThis, 0, 0, 0, 0, 0, 0); @@ -220803,39 +222021,28 @@ static int sessionTableInfo( }else if( rc==SQLITE_ERROR ){ zPragma = sqlite3_mprintf(""); }else{ - *pazCol = 0; - *pabPK = 0; - *pnCol = 0; - if( pzTab ) *pzTab = 0; return rc; } }else{ zPragma = sqlite3_mprintf("PRAGMA '%q'.table_info('%q')", zDb, zThis); } if( !zPragma ){ - *pazCol = 0; - *pabPK = 0; - *pnCol = 0; - if( pzTab ) *pzTab = 0; return SQLITE_NOMEM; } rc = sqlite3_prepare_v2(db, zPragma, -1, &pStmt, 0); sqlite3_free(zPragma); if( rc!=SQLITE_OK ){ - *pazCol = 0; - *pabPK = 0; - *pnCol = 0; - if( pzTab ) *pzTab = 0; return rc; } nByte = nThis + 1; bRowid = (pbRowid!=0); while( SQLITE_ROW==sqlite3_step(pStmt) ){ - nByte += sqlite3_column_bytes(pStmt, 1); + nByte += sqlite3_column_bytes(pStmt, 1); /* name */ + nByte += sqlite3_column_bytes(pStmt, 4); /* dflt_value */ nDbCol++; - if( sqlite3_column_int(pStmt, 5) ) bRowid = 0; + if( sqlite3_column_int(pStmt, 5) ) bRowid = 0; /* pk */ } if( nDbCol==0 ) bRowid = 0; nDbCol += bRowid; @@ -220843,15 +222050,18 @@ static int sessionTableInfo( rc = sqlite3_reset(pStmt); if( rc==SQLITE_OK ){ - nByte += nDbCol * (sizeof(const char *) + sizeof(u8) + 1); + nByte += nDbCol * (sizeof(const char *)*2 + sizeof(u8) + 1 + 1); pAlloc = sessionMalloc64(pSession, nByte); if( pAlloc==0 ){ rc = SQLITE_NOMEM; + }else{ + memset(pAlloc, 0, nByte); } } if( rc==SQLITE_OK ){ azCol = (char **)pAlloc; - pAlloc = (u8 *)&azCol[nDbCol]; + azDflt = (char**)&azCol[nDbCol]; + pAlloc = (u8 *)&azDflt[nDbCol]; abPK = (u8 *)pAlloc; pAlloc = &abPK[nDbCol]; if( pzTab ){ @@ -220871,11 +222081,21 @@ static int sessionTableInfo( } while( SQLITE_ROW==sqlite3_step(pStmt) ){ int nName = sqlite3_column_bytes(pStmt, 1); + int nDflt = sqlite3_column_bytes(pStmt, 4); const unsigned char *zName = sqlite3_column_text(pStmt, 1); + const unsigned char *zDflt = sqlite3_column_text(pStmt, 4); + if( zName==0 ) break; memcpy(pAlloc, zName, nName+1); azCol[i] = (char *)pAlloc; pAlloc += nName+1; + if( zDflt ){ + memcpy(pAlloc, zDflt, nDflt+1); + azDflt[i] = (char *)pAlloc; + pAlloc += nDflt+1; + }else{ + azDflt[i] = 0; + } abPK[i] = sqlite3_column_int(pStmt, 5); i++; } @@ -220886,14 +222106,11 @@ static int sessionTableInfo( ** free any allocation made. An error code will be returned in this case. */ if( rc==SQLITE_OK ){ - *pazCol = (const char **)azCol; + *pazCol = (const char**)azCol; + if( pazDflt ) *pazDflt = (const char**)azDflt; *pabPK = abPK; *pnCol = nDbCol; }else{ - *pazCol = 0; - *pabPK = 0; - *pnCol = 0; - if( pzTab ) *pzTab = 0; sessionFree(pSession, azCol); } if( pbRowid ) *pbRowid = bRowid; @@ -220902,10 +222119,9 @@ static int sessionTableInfo( } /* -** This function is only called from within a pre-update handler for a -** write to table pTab, part of session pSession. If this is the first -** write to this table, initalize the SessionTable.nCol, azCol[] and -** abPK[] arrays accordingly. +** This function is called to initialize the SessionTable.nCol, azCol[] +** abPK[] and azDflt[] members of SessionTable object pTab. If these +** fields are already initilialized, this function is a no-op. ** ** If an error occurs, an error code is stored in sqlite3_session.rc and ** non-zero returned. Or, if no error occurs but the table has no primary @@ -220913,15 +222129,22 @@ static int sessionTableInfo( ** indicate that updates on this table should be ignored. SessionTable.abPK ** is set to NULL in this case. */ -static int sessionInitTable(sqlite3_session *pSession, SessionTable *pTab){ +static int sessionInitTable( + sqlite3_session *pSession, /* Optional session handle */ + SessionTable *pTab, /* Table object to initialize */ + sqlite3 *db, /* Database handle to read schema from */ + const char *zDb /* Name of db - "main", "temp" etc. */ +){ + int rc = SQLITE_OK; + if( pTab->nCol==0 ){ u8 *abPK; assert( pTab->azCol==0 || pTab->abPK==0 ); - pSession->rc = sessionTableInfo(pSession, pSession->db, pSession->zDb, - pTab->zName, &pTab->nCol, 0, &pTab->azCol, &abPK, - (pSession->bImplicitPK ? &pTab->bRowid : 0) + rc = sessionTableInfo(pSession, db, zDb, + pTab->zName, &pTab->nCol, 0, &pTab->azCol, &pTab->azDflt, &abPK, + ((pSession==0 || pSession->bImplicitPK) ? &pTab->bRowid : 0) ); - if( pSession->rc==SQLITE_OK ){ + if( rc==SQLITE_OK ){ int i; for(i=0; inCol; i++){ if( abPK[i] ){ @@ -220933,14 +222156,321 @@ static int sessionInitTable(sqlite3_session *pSession, SessionTable *pTab){ pTab->bStat1 = 1; } - if( pSession->bEnableSize ){ + if( pSession && pSession->bEnableSize ){ pSession->nMaxChangesetSize += ( 1 + sessionVarintLen(pTab->nCol) + pTab->nCol + strlen(pTab->zName)+1 ); } } } - return (pSession->rc || pTab->abPK==0); + + if( pSession ){ + pSession->rc = rc; + return (rc || pTab->abPK==0); + } + return rc; +} + +/* +** Re-initialize table object pTab. +*/ +static int sessionReinitTable(sqlite3_session *pSession, SessionTable *pTab){ + int nCol = 0; + const char **azCol = 0; + const char **azDflt = 0; + u8 *abPK = 0; + int bRowid = 0; + + assert( pSession->rc==SQLITE_OK ); + + pSession->rc = sessionTableInfo(pSession, pSession->db, pSession->zDb, + pTab->zName, &nCol, 0, &azCol, &azDflt, &abPK, + (pSession->bImplicitPK ? &bRowid : 0) + ); + if( pSession->rc==SQLITE_OK ){ + if( pTab->nCol>nCol || pTab->bRowid!=bRowid ){ + pSession->rc = SQLITE_SCHEMA; + }else{ + int ii; + int nOldCol = pTab->nCol; + for(ii=0; iinCol ){ + if( pTab->abPK[ii]!=abPK[ii] ){ + pSession->rc = SQLITE_SCHEMA; + } + }else if( abPK[ii] ){ + pSession->rc = SQLITE_SCHEMA; + } + } + + if( pSession->rc==SQLITE_OK ){ + const char **a = pTab->azCol; + pTab->azCol = azCol; + pTab->nCol = nCol; + pTab->azDflt = azDflt; + pTab->abPK = abPK; + azCol = a; + } + if( pSession->bEnableSize ){ + pSession->nMaxChangesetSize += (nCol - nOldCol); + pSession->nMaxChangesetSize += sessionVarintLen(nCol); + pSession->nMaxChangesetSize -= sessionVarintLen(nOldCol); + } + } + } + + sqlite3_free((char*)azCol); + return pSession->rc; +} + +/* +** Session-change object (*pp) contains an old.* record with fewer than +** nCol fields. This function updates it with the default values for +** the missing fields. +*/ +static void sessionUpdateOneChange( + sqlite3_session *pSession, /* For memory accounting */ + int *pRc, /* IN/OUT: Error code */ + SessionChange **pp, /* IN/OUT: Change object to update */ + int nCol, /* Number of columns now in table */ + sqlite3_stmt *pDflt /* SELECT */ +){ + SessionChange *pOld = *pp; + + while( pOld->nRecordFieldnRecordField; + int eType = sqlite3_column_type(pDflt, iField); + switch( eType ){ + case SQLITE_NULL: + nIncr = 1; + break; + case SQLITE_INTEGER: + case SQLITE_FLOAT: + nIncr = 9; + break; + default: { + int n = sqlite3_column_bytes(pDflt, iField); + nIncr = 1 + sessionVarintLen(n) + n; + assert( eType==SQLITE_TEXT || eType==SQLITE_BLOB ); + break; + } + } + + nByte = nIncr + (sizeof(SessionChange) + pOld->nRecord); + pNew = sessionMalloc64(pSession, nByte); + if( pNew==0 ){ + *pRc = SQLITE_NOMEM; + return; + }else{ + memcpy(pNew, pOld, sizeof(SessionChange)); + pNew->aRecord = (u8*)&pNew[1]; + memcpy(pNew->aRecord, pOld->aRecord, pOld->nRecord); + pNew->aRecord[pNew->nRecord++] = (u8)eType; + switch( eType ){ + case SQLITE_INTEGER: { + i64 iVal = sqlite3_column_int64(pDflt, iField); + sessionPutI64(&pNew->aRecord[pNew->nRecord], iVal); + pNew->nRecord += 8; + break; + } + + case SQLITE_FLOAT: { + double rVal = sqlite3_column_double(pDflt, iField); + i64 iVal = 0; + memcpy(&iVal, &rVal, sizeof(rVal)); + sessionPutI64(&pNew->aRecord[pNew->nRecord], iVal); + pNew->nRecord += 8; + break; + } + + case SQLITE_TEXT: { + int n = sqlite3_column_bytes(pDflt, iField); + const char *z = (const char*)sqlite3_column_text(pDflt, iField); + pNew->nRecord += sessionVarintPut(&pNew->aRecord[pNew->nRecord], n); + memcpy(&pNew->aRecord[pNew->nRecord], z, n); + pNew->nRecord += n; + break; + } + + case SQLITE_BLOB: { + int n = sqlite3_column_bytes(pDflt, iField); + const u8 *z = (const u8*)sqlite3_column_blob(pDflt, iField); + pNew->nRecord += sessionVarintPut(&pNew->aRecord[pNew->nRecord], n); + memcpy(&pNew->aRecord[pNew->nRecord], z, n); + pNew->nRecord += n; + break; + } + + default: + assert( eType==SQLITE_NULL ); + break; + } + + sessionFree(pSession, pOld); + *pp = pOld = pNew; + pNew->nRecordField++; + pNew->nMaxSize += nIncr; + if( pSession ){ + pSession->nMaxChangesetSize += nIncr; + } + } + } +} + +/* +** Ensure that there is room in the buffer to append nByte bytes of data. +** If not, use sqlite3_realloc() to grow the buffer so that there is. +** +** If successful, return zero. Otherwise, if an OOM condition is encountered, +** set *pRc to SQLITE_NOMEM and return non-zero. +*/ +static int sessionBufferGrow(SessionBuffer *p, i64 nByte, int *pRc){ +#define SESSION_MAX_BUFFER_SZ (0x7FFFFF00 - 1) + i64 nReq = p->nBuf + nByte; + if( *pRc==SQLITE_OK && nReq>p->nAlloc ){ + u8 *aNew; + i64 nNew = p->nAlloc ? p->nAlloc : 128; + + do { + nNew = nNew*2; + }while( nNewSESSION_MAX_BUFFER_SZ ){ + nNew = SESSION_MAX_BUFFER_SZ; + if( nNewaBuf, nNew); + if( 0==aNew ){ + *pRc = SQLITE_NOMEM; + }else{ + p->aBuf = aNew; + p->nAlloc = nNew; + } + } + return (*pRc!=SQLITE_OK); +} + + +/* +** This function is a no-op if *pRc is other than SQLITE_OK when it is +** called. Otherwise, append a string to the buffer. All bytes in the string +** up to (but not including) the nul-terminator are written to the buffer. +** +** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before +** returning. +*/ +static void sessionAppendStr( + SessionBuffer *p, + const char *zStr, + int *pRc +){ + int nStr = sqlite3Strlen30(zStr); + if( 0==sessionBufferGrow(p, nStr+1, pRc) ){ + memcpy(&p->aBuf[p->nBuf], zStr, nStr); + p->nBuf += nStr; + p->aBuf[p->nBuf] = 0x00; + } +} + +/* +** Format a string using printf() style formatting and then append it to the +** buffer using sessionAppendString(). +*/ +static void sessionAppendPrintf( + SessionBuffer *p, /* Buffer to append to */ + int *pRc, + const char *zFmt, + ... +){ + if( *pRc==SQLITE_OK ){ + char *zApp = 0; + va_list ap; + va_start(ap, zFmt); + zApp = sqlite3_vmprintf(zFmt, ap); + if( zApp==0 ){ + *pRc = SQLITE_NOMEM; + }else{ + sessionAppendStr(p, zApp, pRc); + } + va_end(ap); + sqlite3_free(zApp); + } +} + +/* +** Prepare a statement against database handle db that SELECTs a single +** row containing the default values for each column in table pTab. For +** example, if pTab is declared as: +** +** CREATE TABLE pTab(a PRIMARY KEY, b DEFAULT 123, c DEFAULT 'abcd'); +** +** Then this function prepares and returns the SQL statement: +** +** SELECT NULL, 123, 'abcd'; +*/ +static int sessionPrepareDfltStmt( + sqlite3 *db, /* Database handle */ + SessionTable *pTab, /* Table to prepare statement for */ + sqlite3_stmt **ppStmt /* OUT: Statement handle */ +){ + SessionBuffer sql = {0,0,0}; + int rc = SQLITE_OK; + const char *zSep = " "; + int ii = 0; + + *ppStmt = 0; + sessionAppendPrintf(&sql, &rc, "SELECT"); + for(ii=0; iinCol; ii++){ + const char *zDflt = pTab->azDflt[ii] ? pTab->azDflt[ii] : "NULL"; + sessionAppendPrintf(&sql, &rc, "%s%s", zSep, zDflt); + zSep = ", "; + } + if( rc==SQLITE_OK ){ + rc = sqlite3_prepare_v2(db, (const char*)sql.aBuf, -1, ppStmt, 0); + } + sqlite3_free(sql.aBuf); + + return rc; +} + +/* +** Table pTab has one or more existing change-records with old.* records +** with fewer than pTab->nCol columns. This function updates all such +** change-records with the default values for the missing columns. +*/ +static int sessionUpdateChanges(sqlite3_session *pSession, SessionTable *pTab){ + sqlite3_stmt *pStmt = 0; + int rc = pSession->rc; + + rc = sessionPrepareDfltStmt(pSession->db, pTab, &pStmt); + if( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){ + int ii = 0; + SessionChange **pp = 0; + for(ii=0; iinChange; ii++){ + for(pp=&pTab->apChange[ii]; *pp; pp=&((*pp)->pNext)){ + if( (*pp)->nRecordField!=pTab->nCol ){ + sessionUpdateOneChange(pSession, &rc, pp, pTab->nCol, pStmt); + } + } + } + } + + pSession->rc = rc; + rc = sqlite3_finalize(pStmt); + if( pSession->rc==SQLITE_OK ) pSession->rc = rc; + return pSession->rc; } /* @@ -221103,16 +222633,22 @@ static void sessionPreupdateOneChange( int iHash; int bNull = 0; int rc = SQLITE_OK; + int nExpect = 0; SessionStat1Ctx stat1 = {{0,0,0,0,0},0}; if( pSession->rc ) return; /* Load table details if required */ - if( sessionInitTable(pSession, pTab) ) return; + if( sessionInitTable(pSession, pTab, pSession->db, pSession->zDb) ) return; /* Check the number of columns in this xPreUpdate call matches the ** number of columns in the table. */ - if( (pTab->nCol-pTab->bRowid)!=pSession->hook.xCount(pSession->hook.pCtx) ){ + nExpect = pSession->hook.xCount(pSession->hook.pCtx); + if( (pTab->nCol-pTab->bRowid)nCol-pTab->bRowid)!=nExpect ){ pSession->rc = SQLITE_SCHEMA; return; } @@ -221189,7 +222725,7 @@ static void sessionPreupdateOneChange( } /* Allocate the change object */ - pC = (SessionChange *)sessionMalloc64(pSession, nByte); + pC = (SessionChange*)sessionMalloc64(pSession, nByte); if( !pC ){ rc = SQLITE_NOMEM; goto error_out; @@ -221222,6 +222758,7 @@ static void sessionPreupdateOneChange( if( pSession->bIndirect || pSession->hook.xDepth(pSession->hook.pCtx) ){ pC->bIndirect = 1; } + pC->nRecordField = pTab->nCol; pC->nRecord = nByte; pC->op = op; pC->pNext = pTab->apChange[iHash]; @@ -221601,7 +223138,7 @@ SQLITE_API int sqlite3session_diff( /* Locate and if necessary initialize the target table object */ rc = sessionFindTable(pSession, zTbl, &pTo); if( pTo==0 ) goto diff_out; - if( sessionInitTable(pSession, pTo) ){ + if( sessionInitTable(pSession, pTo, pSession->db, pSession->zDb) ){ rc = pSession->rc; goto diff_out; } @@ -221614,7 +223151,7 @@ SQLITE_API int sqlite3session_diff( int bRowid = 0; u8 *abPK; const char **azCol = 0; - rc = sessionTableInfo(0, db, zFrom, zTbl, &nCol, 0, &azCol, &abPK, + rc = sessionTableInfo(0, db, zFrom, zTbl, &nCol, 0, &azCol, 0, &abPK, pSession->bImplicitPK ? &bRowid : 0 ); if( rc==SQLITE_OK ){ @@ -221729,6 +223266,7 @@ static void sessionDeleteTable(sqlite3_session *pSession, SessionTable *pList){ sessionFree(pSession, p); } } + sqlite3_finalize(pTab->pDfltStmt); sessionFree(pSession, (char*)pTab->azCol); /* cast works around VC++ bug */ sessionFree(pSession, pTab->apChange); sessionFree(pSession, pTab); @@ -221763,7 +223301,7 @@ SQLITE_API void sqlite3session_delete(sqlite3_session *pSession){ /* Assert that all allocations have been freed and then free the ** session object itself. */ - assert( pSession->nMalloc==0 ); + // assert( pSession->nMalloc==0 ); sqlite3_free(pSession); } @@ -221834,48 +223372,6 @@ SQLITE_API int sqlite3session_attach( return rc; } -/* -** Ensure that there is room in the buffer to append nByte bytes of data. -** If not, use sqlite3_realloc() to grow the buffer so that there is. -** -** If successful, return zero. Otherwise, if an OOM condition is encountered, -** set *pRc to SQLITE_NOMEM and return non-zero. -*/ -static int sessionBufferGrow(SessionBuffer *p, i64 nByte, int *pRc){ -#define SESSION_MAX_BUFFER_SZ (0x7FFFFF00 - 1) - i64 nReq = p->nBuf + nByte; - if( *pRc==SQLITE_OK && nReq>p->nAlloc ){ - u8 *aNew; - i64 nNew = p->nAlloc ? p->nAlloc : 128; - - do { - nNew = nNew*2; - }while( nNewSESSION_MAX_BUFFER_SZ ){ - nNew = SESSION_MAX_BUFFER_SZ; - if( nNewaBuf, nNew); - if( 0==aNew ){ - *pRc = SQLITE_NOMEM; - }else{ - p->aBuf = aNew; - p->nAlloc = nNew; - } - } - return (*pRc!=SQLITE_OK); -} - /* ** Append the value passed as the second argument to the buffer passed ** as the first. @@ -221944,27 +223440,6 @@ static void sessionAppendBlob( } } -/* -** This function is a no-op if *pRc is other than SQLITE_OK when it is -** called. Otherwise, append a string to the buffer. All bytes in the string -** up to (but not including) the nul-terminator are written to the buffer. -** -** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before -** returning. -*/ -static void sessionAppendStr( - SessionBuffer *p, - const char *zStr, - int *pRc -){ - int nStr = sqlite3Strlen30(zStr); - if( 0==sessionBufferGrow(p, nStr+1, pRc) ){ - memcpy(&p->aBuf[p->nBuf], zStr, nStr); - p->nBuf += nStr; - p->aBuf[p->nBuf] = 0x00; - } -} - /* ** This function is a no-op if *pRc is other than SQLITE_OK when it is ** called. Otherwise, append the string representation of integer iVal @@ -221983,27 +223458,6 @@ static void sessionAppendInteger( sessionAppendStr(p, aBuf, pRc); } -static void sessionAppendPrintf( - SessionBuffer *p, /* Buffer to append to */ - int *pRc, - const char *zFmt, - ... -){ - if( *pRc==SQLITE_OK ){ - char *zApp = 0; - va_list ap; - va_start(ap, zFmt); - zApp = sqlite3_vmprintf(zFmt, ap); - if( zApp==0 ){ - *pRc = SQLITE_NOMEM; - }else{ - sessionAppendStr(p, zApp, pRc); - } - va_end(ap); - sqlite3_free(zApp); - } -} - /* ** This function is a no-op if *pRc is other than SQLITE_OK when it is ** called. Otherwise, append the string zStr enclosed in quotes (") and @@ -222494,26 +223948,16 @@ static int sessionGenerateChangeset( for(pTab=pSession->pTable; rc==SQLITE_OK && pTab; pTab=pTab->pNext){ if( pTab->nEntry ){ const char *zName = pTab->zName; - int nCol = 0; /* Number of columns in table */ - u8 *abPK = 0; /* Primary key array */ - const char **azCol = 0; /* Table columns */ int i; /* Used to iterate through hash buckets */ sqlite3_stmt *pSel = 0; /* SELECT statement to query table pTab */ int nRewind = buf.nBuf; /* Initial size of write buffer */ int nNoop; /* Size of buffer after writing tbl header */ - int bRowid = 0; + int nOldCol = pTab->nCol; /* Check the table schema is still Ok. */ - rc = sessionTableInfo( - 0, db, pSession->zDb, zName, &nCol, 0, &azCol, &abPK, - (pSession->bImplicitPK ? &bRowid : 0) - ); - if( rc==SQLITE_OK && ( - pTab->nCol!=nCol - || pTab->bRowid!=bRowid - || memcmp(abPK, pTab->abPK, nCol) - )){ - rc = SQLITE_SCHEMA; + rc = sessionReinitTable(pSession, pTab); + if( rc==SQLITE_OK && pTab->nCol!=nOldCol ){ + rc = sessionUpdateChanges(pSession, pTab); } /* Write a table header */ @@ -222521,8 +223965,8 @@ static int sessionGenerateChangeset( /* Build and compile a statement to execute: */ if( rc==SQLITE_OK ){ - rc = sessionSelectStmt( - db, 0, pSession->zDb, zName, bRowid, nCol, azCol, abPK, &pSel + rc = sessionSelectStmt(db, 0, pSession->zDb, + zName, pTab->bRowid, pTab->nCol, pTab->azCol, pTab->abPK, &pSel ); } @@ -222531,22 +223975,22 @@ static int sessionGenerateChangeset( SessionChange *p; /* Used to iterate through changes */ for(p=pTab->apChange[i]; rc==SQLITE_OK && p; p=p->pNext){ - rc = sessionSelectBind(pSel, nCol, abPK, p); + rc = sessionSelectBind(pSel, pTab->nCol, pTab->abPK, p); if( rc!=SQLITE_OK ) continue; if( sqlite3_step(pSel)==SQLITE_ROW ){ if( p->op==SQLITE_INSERT ){ int iCol; sessionAppendByte(&buf, SQLITE_INSERT, &rc); sessionAppendByte(&buf, p->bIndirect, &rc); - for(iCol=0; iColnCol; iCol++){ sessionAppendCol(&buf, pSel, iCol, &rc); } }else{ - assert( abPK!=0 ); /* Because sessionSelectStmt() returned ok */ - rc = sessionAppendUpdate(&buf, bPatchset, pSel, p, abPK); + assert( pTab->abPK!=0 ); + rc = sessionAppendUpdate(&buf, bPatchset, pSel, p, pTab->abPK); } }else if( p->op!=SQLITE_INSERT ){ - rc = sessionAppendDelete(&buf, bPatchset, p, nCol, abPK); + rc = sessionAppendDelete(&buf, bPatchset, p, pTab->nCol,pTab->abPK); } if( rc==SQLITE_OK ){ rc = sqlite3_reset(pSel); @@ -222571,7 +224015,6 @@ static int sessionGenerateChangeset( if( buf.nBuf==nNoop ){ buf.nBuf = nRewind; } - sqlite3_free((char*)azCol); /* cast works around VC++ bug */ } } @@ -224700,7 +226143,7 @@ static int sessionChangesetApply( sqlite3changeset_pk(pIter, &abPK, 0); rc = sessionTableInfo(0, db, "main", zNew, - &sApply.nCol, &zTab, &sApply.azCol, &sApply.abPK, &sApply.bRowid + &sApply.nCol, &zTab, &sApply.azCol, 0, &sApply.abPK, &sApply.bRowid ); if( rc!=SQLITE_OK ) break; for(i=0; iflags & SQLITE_FkNoAction; + + if( flags & SQLITE_CHANGESETAPPLY_FKNOACTION ){ + db->flags |= ((u64)SQLITE_FkNoAction); + db->aDb[0].pSchema->schema_cookie -= 32; + } + if( rc==SQLITE_OK ){ rc = sessionChangesetApply( db, pIter, xFilter, xConflict, pCtx, ppRebase, pnRebase, flags ); } + + if( (flags & SQLITE_CHANGESETAPPLY_FKNOACTION) && savedFlag==0 ){ + assert( db->flags & SQLITE_FkNoAction ); + db->flags &= ~((u64)SQLITE_FkNoAction); + db->aDb[0].pSchema->schema_cookie -= 32; + } return rc; } @@ -224924,6 +226380,9 @@ struct sqlite3_changegroup { int rc; /* Error code */ int bPatch; /* True to accumulate patchsets */ SessionTable *pList; /* List of tables in current patch */ + + sqlite3 *db; /* Configured by changegroup_schema() */ + char *zDb; /* Configured by changegroup_schema() */ }; /* @@ -224944,6 +226403,7 @@ static int sessionChangeMerge( ){ SessionChange *pNew = 0; int rc = SQLITE_OK; + assert( aRec!=0 ); if( !pExist ){ pNew = (SessionChange *)sqlite3_malloc64(sizeof(SessionChange) + nRec); @@ -225109,6 +226569,114 @@ static int sessionChangeMerge( return rc; } +/* +** Check if a changeset entry with nCol columns and the PK array passed +** as the final argument to this function is compatible with SessionTable +** pTab. If so, return 1. Otherwise, if they are incompatible in some way, +** return 0. +*/ +static int sessionChangesetCheckCompat( + SessionTable *pTab, + int nCol, + u8 *abPK +){ + if( pTab->azCol && nColnCol ){ + int ii; + for(ii=0; iinCol; ii++){ + u8 bPK = (ii < nCol) ? abPK[ii] : 0; + if( pTab->abPK[ii]!=bPK ) return 0; + } + return 1; + } + return (pTab->nCol==nCol && 0==memcmp(abPK, pTab->abPK, nCol)); +} + +static int sessionChangesetExtendRecord( + sqlite3_changegroup *pGrp, + SessionTable *pTab, + int nCol, + int op, + const u8 *aRec, + int nRec, + SessionBuffer *pOut +){ + int rc = SQLITE_OK; + int ii = 0; + + assert( pTab->azCol ); + assert( nColnCol ); + + pOut->nBuf = 0; + if( op==SQLITE_INSERT || (op==SQLITE_DELETE && pGrp->bPatch==0) ){ + /* Append the missing default column values to the record. */ + sessionAppendBlob(pOut, aRec, nRec, &rc); + if( rc==SQLITE_OK && pTab->pDfltStmt==0 ){ + rc = sessionPrepareDfltStmt(pGrp->db, pTab, &pTab->pDfltStmt); + } + for(ii=nCol; rc==SQLITE_OK && iinCol; ii++){ + int eType = sqlite3_column_type(pTab->pDfltStmt, ii); + sessionAppendByte(pOut, eType, &rc); + switch( eType ){ + case SQLITE_FLOAT: + case SQLITE_INTEGER: { + i64 iVal; + if( eType==SQLITE_INTEGER ){ + iVal = sqlite3_column_int64(pTab->pDfltStmt, ii); + }else{ + double rVal = sqlite3_column_int64(pTab->pDfltStmt, ii); + memcpy(&iVal, &rVal, sizeof(i64)); + } + if( SQLITE_OK==sessionBufferGrow(pOut, 8, &rc) ){ + sessionPutI64(&pOut->aBuf[pOut->nBuf], iVal); + } + break; + } + + case SQLITE_BLOB: + case SQLITE_TEXT: { + int n = sqlite3_column_bytes(pTab->pDfltStmt, ii); + sessionAppendVarint(pOut, n, &rc); + if( eType==SQLITE_TEXT ){ + const u8 *z = (const u8*)sqlite3_column_text(pTab->pDfltStmt, ii); + sessionAppendBlob(pOut, z, n, &rc); + }else{ + const u8 *z = (const u8*)sqlite3_column_blob(pTab->pDfltStmt, ii); + sessionAppendBlob(pOut, z, n, &rc); + } + break; + } + + default: + assert( eType==SQLITE_NULL ); + break; + } + } + }else if( op==SQLITE_UPDATE ){ + /* Append missing "undefined" entries to the old.* record. And, if this + ** is an UPDATE, to the new.* record as well. */ + int iOff = 0; + if( pGrp->bPatch==0 ){ + for(ii=0; iinCol-nCol); ii++){ + sessionAppendByte(pOut, 0x00, &rc); + } + } + + sessionAppendBlob(pOut, &aRec[iOff], nRec-iOff, &rc); + for(ii=0; ii<(pTab->nCol-nCol); ii++){ + sessionAppendByte(pOut, 0x00, &rc); + } + }else{ + assert( op==SQLITE_DELETE && pGrp->bPatch ); + sessionAppendBlob(pOut, aRec, nRec, &rc); + } + + return rc; +} + /* ** Add all changes in the changeset traversed by the iterator passed as ** the first argument to the changegroup hash tables. @@ -225122,6 +226690,7 @@ static int sessionChangesetToHash( int nRec; int rc = SQLITE_OK; SessionTable *pTab = 0; + SessionBuffer rec = {0, 0, 0}; while( SQLITE_ROW==sessionChangesetNext(pIter, &aRec, &nRec, 0) ){ const char *zNew; @@ -225133,6 +226702,9 @@ static int sessionChangesetToHash( SessionChange *pExist = 0; SessionChange **pp; + /* Ensure that only changesets, or only patchsets, but not a mixture + ** of both, are being combined. It is an error to try to combine a + ** changeset and a patchset. */ if( pGrp->pList==0 ){ pGrp->bPatch = pIter->bPatchset; }else if( pIter->bPatchset!=pGrp->bPatch ){ @@ -225165,18 +226737,38 @@ static int sessionChangesetToHash( pTab->zName = (char*)&pTab->abPK[nCol]; memcpy(pTab->zName, zNew, nNew+1); + if( pGrp->db ){ + pTab->nCol = 0; + rc = sessionInitTable(0, pTab, pGrp->db, pGrp->zDb); + if( rc ){ + assert( pTab->azCol==0 ); + sqlite3_free(pTab); + break; + } + } + /* The new object must be linked on to the end of the list, not ** simply added to the start of it. This is to ensure that the ** tables within the output of sqlite3changegroup_output() are in ** the right order. */ for(ppTab=&pGrp->pList; *ppTab; ppTab=&(*ppTab)->pNext); *ppTab = pTab; - }else if( pTab->nCol!=nCol || memcmp(pTab->abPK, abPK, nCol) ){ + } + + if( !sessionChangesetCheckCompat(pTab, nCol, abPK) ){ rc = SQLITE_SCHEMA; break; } } + if( nColnCol ){ + assert( pGrp->db ); + rc = sessionChangesetExtendRecord(pGrp, pTab, nCol, op, aRec, nRec, &rec); + if( rc ) break; + aRec = rec.aBuf; + nRec = rec.nBuf; + } + if( sessionGrowHash(0, pIter->bPatchset, pTab) ){ rc = SQLITE_NOMEM; break; @@ -225214,6 +226806,7 @@ static int sessionChangesetToHash( } } + sqlite3_free(rec.aBuf); if( rc==SQLITE_OK ) rc = pIter->rc; return rc; } @@ -225300,6 +226893,31 @@ SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp){ return rc; } +/* +** Provide a database schema to the changegroup object. +*/ +SQLITE_API int sqlite3changegroup_schema( + sqlite3_changegroup *pGrp, + sqlite3 *db, + const char *zDb +){ + int rc = SQLITE_OK; + + if( pGrp->pList || pGrp->db ){ + /* Cannot add a schema after one or more calls to sqlite3changegroup_add(), + ** or after sqlite3changegroup_schema() has already been called. */ + rc = SQLITE_MISUSE; + }else{ + pGrp->zDb = sqlite3_mprintf("%s", zDb); + if( pGrp->zDb==0 ){ + rc = SQLITE_NOMEM; + }else{ + pGrp->db = db; + } + } + return rc; +} + /* ** Add the changeset currently stored in buffer pData, size nData bytes, ** to changeset-group p. @@ -225363,6 +226981,7 @@ SQLITE_API int sqlite3changegroup_output_strm( */ SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup *pGrp){ if( pGrp ){ + sqlite3_free(pGrp->zDb); sessionDeleteTable(0, pGrp->pList); sqlite3_free(pGrp); } @@ -228868,15 +230487,19 @@ static int fts5CInstIterInit( */ typedef struct HighlightContext HighlightContext; struct HighlightContext { - CInstIter iter; /* Coalesced Instance Iterator */ - int iPos; /* Current token offset in zIn[] */ + /* Constant parameters to fts5HighlightCb() */ int iRangeStart; /* First token to include */ int iRangeEnd; /* If non-zero, last token to include */ const char *zOpen; /* Opening highlight */ const char *zClose; /* Closing highlight */ const char *zIn; /* Input text */ int nIn; /* Size of input text in bytes */ - int iOff; /* Current offset within zIn[] */ + + /* Variables modified by fts5HighlightCb() */ + CInstIter iter; /* Coalesced Instance Iterator */ + int iPos; /* Current token offset in zIn[] */ + int iOff; /* Have copied up to this offset in zIn[] */ + int bOpen; /* True if highlight is open */ char *zOut; /* Output value */ }; @@ -228909,8 +230532,8 @@ static int fts5HighlightCb( int tflags, /* Mask of FTS5_TOKEN_* flags */ const char *pToken, /* Buffer containing token */ int nToken, /* Size of token in bytes */ - int iStartOff, /* Start offset of token */ - int iEndOff /* End offset of token */ + int iStartOff, /* Start byte offset of token */ + int iEndOff /* End byte offset of token */ ){ HighlightContext *p = (HighlightContext*)pContext; int rc = SQLITE_OK; @@ -228926,30 +230549,47 @@ static int fts5HighlightCb( if( p->iRangeStart && iPos==p->iRangeStart ) p->iOff = iStartOff; } - if( iPos==p->iter.iStart ){ + /* If the parenthesis is open, and this token is not part of the current + ** phrase, and the starting byte offset of this token is past the point + ** that has currently been copied into the output buffer, close the + ** parenthesis. */ + if( p->bOpen + && (iPos<=p->iter.iStart || p->iter.iStart<0) + && iStartOff>p->iOff + ){ + fts5HighlightAppend(&rc, p, p->zClose, -1); + p->bOpen = 0; + } + + /* If this is the start of a new phrase, and the highlight is not open: + ** + ** * copy text from the input up to the start of the phrase, and + ** * open the highlight. + */ + if( iPos==p->iter.iStart && p->bOpen==0 ){ fts5HighlightAppend(&rc, p, &p->zIn[p->iOff], iStartOff - p->iOff); fts5HighlightAppend(&rc, p, p->zOpen, -1); p->iOff = iStartOff; + p->bOpen = 1; } if( iPos==p->iter.iEnd ){ - if( p->iRangeEnd>=0 && p->iter.iStartiRangeStart ){ + if( p->bOpen==0 ){ + assert( p->iRangeEnd>=0 ); fts5HighlightAppend(&rc, p, p->zOpen, -1); + p->bOpen = 1; } fts5HighlightAppend(&rc, p, &p->zIn[p->iOff], iEndOff - p->iOff); - fts5HighlightAppend(&rc, p, p->zClose, -1); p->iOff = iEndOff; + if( rc==SQLITE_OK ){ rc = fts5CInstIterNext(&p->iter); } } - if( p->iRangeEnd>=0 && iPos==p->iRangeEnd ){ + if( iPos==p->iRangeEnd ){ fts5HighlightAppend(&rc, p, &p->zIn[p->iOff], iEndOff - p->iOff); p->iOff = iEndOff; - if( iPos>=p->iter.iStart && iPositer.iEnd ){ - fts5HighlightAppend(&rc, p, p->zClose, -1); - } } return rc; @@ -228990,6 +230630,9 @@ static void fts5HighlightFunction( if( rc==SQLITE_OK ){ rc = pApi->xTokenize(pFts, ctx.zIn, ctx.nIn, (void*)&ctx,fts5HighlightCb); } + if( ctx.bOpen ){ + fts5HighlightAppend(&rc, &ctx, ctx.zClose, -1); + } fts5HighlightAppend(&rc, &ctx, &ctx.zIn[ctx.iOff], ctx.nIn - ctx.iOff); if( rc==SQLITE_OK ){ @@ -229268,6 +230911,9 @@ static void fts5SnippetFunction( if( rc==SQLITE_OK ){ rc = pApi->xTokenize(pFts, ctx.zIn, ctx.nIn, (void*)&ctx,fts5HighlightCb); } + if( ctx.bOpen ){ + fts5HighlightAppend(&rc, &ctx, ctx.zClose, -1); + } if( ctx.iRangeEnd>=(nColSize-1) ){ fts5HighlightAppend(&rc, &ctx, &ctx.zIn[ctx.iOff], ctx.nIn - ctx.iOff); }else{ @@ -237539,7 +239185,6 @@ static int fts5MultiIterDoCompare(Fts5Iter *pIter, int iOut){ assert_nc( i2!=0 ); pRes->bTermEq = 1; if( p1->iRowid==p2->iRowid ){ - p1->bDel = p2->bDel; return i2; } res = ((p1->iRowid > p2->iRowid)==pIter->bRev) ? -1 : +1; @@ -237907,7 +239552,7 @@ static Fts5Iter *fts5MultiIterAlloc( int nSeg ){ Fts5Iter *pNew; - int nSlot; /* Power of two >= nSeg */ + i64 nSlot; /* Power of two >= nSeg */ for(nSlot=2; nSlotpLeaf->szLeaf; u64 iDelta = 0; - u64 iNextDelta = 0; int iNextOff = 0; int iOff = 0; int nIdx = 0; @@ -239691,7 +241335,6 @@ static void fts5DoSecureDelete( int bLastInDoclist = 0; int iIdx = 0; int iStart = 0; - int iKeyOff = 0; int iDelKeyOff = 0; /* Offset of deleted key, if any */ nIdx = nPg-iPgIdx; @@ -239716,10 +241359,21 @@ static void fts5DoSecureDelete( ** This block sets the following variables: ** ** iStart: + ** The offset of the first byte of the rowid or delta-rowid + ** value for the doclist entry being removed. + ** ** iDelta: + ** The value of the rowid or delta-rowid value for the doclist + ** entry being removed. + ** + ** iNextOff: + ** The offset of the next entry following the position list + ** for the one being removed. If the position list for this + ** entry overflows onto the next leaf page, this value will be + ** greater than pLeaf->szLeaf. */ { - int iSOP; + int iSOP; /* Start-Of-Position-list */ if( pSeg->iLeafPgno==pSeg->iTermLeafPgno ){ iStart = pSeg->iTermLeafOffset; }else{ @@ -239755,47 +241409,75 @@ static void fts5DoSecureDelete( } iOff = iStart; - if( iNextOff>=iPgIdx ){ - int pgno = pSeg->iLeafPgno+1; - fts5SecureDeleteOverflow(p, pSeg->pSeg, pgno, &bLastInDoclist); - iNextOff = iPgIdx; - }else{ - /* Set bLastInDoclist to true if the entry being removed is the last - ** in its doclist. */ - for(iIdx=0, iKeyOff=0; iIdxbDel==0 ){ + if( iNextOff>=iPgIdx ){ + int pgno = pSeg->iLeafPgno+1; + fts5SecureDeleteOverflow(p, pSeg->pSeg, pgno, &bLastInDoclist); + iNextOff = iPgIdx; + }else{ + /* Loop through the page-footer. If iNextOff (offset of the + ** entry following the one we are removing) is equal to the + ** offset of a key on this page, then the entry is the last + ** in its doclist. */ + int iKeyOff = 0; + for(iIdx=0; iIdxbDel ){ + iOff += sqlite3Fts5PutVarint(&aPg[iOff], iDelta); + aPg[iOff++] = 0x01; + }else if( bLastInDoclist==0 ){ if( iNextOff!=iPgIdx ){ + u64 iNextDelta = 0; iNextOff += fts5GetVarint(&aPg[iNextOff], &iNextDelta); iOff += sqlite3Fts5PutVarint(&aPg[iOff], iDelta + iNextDelta); } }else if( - iStart==pSeg->iTermLeafOffset && pSeg->iLeafPgno==pSeg->iTermLeafPgno + pSeg->iLeafPgno==pSeg->iTermLeafPgno + && iStart==pSeg->iTermLeafOffset ){ /* The entry being removed was the only position list in its ** doclist. Therefore the term needs to be removed as well. */ int iKey = 0; - for(iIdx=0, iKeyOff=0; iIdx(u32)iStart ) break; iKeyOff += iVal; } + assert_nc( iKey>=1 ); + /* Set iDelKeyOff to the value of the footer entry to remove from + ** the page. */ iDelKeyOff = iOff = iKeyOff; + if( iNextOff!=iPgIdx ){ + /* This is the only position-list associated with the term, and there + ** is another term following it on this page. So the subsequent term + ** needs to be moved to replace the term associated with the entry + ** being removed. */ int nPrefix = 0; int nSuffix = 0; int nPrefix2 = 0; @@ -239874,6 +241556,15 @@ static void fts5DoSecureDelete( } } + /* Assuming no error has occurred, this block does final edits to the + ** leaf page before writing it back to disk. Input variables are: + ** + ** nPg: Total initial size of leaf page. + ** iPgIdx: Initial offset of page footer. + ** + ** iOff: Offset to move data to + ** iNextOff: Offset to move data from + */ if( p->rc==SQLITE_OK ){ const int nMove = nPg - iNextOff; /* Number of bytes to move */ int nShift = iNextOff - iOff; /* Distance to move them */ @@ -240074,10 +241765,16 @@ static void fts5FlushOneHash(Fts5Index *p){ fts5WriteFlushLeaf(p, &writer); } }else{ - int bDummy; - int nPos; - int nCopy = fts5GetPoslistSize(&pDoclist[iOff], &nPos, &bDummy); - nCopy += nPos; + int bDel = 0; + int nPos = 0; + int nCopy = fts5GetPoslistSize(&pDoclist[iOff], &nPos, &bDel); + if( bDel && bSecureDelete ){ + fts5BufferAppendVarint(&p->rc, pBuf, nPos*2); + iOff += nCopy; + nCopy = nPos; + }else{ + nCopy += nPos; + } if( (pBuf->n + pPgidx->n + nCopy) <= pgsz ){ /* The entire poslist will fit on the current leaf. So copy ** it in one go. */ @@ -240115,7 +241812,6 @@ static void fts5FlushOneHash(Fts5Index *p){ assert( pBuf->n<=pBuf->nSpace ); if( p->rc==SQLITE_OK ) sqlite3Fts5HashScanNext(pHash); } - sqlite3Fts5HashClear(pHash); fts5WriteFinish(p, &writer, &pgnoLast); assert( p->rc!=SQLITE_OK || bSecureDelete || pgnoLast>0 ); @@ -240148,7 +241844,6 @@ static void fts5FlushOneHash(Fts5Index *p){ fts5IndexCrisismerge(p, &pStruct); fts5StructureWrite(p, pStruct); fts5StructureRelease(pStruct); - p->nContentlessDelete = 0; } /* @@ -240159,8 +241854,12 @@ static void fts5IndexFlush(Fts5Index *p){ if( p->nPendingData || p->nContentlessDelete ){ assert( p->pHash ); fts5FlushOneHash(p); - p->nPendingData = 0; - p->nPendingRow = 0; + if( p->rc==SQLITE_OK ){ + sqlite3Fts5HashClear(p->pHash); + p->nPendingData = 0; + p->nPendingRow = 0; + p->nContentlessDelete = 0; + } } } @@ -242902,7 +244601,8 @@ static int sqlite3Fts5IndexInit(sqlite3 *db){ 0, /* xSavepoint */ 0, /* xRelease */ 0, /* xRollbackTo */ - 0 /* xShadowName */ + 0, /* xShadowName */ + 0 /* xIntegrity */ }; rc = sqlite3_create_module(db, "fts5_structure", &fts5structure_module, 0); } @@ -243041,6 +244741,8 @@ struct Fts5FullTable { Fts5Storage *pStorage; /* Document store */ Fts5Global *pGlobal; /* Global (connection wide) data */ Fts5Cursor *pSortCsr; /* Sort data from this cursor */ + int iSavepoint; /* Successful xSavepoint()+1 */ + int bInSavepoint; #ifdef SQLITE_DEBUG struct Fts5TransactionState ts; #endif @@ -243329,6 +245031,13 @@ static int fts5InitVtab( pConfig->pzErrmsg = 0; } + if( rc==SQLITE_OK && pConfig->eContent==FTS5_CONTENT_NORMAL ){ + rc = sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, (int)1); + } + if( rc==SQLITE_OK ){ + rc = sqlite3_vtab_config(db, SQLITE_VTAB_INNOCUOUS); + } + if( rc!=SQLITE_OK ){ fts5FreeVtab(pTab); pTab = 0; @@ -244278,9 +245987,8 @@ static int fts5FilterMethod( pCsr->pExpr = pTab->pSortCsr->pExpr; rc = fts5CursorFirst(pTab, pCsr, bDesc); }else if( pCsr->pExpr ){ - if( rc==SQLITE_OK ){ - rc = fts5CursorParseRank(pConfig, pCsr, pRank); - } + assert( rc==SQLITE_OK ); + rc = fts5CursorParseRank(pConfig, pCsr, pRank); if( rc==SQLITE_OK ){ if( bOrderByRank ){ pCsr->ePlan = FTS5_PLAN_SORTED_MATCH; @@ -244451,6 +246159,7 @@ static int fts5SpecialInsert( Fts5Config *pConfig = pTab->p.pConfig; int rc = SQLITE_OK; int bError = 0; + int bLoadConfig = 0; if( 0==sqlite3_stricmp("delete-all", zCmd) ){ if( pConfig->eContent==FTS5_CONTENT_NORMAL ){ @@ -244462,6 +246171,7 @@ static int fts5SpecialInsert( }else{ rc = sqlite3Fts5StorageDeleteAll(pTab->pStorage); } + bLoadConfig = 1; }else if( 0==sqlite3_stricmp("rebuild", zCmd) ){ if( pConfig->eContent==FTS5_CONTENT_NONE ){ fts5SetVtabError(pTab, @@ -244471,6 +246181,7 @@ static int fts5SpecialInsert( }else{ rc = sqlite3Fts5StorageRebuild(pTab->pStorage); } + bLoadConfig = 1; }else if( 0==sqlite3_stricmp("optimize", zCmd) ){ rc = sqlite3Fts5StorageOptimize(pTab->pStorage); }else if( 0==sqlite3_stricmp("merge", zCmd) ){ @@ -244483,6 +246194,8 @@ static int fts5SpecialInsert( }else if( 0==sqlite3_stricmp("prefix-index", zCmd) ){ pConfig->bPrefixIndex = sqlite3_value_int(pVal); #endif + }else if( 0==sqlite3_stricmp("flush", zCmd) ){ + rc = sqlite3Fts5FlushToDisk(&pTab->p); }else{ rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex); if( rc==SQLITE_OK ){ @@ -244496,6 +246209,12 @@ static int fts5SpecialInsert( } } } + + if( rc==SQLITE_OK && bLoadConfig ){ + pTab->p.pConfig->iCookie--; + rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex); + } + return rc; } @@ -244614,7 +246333,7 @@ static int fts5UpdateMethod( assert( nArg!=1 || eType0==SQLITE_INTEGER ); /* Filter out attempts to run UPDATE or DELETE on contentless tables. - ** This is not suported. Except - DELETE is supported if the CREATE + ** This is not suported. Except - they are both supported if the CREATE ** VIRTUAL TABLE statement contained "contentless_delete=1". */ if( eType0==SQLITE_INTEGER && pConfig->eContent==FTS5_CONTENT_NONE @@ -244643,7 +246362,8 @@ static int fts5UpdateMethod( } else if( eType0!=SQLITE_INTEGER ){ - /* If this is a REPLACE, first remove the current entry (if any) */ + /* An INSERT statement. If the conflict-mode is REPLACE, first remove + ** the current entry (if any). */ if( eConflict==SQLITE_REPLACE && eType1==SQLITE_INTEGER ){ i64 iNew = sqlite3_value_int64(apVal[1]); /* Rowid to delete */ rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0); @@ -245517,8 +247237,12 @@ static int fts5RenameMethod( sqlite3_vtab *pVtab, /* Virtual table handle */ const char *zName /* New name of table */ ){ + int rc; Fts5FullTable *pTab = (Fts5FullTable*)pVtab; - return sqlite3Fts5StorageRename(pTab->pStorage, zName); + pTab->bInSavepoint = 1; + rc = sqlite3Fts5StorageRename(pTab->pStorage, zName); + pTab->bInSavepoint = 0; + return rc; } static int sqlite3Fts5FlushToDisk(Fts5Table *pTab){ @@ -245532,9 +247256,29 @@ static int sqlite3Fts5FlushToDisk(Fts5Table *pTab){ ** Flush the contents of the pending-terms table to disk. */ static int fts5SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){ - UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */ - fts5CheckTransactionState((Fts5FullTable*)pVtab, FTS5_SAVEPOINT, iSavepoint); - return sqlite3Fts5FlushToDisk((Fts5Table*)pVtab); + Fts5FullTable *pTab = (Fts5FullTable*)pVtab; + int rc = SQLITE_OK; + char *zSql = 0; + fts5CheckTransactionState(pTab, FTS5_SAVEPOINT, iSavepoint); + + if( pTab->bInSavepoint==0 ){ + zSql = sqlite3_mprintf("INSERT INTO %Q.%Q(%Q) VALUES('flush')", + pTab->p.pConfig->zDb, pTab->p.pConfig->zName, pTab->p.pConfig->zName + ); + if( zSql ){ + pTab->bInSavepoint = 1; + rc = sqlite3_exec(pTab->p.pConfig->db, zSql, 0, 0, 0); + pTab->bInSavepoint = 0; + sqlite3_free(zSql); + }else{ + rc = SQLITE_NOMEM; + } + if( rc==SQLITE_OK ){ + pTab->iSavepoint = iSavepoint+1; + } + } + + return rc; } /* @@ -245543,9 +247287,16 @@ static int fts5SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){ ** This is a no-op. */ static int fts5ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){ - UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */ - fts5CheckTransactionState((Fts5FullTable*)pVtab, FTS5_RELEASE, iSavepoint); - return sqlite3Fts5FlushToDisk((Fts5Table*)pVtab); + Fts5FullTable *pTab = (Fts5FullTable*)pVtab; + int rc = SQLITE_OK; + fts5CheckTransactionState(pTab, FTS5_RELEASE, iSavepoint); + if( (iSavepoint+1)iSavepoint ){ + rc = sqlite3Fts5FlushToDisk(&pTab->p); + if( rc==SQLITE_OK ){ + pTab->iSavepoint = iSavepoint; + } + } + return rc; } /* @@ -245555,11 +247306,14 @@ static int fts5ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){ */ static int fts5RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){ Fts5FullTable *pTab = (Fts5FullTable*)pVtab; - UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */ + int rc = SQLITE_OK; fts5CheckTransactionState(pTab, FTS5_ROLLBACKTO, iSavepoint); fts5TripCursors(pTab); pTab->p.pConfig->pgsz = 0; - return sqlite3Fts5StorageRollback(pTab->pStorage); + if( (iSavepoint+1)<=pTab->iSavepoint ){ + rc = sqlite3Fts5StorageRollback(pTab->pStorage); + } + return rc; } /* @@ -245761,7 +247515,7 @@ static void fts5SourceIdFunc( ){ assert( nArg==0 ); UNUSED_PARAM2(nArg, apUnused); - sqlite3_result_text(pCtx, "fts5: 2023-10-10 12:14:04 4310099cce5a487035fa535dd3002c59ac7f1d1bec68d7cf317fd3e769484790", -1, SQLITE_TRANSIENT); + sqlite3_result_text(pCtx, "fts5: 2023-11-01 11:23:50 17129ba1ff7f0daf37100ee82d507aef7827cf38de1866e2633096ae6ad81301", -1, SQLITE_TRANSIENT); } /* @@ -245779,9 +247533,46 @@ static int fts5ShadowName(const char *zName){ return 0; } +/* +** Run an integrity check on the FTS5 data structures. Return a string +** if anything is found amiss. Return a NULL pointer if everything is +** OK. +*/ +static int fts5Integrity( + sqlite3_vtab *pVtab, /* the FTS5 virtual table to check */ + const char *zSchema, /* Name of schema in which this table lives */ + const char *zTabname, /* Name of the table itself */ + int isQuick, /* True if this is a quick-check */ + char **pzErr /* Write error message here */ +){ + Fts5FullTable *pTab = (Fts5FullTable*)pVtab; + Fts5Config *pConfig = pTab->p.pConfig; + char *zSql; + char *zErr = 0; + int rc; + assert( pzErr!=0 && *pzErr==0 ); + UNUSED_PARAM(isQuick); + zSql = sqlite3_mprintf( + "INSERT INTO \"%w\".\"%w\"(\"%w\") VALUES('integrity-check');", + zSchema, zTabname, pConfig->zName); + if( zSql==0 ) return SQLITE_NOMEM; + rc = sqlite3_exec(pConfig->db, zSql, 0, 0, &zErr); + sqlite3_free(zSql); + if( (rc&0xff)==SQLITE_CORRUPT ){ + *pzErr = sqlite3_mprintf("malformed inverted index for FTS5 table %s.%s", + zSchema, zTabname); + }else if( rc!=SQLITE_OK ){ + *pzErr = sqlite3_mprintf("unable to validate the inverted index for" + " FTS5 table %s.%s: %s", + zSchema, zTabname, zErr); + } + sqlite3_free(zErr); + return SQLITE_OK; +} + static int fts5Init(sqlite3 *db){ static const sqlite3_module fts5Mod = { - /* iVersion */ 3, + /* iVersion */ 4, /* xCreate */ fts5CreateMethod, /* xConnect */ fts5ConnectMethod, /* xBestIndex */ fts5BestIndexMethod, @@ -245804,7 +247595,8 @@ static int fts5Init(sqlite3 *db){ /* xSavepoint */ fts5SavepointMethod, /* xRelease */ fts5ReleaseMethod, /* xRollbackTo */ fts5RollbackToMethod, - /* xShadowName */ fts5ShadowName + /* xShadowName */ fts5ShadowName, + /* xIntegrity */ fts5Integrity }; int rc; @@ -247081,7 +248873,9 @@ static int sqlite3Fts5StorageSync(Fts5Storage *p){ i64 iLastRowid = sqlite3_last_insert_rowid(p->pConfig->db); if( p->bTotalsValid ){ rc = fts5StorageSaveTotals(p); - p->bTotalsValid = 0; + if( rc==SQLITE_OK ){ + p->bTotalsValid = 0; + } } if( rc==SQLITE_OK ){ rc = sqlite3Fts5IndexSync(p->pIndex); @@ -250449,7 +252243,8 @@ static int sqlite3Fts5VocabInit(Fts5Global *pGlobal, sqlite3 *db){ /* xSavepoint */ 0, /* xRelease */ 0, /* xRollbackTo */ 0, - /* xShadowName */ 0 + /* xShadowName */ 0, + /* xIntegrity */ 0 }; void *p = (void*)pGlobal; @@ -250778,6 +252573,7 @@ static sqlite3_module stmtModule = { 0, /* xRelease */ 0, /* xRollbackTo */ 0, /* xShadowName */ + 0 /* xIntegrity */ }; #endif /* SQLITE_OMIT_VIRTUALTABLE */ diff --git a/libsqlite3-sys/sqlite3/sqlite3.h b/libsqlite3-sys/sqlite3/sqlite3.h index 0376113..d4f1c81 100644 --- a/libsqlite3-sys/sqlite3/sqlite3.h +++ b/libsqlite3-sys/sqlite3/sqlite3.h @@ -146,9 +146,9 @@ extern "C" { ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ -#define SQLITE_VERSION "3.43.2" -#define SQLITE_VERSION_NUMBER 3043002 -#define SQLITE_SOURCE_ID "2023-10-10 12:14:04 4310099cce5a487035fa535dd3002c59ac7f1d1bec68d7cf317fd3e769484790" +#define SQLITE_VERSION "3.44.0" +#define SQLITE_VERSION_NUMBER 3044000 +#define SQLITE_SOURCE_ID "2023-11-01 11:23:50 17129ba1ff7f0daf37100ee82d507aef7827cf38de1866e2633096ae6ad81301" /* ** CAPI3REF: Run-Time Library Version Numbers @@ -2127,7 +2127,7 @@ struct sqlite3_mem_methods { ** is stored in each sorted record and the required column values loaded ** from the database as records are returned in sorted order. The default ** value for this option is to never use this optimization. Specifying a -** negative value for this option restores the default behaviour. +** negative value for this option restores the default behavior. ** This option is only available if SQLite is compiled with the ** [SQLITE_ENABLE_SORTER_REFERENCES] compile-time option. ** @@ -2302,7 +2302,7 @@ struct sqlite3_mem_methods { ** database handle, SQLite checks if this will mean that there are now no ** connections at all to the database. If so, it performs a checkpoint ** operation before closing the connection. This option may be used to -** override this behaviour. The first parameter passed to this operation +** override this behavior. The first parameter passed to this operation ** is an integer - positive to disable checkpoints-on-close, or zero (the ** default) to enable them, and negative to leave the setting unchanged. ** The second parameter is a pointer to an integer @@ -3955,6 +3955,7 @@ SQLITE_API void sqlite3_free_filename(sqlite3_filename); ** ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language ** text that describes the error, as either UTF-8 or UTF-16 respectively. +** (See how SQLite handles [invalid UTF] for exceptions to this rule.) ** ^(Memory to hold the error message string is managed internally. ** The application does not need to worry about freeing the result. ** However, the error string might be overwritten or deallocated by @@ -5325,6 +5326,7 @@ SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt); */ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); + /* ** CAPI3REF: Create Or Redefine SQL Functions ** KEYWORDS: {function creation routines} @@ -5879,32 +5881,32 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*); ** METHOD: sqlite3_context ** ** These functions may be used by (non-aggregate) SQL functions to -** associate metadata with argument values. If the same value is passed to -** multiple invocations of the same SQL function during query execution, under -** some circumstances the associated metadata may be preserved. An example -** of where this might be useful is in a regular-expression matching -** function. The compiled version of the regular expression can be stored as -** metadata associated with the pattern string. +** associate auxiliary data with argument values. If the same argument +** value is passed to multiple invocations of the same SQL function during +** query execution, under some circumstances the associated auxiliary data +** might be preserved. An example of where this might be useful is in a +** regular-expression matching function. The compiled version of the regular +** expression can be stored as auxiliary data associated with the pattern string. ** Then as long as the pattern string remains the same, ** the compiled regular expression can be reused on multiple ** invocations of the same function. ** -** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the metadata +** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the auxiliary data ** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument ** value to the application-defined function. ^N is zero for the left-most -** function argument. ^If there is no metadata +** function argument. ^If there is no auxiliary data ** associated with the function argument, the sqlite3_get_auxdata(C,N) interface ** returns a NULL pointer. ** -** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th -** argument of the application-defined function. ^Subsequent +** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as auxiliary data for the +** N-th argument of the application-defined function. ^Subsequent ** calls to sqlite3_get_auxdata(C,N) return P from the most recent -** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or -** NULL if the metadata has been discarded. +** sqlite3_set_auxdata(C,N,P,X) call if the auxiliary data is still valid or +** NULL if the auxiliary data has been discarded. ** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL, ** SQLite will invoke the destructor function X with parameter P exactly -** once, when the metadata is discarded. -** SQLite is free to discard the metadata at any time, including:
          +** once, when the auxiliary data is discarded. +** SQLite is free to discard the auxiliary data at any time, including:
            **
          • ^(when the corresponding function parameter changes)^, or **
          • ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the ** SQL statement)^, or @@ -5920,7 +5922,7 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*); ** function implementation should not make any use of P after ** sqlite3_set_auxdata() has been called. ** -** ^(In practice, metadata is preserved between function calls for +** ^(In practice, auxiliary data is preserved between function calls for ** function parameters that are compile-time constants, including literal ** values and [parameters] and expressions composed from the same.)^ ** @@ -5930,10 +5932,67 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*); ** ** These routines must be called from the same thread in which ** the SQL function is running. +** +** See also: [sqlite3_get_clientdata()] and [sqlite3_set_clientdata()]. */ SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N); SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*)); +/* +** CAPI3REF: Database Connection Client Data +** METHOD: sqlite3 +** +** These functions are used to associate one or more named pointers +** with a [database connection]. +** A call to sqlite3_set_clientdata(D,N,P,X) causes the pointer P +** to be attached to [database connection] D using name N. Subsequent +** calls to sqlite3_get_clientdata(D,N) will return a copy of pointer P +** or a NULL pointer if there were no prior calls to +** sqlite3_set_clientdata() with the same values of D and N. +** Names are compared using strcmp() and are thus case sensitive. +** +** If P and X are both non-NULL, then the destructor X is invoked with +** argument P on the first of the following occurrences: +**
              +**
            • An out-of-memory error occurs during the call to +** sqlite3_set_clientdata() which attempts to register pointer P. +**
            • A subsequent call to sqlite3_set_clientdata(D,N,P,X) is made +** with the same D and N parameters. +**
            • The database connection closes. SQLite does not make any guarantees +** about the order in which destructors are called, only that all +** destructors will be called exactly once at some point during the +** database connection closing process. +**
            +** +** SQLite does not do anything with client data other than invoke +** destructors on the client data at the appropriate time. The intended +** use for client data is to provide a mechanism for wrapper libraries +** to store additional information about an SQLite database connection. +** +** There is no limit (other than available memory) on the number of different +** client data pointers (with different names) that can be attached to a +** single database connection. However, the implementation is optimized +** for the case of having only one or two different client data names. +** Applications and wrapper libraries are discouraged from using more than +** one client data name each. +** +** There is no way to enumerate the client data pointers +** associated with a database connection. The N parameter can be thought +** of as a secret key such that only code that knows the secret key is able +** to access the associated data. +** +** Security Warning: These interfaces should not be exposed in scripting +** languages or in other circumstances where it might be possible for an +** an attacker to invoke them. Any agent that can invoke these interfaces +** can probably also take control of the process. +** +** Database connection client data is only available for SQLite +** version 3.44.0 ([dateof:3.44.0]) and later. +** +** See also: [sqlite3_set_auxdata()] and [sqlite3_get_auxdata()]. +*/ +SQLITE_API void *sqlite3_get_clientdata(sqlite3*,const char*); +SQLITE_API int sqlite3_set_clientdata(sqlite3*, const char*, void*, void(*)(void*)); /* ** CAPI3REF: Constants Defining Special Destructor Behavior @@ -6566,7 +6625,7 @@ SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName); SQLITE_API int sqlite3_txn_state(sqlite3*,const char *zSchema); /* -** CAPI3REF: Allowed return values from [sqlite3_txn_state()] +** CAPI3REF: Allowed return values from sqlite3_txn_state() ** KEYWORDS: {transaction state} ** ** These constants define the current transaction state of a database file. @@ -6698,7 +6757,7 @@ SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*); ** ^Each call to the sqlite3_autovacuum_pages() interface overrides all ** previous invocations for that database connection. ^If the callback ** argument (C) to sqlite3_autovacuum_pages(D,C,P,X) is a NULL pointer, -** then the autovacuum steps callback is cancelled. The return value +** then the autovacuum steps callback is canceled. The return value ** from sqlite3_autovacuum_pages() is normally SQLITE_OK, but might ** be some other error code if something goes wrong. The current ** implementation will only return SQLITE_OK or SQLITE_MISUSE, but other @@ -7217,6 +7276,10 @@ struct sqlite3_module { /* The methods above are in versions 1 and 2 of the sqlite_module object. ** Those below are for version 3 and greater. */ int (*xShadowName)(const char*); + /* The methods above are in versions 1 through 3 of the sqlite_module object. + ** Those below are for version 4 and greater. */ + int (*xIntegrity)(sqlite3_vtab *pVTab, const char *zSchema, + const char *zTabName, int mFlags, char **pzErr); }; /* @@ -7704,7 +7767,7 @@ SQLITE_API int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64); ** code is returned and the transaction rolled back. ** ** Calling this function with an argument that is not a NULL pointer or an -** open blob handle results in undefined behaviour. ^Calling this routine +** open blob handle results in undefined behavior. ^Calling this routine ** with a null pointer (such as would be returned by a failed call to ** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function ** is passed a valid open blob handle, the values returned by the @@ -8184,6 +8247,7 @@ SQLITE_API int sqlite3_test_control(int op, ...); #define SQLITE_TESTCTRL_PRNG_SAVE 5 #define SQLITE_TESTCTRL_PRNG_RESTORE 6 #define SQLITE_TESTCTRL_PRNG_RESET 7 /* NOT USED */ +#define SQLITE_TESTCTRL_FK_NO_ACTION 7 #define SQLITE_TESTCTRL_BITVEC_TEST 8 #define SQLITE_TESTCTRL_FAULT_INSTALL 9 #define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 @@ -9245,8 +9309,8 @@ SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p); ** blocked connection already has a registered unlock-notify callback, ** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is ** called with a NULL pointer as its second argument, then any existing -** unlock-notify callback is cancelled. ^The blocked connections -** unlock-notify callback may also be cancelled by closing the blocked +** unlock-notify callback is canceled. ^The blocked connections +** unlock-notify callback may also be canceled by closing the blocked ** connection using [sqlite3_close()]. ** ** The unlock-notify callback is not reentrant. If an application invokes @@ -10549,6 +10613,13 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const c ** SQLITE_SERIALIZE_NOCOPY bit is set but no contiguous copy ** of the database exists. ** +** After the call, if the SQLITE_SERIALIZE_NOCOPY bit had been set, +** the returned buffer content will remain accessible and unchanged +** until either the next write operation on the connection or when +** the connection is closed, and applications must not modify the +** buffer. If the bit had been clear, the returned buffer will not +** be accessed by SQLite after the call. +** ** A call to sqlite3_serialize(D,S,P,F) might return NULL even if the ** SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory ** allocation error occurs. @@ -10597,6 +10668,9 @@ SQLITE_API unsigned char *sqlite3_serialize( ** SQLite will try to increase the buffer size using sqlite3_realloc64() ** if writes on the database cause it to grow larger than M bytes. ** +** Applications must not modify the buffer P or invalidate it before +** the database connection D is closed. +** ** The sqlite3_deserialize() interface will fail with SQLITE_BUSY if the ** database is currently in a read transaction or is involved in a backup ** operation. @@ -10605,6 +10679,13 @@ SQLITE_API unsigned char *sqlite3_serialize( ** S argument to sqlite3_deserialize(D,S,P,N,M,F) is "temp" then the ** function returns SQLITE_ERROR. ** +** The deserialized database should not be in [WAL mode]. If the database +** is in WAL mode, then any attempt to use the database file will result +** in an [SQLITE_CANTOPEN] error. The application can set the +** [file format version numbers] (bytes 18 and 19) of the input database P +** to 0x01 prior to invoking sqlite3_deserialize(D,S,P,N,M,F) to force the +** database file into rollback mode and work around this limitation. +** ** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the ** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then ** [sqlite3_free()] is invoked on argument P prior to returning. @@ -11677,6 +11758,18 @@ SQLITE_API int sqlite3changeset_concat( ); +/* +** CAPI3REF: Upgrade the Schema of a Changeset/Patchset +*/ +SQLITE_API int sqlite3changeset_upgrade( + sqlite3 *db, + const char *zDb, + int nIn, const void *pIn, /* Input changeset */ + int *pnOut, void **ppOut /* OUT: Inverse of input */ +); + + + /* ** CAPI3REF: Changegroup Handle ** @@ -11723,6 +11816,38 @@ typedef struct sqlite3_changegroup sqlite3_changegroup; */ SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp); +/* +** CAPI3REF: Add a Schema to a Changegroup +** METHOD: sqlite3_changegroup_schema +** +** This method may be used to optionally enforce the rule that the changesets +** added to the changegroup handle must match the schema of database zDb +** ("main", "temp", or the name of an attached database). If +** sqlite3changegroup_add() is called to add a changeset that is not compatible +** with the configured schema, SQLITE_SCHEMA is returned and the changegroup +** object is left in an undefined state. +** +** A changeset schema is considered compatible with the database schema in +** the same way as for sqlite3changeset_apply(). Specifically, for each +** table in the changeset, there exists a database table with: +** +**
              +**
            • The name identified by the changeset, and +**
            • at least as many columns as recorded in the changeset, and +**
            • the primary key columns in the same position as recorded in +** the changeset. +**
            +** +** The output of the changegroup object always has the same schema as the +** database nominated using this function. In cases where changesets passed +** to sqlite3changegroup_add() have fewer columns than the corresponding table +** in the database schema, these are filled in using the default column +** values from the database schema. This makes it possible to combined +** changesets that have different numbers of columns for a single table +** within a changegroup, provided that they are otherwise compatible. +*/ +SQLITE_API int sqlite3changegroup_schema(sqlite3_changegroup*, sqlite3*, const char *zDb); + /* ** CAPI3REF: Add A Changeset To A Changegroup ** METHOD: sqlite3_changegroup @@ -11791,13 +11916,18 @@ SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp); ** If the new changeset contains changes to a table that is already present ** in the changegroup, then the number of columns and the position of the ** primary key columns for the table must be consistent. If this is not the -** case, this function fails with SQLITE_SCHEMA. If the input changeset -** appears to be corrupt and the corruption is detected, SQLITE_CORRUPT is -** returned. Or, if an out-of-memory condition occurs during processing, this -** function returns SQLITE_NOMEM. In all cases, if an error occurs the state -** of the final contents of the changegroup is undefined. +** case, this function fails with SQLITE_SCHEMA. Except, if the changegroup +** object has been configured with a database schema using the +** sqlite3changegroup_schema() API, then it is possible to combine changesets +** with different numbers of columns for a single table, provided that +** they are otherwise compatible. ** -** If no error occurs, SQLITE_OK is returned. +** If the input changeset appears to be corrupt and the corruption is +** detected, SQLITE_CORRUPT is returned. Or, if an out-of-memory condition +** occurs during processing, this function returns SQLITE_NOMEM. +** +** In all cases, if an error occurs the state of the final contents of the +** changegroup is undefined. If no error occurs, SQLITE_OK is returned. */ SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData); @@ -12062,10 +12192,17 @@ SQLITE_API int sqlite3changeset_apply_v2( **
          • an insert change if all fields of the conflicting row match ** the row being inserted. **
          +** +**
          SQLITE_CHANGESETAPPLY_FKNOACTION
          +** If this flag it set, then all foreign key constraints in the target +** database behave as if they were declared with "ON UPDATE NO ACTION ON +** DELETE NO ACTION", even if they are actually CASCADE, RESTRICT, SET NULL +** or SET DEFAULT. */ #define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001 #define SQLITE_CHANGESETAPPLY_INVERT 0x0002 #define SQLITE_CHANGESETAPPLY_IGNORENOOP 0x0004 +#define SQLITE_CHANGESETAPPLY_FKNOACTION 0x0008 /* ** CAPI3REF: Constants Passed To The Conflict Handler diff --git a/libsqlite3-sys/sqlite3/sqlite3ext.h b/libsqlite3-sys/sqlite3/sqlite3ext.h index 7116380..ae0949b 100644 --- a/libsqlite3-sys/sqlite3/sqlite3ext.h +++ b/libsqlite3-sys/sqlite3/sqlite3ext.h @@ -363,6 +363,9 @@ struct sqlite3_api_routines { int (*is_interrupted)(sqlite3*); /* Version 3.43.0 and later */ int (*stmt_explain)(sqlite3_stmt*,int); + /* Version 3.44.0 and later */ + void *(*get_clientdata)(sqlite3*,const char*); + int (*set_clientdata)(sqlite3*, const char*, void*, void(*)(void*)); }; /* @@ -693,6 +696,9 @@ typedef int (*sqlite3_loadext_entry)( #define sqlite3_is_interrupted sqlite3_api->is_interrupted /* Version 3.43.0 and later */ #define sqlite3_stmt_explain sqlite3_api->stmt_explain +/* Version 3.44.0 and later */ +#define sqlite3_get_clientdata sqlite3_api->get_clientdata +#define sqlite3_set_clientdata sqlite3_api->set_clientdata #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) diff --git a/libsqlite3-sys/upgrade.sh b/libsqlite3-sys/upgrade.sh index 882fb73..a0b160c 100755 --- a/libsqlite3-sys/upgrade.sh +++ b/libsqlite3-sys/upgrade.sh @@ -9,7 +9,7 @@ export SQLITE3_LIB_DIR="$SCRIPT_DIR/sqlite3" export SQLITE3_INCLUDE_DIR="$SQLITE3_LIB_DIR" # Download and extract amalgamation -SQLITE=sqlite-amalgamation-3430200 +SQLITE=sqlite-amalgamation-3440000 curl -O https://sqlite.org/2023/$SQLITE.zip unzip -p "$SQLITE.zip" "$SQLITE/sqlite3.c" > "$SQLITE3_LIB_DIR/sqlite3.c" unzip -p "$SQLITE.zip" "$SQLITE/sqlite3.h" > "$SQLITE3_LIB_DIR/sqlite3.h" From 2326556d9b4c14b5d8cb738bf4a29dd5eb97e4b6 Mon Sep 17 00:00:00 2001 From: gwenn Date: Fri, 3 Nov 2023 19:39:25 +0100 Subject: [PATCH 38/63] Bump bindgen version to 0.69 --- libsqlite3-sys/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsqlite3-sys/Cargo.toml b/libsqlite3-sys/Cargo.toml index 3a84ce0..bb0d325 100644 --- a/libsqlite3-sys/Cargo.toml +++ b/libsqlite3-sys/Cargo.toml @@ -44,7 +44,7 @@ winsqlite3 = [] openssl-sys = { version = "0.9", optional = true } [build-dependencies] -bindgen = { version = "0.68", optional = true, default-features = false, features = ["runtime"] } +bindgen = { version = "0.69", optional = true, default-features = false, features = ["runtime"] } pkg-config = { version = "0.3.19", optional = true } cc = { version = "1.0", optional = true } vcpkg = { version = "0.2", optional = true } From 11d0443af19cd3ce14f7bc3ab26982460442e9f2 Mon Sep 17 00:00:00 2001 From: gwenn Date: Fri, 10 Nov 2023 17:52:17 +0000 Subject: [PATCH 39/63] Regenerate bindgen_bundled_version_ext.rs for version 3.44.0 --- .../sqlite3/bindgen_bundled_version.rs | 2 +- .../sqlite3/bindgen_bundled_version_ext.rs | 76 ++++++++++++++++++- libsqlite3-sys/upgrade.sh | 2 +- 3 files changed, 74 insertions(+), 6 deletions(-) diff --git a/libsqlite3-sys/sqlite3/bindgen_bundled_version.rs b/libsqlite3-sys/sqlite3/bindgen_bundled_version.rs index 76eea10..ef59419 100644 --- a/libsqlite3-sys/sqlite3/bindgen_bundled_version.rs +++ b/libsqlite3-sys/sqlite3/bindgen_bundled_version.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.68.1 */ +/* automatically generated by rust-bindgen 0.69.1 */ extern "C" { pub fn sqlite3_auto_extension( diff --git a/libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs b/libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs index ed7fc5c..f64ecd2 100644 --- a/libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs +++ b/libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs @@ -1,9 +1,9 @@ -/* automatically generated by rust-bindgen 0.68.1 */ +/* automatically generated by rust-bindgen 0.69.1 */ -pub const SQLITE_VERSION: &[u8; 7] = b"3.43.2\0"; -pub const SQLITE_VERSION_NUMBER: i32 = 3043002; +pub const SQLITE_VERSION: &[u8; 7] = b"3.44.0\0"; +pub const SQLITE_VERSION_NUMBER: i32 = 3044000; pub const SQLITE_SOURCE_ID: &[u8; 85] = - b"2023-10-10 12:14:04 4310099cce5a487035fa535dd3002c59ac7f1d1bec68d7cf317fd3e769484790\0"; + b"2023-11-01 11:23:50 17129ba1ff7f0daf37100ee82d507aef7827cf38de1866e2633096ae6ad81301\0"; pub const SQLITE_OK: i32 = 0; pub const SQLITE_ERROR: i32 = 1; pub const SQLITE_INTERNAL: i32 = 2; @@ -374,6 +374,7 @@ pub const SQLITE_TESTCTRL_FIRST: i32 = 5; pub const SQLITE_TESTCTRL_PRNG_SAVE: i32 = 5; pub const SQLITE_TESTCTRL_PRNG_RESTORE: i32 = 6; pub const SQLITE_TESTCTRL_PRNG_RESET: i32 = 7; +pub const SQLITE_TESTCTRL_FK_NO_ACTION: i32 = 7; pub const SQLITE_TESTCTRL_BITVEC_TEST: i32 = 8; pub const SQLITE_TESTCTRL_FAULT_INSTALL: i32 = 9; pub const SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS: i32 = 10; @@ -912,6 +913,15 @@ pub struct sqlite3_module { pub xShadowName: ::std::option::Option< unsafe extern "C" fn(arg1: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int, >, + pub xIntegrity: ::std::option::Option< + unsafe extern "C" fn( + pVTab: *mut sqlite3_vtab, + zSchema: *const ::std::os::raw::c_char, + zTabName: *const ::std::os::raw::c_char, + mFlags: ::std::os::raw::c_int, + pzErr: *mut *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, } #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -2872,6 +2882,20 @@ pub struct sqlite3_api_routines { arg2: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int, >, + pub get_clientdata: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + ) -> *mut ::std::os::raw::c_void, + >, + pub set_clientdata: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *mut ::std::os::raw::c_void, + arg4: ::std::option::Option, + ) -> ::std::os::raw::c_int, + >, } pub type sqlite3_loadext_entry = ::std::option::Option< unsafe extern "C" fn( @@ -7425,6 +7449,48 @@ pub unsafe fn sqlite3_stmt_explain( (fun)(arg1, arg2) } +static __SQLITE3_GET_CLIENTDATA: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + ) -> *mut ::std::os::raw::c_void, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_get_clientdata( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, +) -> *mut ::std::os::raw::c_void { + let fun = __SQLITE3_GET_CLIENTDATA + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2) +} + +static __SQLITE3_SET_CLIENTDATA: ::atomic::Atomic< + Option< + unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *mut ::std::os::raw::c_void, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int, + >, +> = ::atomic::Atomic::new(None); +pub unsafe fn sqlite3_set_clientdata( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *mut ::std::os::raw::c_void, + arg4: ::std::option::Option, +) -> ::std::os::raw::c_int { + let fun = __SQLITE3_SET_CLIENTDATA + .load(::atomic::Ordering::Acquire) + .expect("SQLite API not initialized or SQLite feature omitted"); + (fun)(arg1, arg2, arg3, arg4) +} + /// Like SQLITE_EXTENSION_INIT2 macro pub unsafe fn rusqlite_extension_init2( p_api: *mut sqlite3_api_routines, @@ -7757,6 +7823,8 @@ pub unsafe fn rusqlite_extension_init2( __SQLITE3_VALUE_ENCODING.store((*p_api).value_encoding, ::atomic::Ordering::Release); __SQLITE3_IS_INTERRUPTED.store((*p_api).is_interrupted, ::atomic::Ordering::Release); __SQLITE3_STMT_EXPLAIN.store((*p_api).stmt_explain, ::atomic::Ordering::Release); + __SQLITE3_GET_CLIENTDATA.store((*p_api).get_clientdata, ::atomic::Ordering::Release); + __SQLITE3_SET_CLIENTDATA.store((*p_api).set_clientdata, ::atomic::Ordering::Release); Ok(()) } diff --git a/libsqlite3-sys/upgrade.sh b/libsqlite3-sys/upgrade.sh index 3965216..5a9da28 100755 --- a/libsqlite3-sys/upgrade.sh +++ b/libsqlite3-sys/upgrade.sh @@ -28,7 +28,7 @@ find "$TARGET_DIR" -type f -name bindgen.rs -exec mv {} "$SQLITE3_LIB_DIR/bindge # Regenerate bindgen file for sqlite3ext.h # some sqlite3_api_routines fields are function pointers with va_list arg but currently stable Rust doesn't support this type. # FIXME how to generate portable bindings without : -sed -i '' 's/va_list/void*/' "$SQLITE3_LIB_DIR/sqlite3ext.h" +sed -i'' -e 's/va_list/void*/' "$SQLITE3_LIB_DIR/sqlite3ext.h" rm -f "$SQLITE3_LIB_DIR/bindgen_bundled_version_ext.rs" find "$TARGET_DIR" -type f -name bindgen.rs -exec rm {} \; env LIBSQLITE3_SYS_BUNDLING=1 cargo build --features "buildtime_bindgen loadable_extension" --no-default-features From 1d74ddcc7bc1420e9b413130a341e7a2d9a288a8 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 11 Nov 2023 15:46:14 +0100 Subject: [PATCH 40/63] Bump atomic dependency version --- libsqlite3-sys/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsqlite3-sys/Cargo.toml b/libsqlite3-sys/Cargo.toml index e23e961..edaa2f0 100644 --- a/libsqlite3-sys/Cargo.toml +++ b/libsqlite3-sys/Cargo.toml @@ -43,7 +43,7 @@ winsqlite3 = [] [dependencies] openssl-sys = { version = "0.9", optional = true } -atomic = { version = "0.5", optional = true } +atomic = { version = "0.6", optional = true } [build-dependencies] bindgen = { version = "0.69", optional = true, default-features = false, features = ["runtime"] } From e8c35fce50d1634aa1a848ad960cca7561155931 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 11 Nov 2023 20:11:37 +0100 Subject: [PATCH 41/63] Replace ::atomic::Atomic by std AtomicPtr NoUninit constraint cannot be satisfied --- libsqlite3-sys/Cargo.toml | 3 +- .../bindgen-bindings/bindgen_3.14.0_ext.rs | 5369 +++++++------ libsqlite3-sys/build.rs | 28 +- .../sqlite3/bindgen_bundled_version_ext.rs | 6658 +++++++++-------- libsqlite3-sys/upgrade.sh | 3 +- 5 files changed, 6583 insertions(+), 5478 deletions(-) diff --git a/libsqlite3-sys/Cargo.toml b/libsqlite3-sys/Cargo.toml index edaa2f0..15ec486 100644 --- a/libsqlite3-sys/Cargo.toml +++ b/libsqlite3-sys/Cargo.toml @@ -23,7 +23,7 @@ min_sqlite_version_3_14_0 = ["pkg-config", "vcpkg"] # Bundle only the bindings file. Note that this does nothing if # `buildtime_bindgen` is enabled. bundled_bindings = [] -loadable_extension = ["atomic", "prettyplease", "quote", "syn"] +loadable_extension = ["prettyplease", "quote", "syn"] # sqlite3_unlock_notify >= 3.6.12 unlock_notify = [] # 3.13.0 @@ -43,7 +43,6 @@ winsqlite3 = [] [dependencies] openssl-sys = { version = "0.9", optional = true } -atomic = { version = "0.6", optional = true } [build-dependencies] bindgen = { version = "0.69", optional = true, default-features = false, features = ["runtime"] } diff --git a/libsqlite3-sys/bindgen-bindings/bindgen_3.14.0_ext.rs b/libsqlite3-sys/bindgen-bindings/bindgen_3.14.0_ext.rs index 5cc4702..0f46645 100644 --- a/libsqlite3-sys/bindgen-bindings/bindgen_3.14.0_ext.rs +++ b/libsqlite3-sys/bindgen-bindings/bindgen_3.14.0_ext.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.66.1 */ +/* automatically generated by rust-bindgen 0.69.1 */ pub const SQLITE_VERSION: &[u8; 7] = b"3.14.0\0"; pub const SQLITE_VERSION_NUMBER: i32 = 3014000; @@ -2491,37 +2491,25 @@ pub type sqlite3_loadext_entry = ::std::option::Option< pThunk: *const sqlite3_api_routines, ) -> ::std::os::raw::c_int, >; -static __SQLITE3_AGGREGATE_CONTEXT: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - nBytes: ::std::os::raw::c_int, - ) -> *mut ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_AGGREGATE_CONTEXT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_aggregate_context( arg1: *mut sqlite3_context, nBytes: ::std::os::raw::c_int, ) -> *mut ::std::os::raw::c_void { - let fun = __SQLITE3_AGGREGATE_CONTEXT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_AGGREGATE_CONTEXT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + nBytes: ::std::os::raw::c_int, + ) -> *mut ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, nBytes) } -static __SQLITE3_BIND_BLOB: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - arg3: *const ::std::os::raw::c_void, - n: ::std::os::raw::c_int, - arg4: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BIND_BLOB: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_bind_blob( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, @@ -2529,151 +2517,141 @@ pub unsafe fn sqlite3_bind_blob( n: ::std::os::raw::c_int, arg4: ::std::option::Option, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BIND_BLOB - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BIND_BLOB.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + n: ::std::os::raw::c_int, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, n, arg4) } -static __SQLITE3_BIND_DOUBLE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - arg3: f64, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BIND_DOUBLE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_bind_double( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, arg3: f64, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BIND_DOUBLE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BIND_DOUBLE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: f64, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_BIND_INT: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - arg3: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BIND_INT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_bind_int( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, arg3: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BIND_INT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BIND_INT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_BIND_INT64: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - arg3: sqlite_int64, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BIND_INT64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_bind_int64( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, arg3: sqlite_int64, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BIND_INT64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BIND_INT64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: sqlite_int64, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_BIND_NULL: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BIND_NULL: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_bind_null( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BIND_NULL - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BIND_NULL.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_BIND_PARAMETER_COUNT: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BIND_PARAMETER_COUNT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_bind_parameter_count( arg1: *mut sqlite3_stmt, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BIND_PARAMETER_COUNT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BIND_PARAMETER_COUNT + .load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_BIND_PARAMETER_INDEX: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - zName: *const ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BIND_PARAMETER_INDEX: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_bind_parameter_index( arg1: *mut sqlite3_stmt, zName: *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BIND_PARAMETER_INDEX - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BIND_PARAMETER_INDEX + .load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + zName: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, zName) } -static __SQLITE3_BIND_PARAMETER_NAME: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_char, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BIND_PARAMETER_NAME: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_bind_parameter_name( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_BIND_PARAMETER_NAME - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BIND_PARAMETER_NAME.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_BIND_TEXT: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - arg3: *const ::std::os::raw::c_char, - n: ::std::os::raw::c_int, - arg4: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BIND_TEXT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_bind_text( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, @@ -2681,25 +2659,23 @@ pub unsafe fn sqlite3_bind_text( n: ::std::os::raw::c_int, arg4: ::std::option::Option, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BIND_TEXT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BIND_TEXT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + n: ::std::os::raw::c_int, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, n, arg4) } -static __SQLITE3_BIND_TEXT16: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - arg3: *const ::std::os::raw::c_void, - arg4: ::std::os::raw::c_int, - arg5: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BIND_TEXT16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_bind_text16( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, @@ -2707,46 +2683,41 @@ pub unsafe fn sqlite3_bind_text16( arg4: ::std::os::raw::c_int, arg5: ::std::option::Option, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BIND_TEXT16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BIND_TEXT16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: ::std::os::raw::c_int, + arg5: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5) } -static __SQLITE3_BIND_VALUE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - arg3: *const sqlite3_value, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BIND_VALUE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_bind_value( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, arg3: *const sqlite3_value, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BIND_VALUE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BIND_VALUE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const sqlite3_value, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_BUSY_HANDLER: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - arg2: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, - arg3: *mut ::std::os::raw::c_void, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BUSY_HANDLER: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_busy_handler( arg1: *mut sqlite3, arg2: ::std::option::Option< @@ -2757,66 +2728,64 @@ pub unsafe fn sqlite3_busy_handler( >, arg3: *mut ::std::os::raw::c_void, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BUSY_HANDLER - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BUSY_HANDLER.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_BUSY_TIMEOUT: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - ms: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BUSY_TIMEOUT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_busy_timeout( arg1: *mut sqlite3, ms: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BUSY_TIMEOUT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BUSY_TIMEOUT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + ms: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, ms) } -static __SQLITE3_CHANGES: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_CHANGES: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_changes(arg1: *mut sqlite3) -> ::std::os::raw::c_int { - let fun = __SQLITE3_CHANGES - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_CHANGES.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_CLOSE: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_CLOSE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_close(arg1: *mut sqlite3) -> ::std::os::raw::c_int { - let fun = __SQLITE3_CLOSE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_CLOSE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_COLLATION_NEEDED: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *mut ::std::os::raw::c_void, - arg3: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - arg2: *mut sqlite3, - eTextRep: ::std::os::raw::c_int, - arg3: *const ::std::os::raw::c_char, - ), - >, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLLATION_NEEDED: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_collation_needed( arg1: *mut sqlite3, arg2: *mut ::std::os::raw::c_void, @@ -2829,28 +2798,26 @@ pub unsafe fn sqlite3_collation_needed( ), >, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_COLLATION_NEEDED - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLLATION_NEEDED.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *mut ::std::os::raw::c_void, + arg3: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut sqlite3, + eTextRep: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + ), + >, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_COLLATION_NEEDED16: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *mut ::std::os::raw::c_void, - arg3: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - arg2: *mut sqlite3, - eTextRep: ::std::os::raw::c_int, - arg3: *const ::std::os::raw::c_void, - ), - >, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLLATION_NEEDED16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_collation_needed16( arg1: *mut sqlite3, arg2: *mut ::std::os::raw::c_void, @@ -2863,392 +2830,361 @@ pub unsafe fn sqlite3_collation_needed16( ), >, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_COLLATION_NEEDED16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLLATION_NEEDED16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *mut ::std::os::raw::c_void, + arg3: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut sqlite3, + eTextRep: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + ), + >, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_COLUMN_BLOB: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - iCol: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_BLOB: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_blob( arg1: *mut sqlite3_stmt, iCol: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_void { - let fun = __SQLITE3_COLUMN_BLOB - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_BLOB.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, iCol) } -static __SQLITE3_COLUMN_BYTES: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - iCol: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_BYTES: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_bytes( arg1: *mut sqlite3_stmt, iCol: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_COLUMN_BYTES - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_BYTES.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, iCol) } -static __SQLITE3_COLUMN_BYTES16: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - iCol: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_BYTES16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_bytes16( arg1: *mut sqlite3_stmt, iCol: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_COLUMN_BYTES16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_BYTES16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, iCol) } -static __SQLITE3_COLUMN_COUNT: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_COUNT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_count(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int { - let fun = __SQLITE3_COLUMN_COUNT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_COUNT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(pStmt) } -static __SQLITE3_COLUMN_DATABASE_NAME: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_char, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_DATABASE_NAME: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_database_name( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_COLUMN_DATABASE_NAME - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_DATABASE_NAME + .load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_COLUMN_DATABASE_NAME16: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_DATABASE_NAME16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_database_name16( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_void { - let fun = __SQLITE3_COLUMN_DATABASE_NAME16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_DATABASE_NAME16 + .load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_COLUMN_DECLTYPE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - i: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_char, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_DECLTYPE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_decltype( arg1: *mut sqlite3_stmt, i: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_COLUMN_DECLTYPE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_DECLTYPE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + i: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1, i) } -static __SQLITE3_COLUMN_DECLTYPE16: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_DECLTYPE16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_decltype16( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_void { - let fun = __SQLITE3_COLUMN_DECLTYPE16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_DECLTYPE16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_COLUMN_DOUBLE: ::atomic::Atomic< - Option< - unsafe extern "C" fn(arg1: *mut sqlite3_stmt, iCol: ::std::os::raw::c_int) -> f64, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_DOUBLE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_double( arg1: *mut sqlite3_stmt, iCol: ::std::os::raw::c_int, ) -> f64 { - let fun = __SQLITE3_COLUMN_DOUBLE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_DOUBLE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> f64 = ::std::mem::transmute(ptr); (fun)(arg1, iCol) } -static __SQLITE3_COLUMN_INT: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - iCol: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_INT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_int( arg1: *mut sqlite3_stmt, iCol: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_COLUMN_INT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_INT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, iCol) } -static __SQLITE3_COLUMN_INT64: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - iCol: ::std::os::raw::c_int, - ) -> sqlite_int64, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_INT64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_int64( arg1: *mut sqlite3_stmt, iCol: ::std::os::raw::c_int, ) -> sqlite_int64 { - let fun = __SQLITE3_COLUMN_INT64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_INT64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> sqlite_int64 = ::std::mem::transmute(ptr); (fun)(arg1, iCol) } -static __SQLITE3_COLUMN_NAME: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_char, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_NAME: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_name( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_COLUMN_NAME - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_NAME.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_COLUMN_NAME16: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_NAME16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_name16( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_void { - let fun = __SQLITE3_COLUMN_NAME16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_NAME16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_COLUMN_ORIGIN_NAME: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_char, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_ORIGIN_NAME: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_origin_name( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_COLUMN_ORIGIN_NAME - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_ORIGIN_NAME.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_COLUMN_ORIGIN_NAME16: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_ORIGIN_NAME16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_origin_name16( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_void { - let fun = __SQLITE3_COLUMN_ORIGIN_NAME16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_ORIGIN_NAME16 + .load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_COLUMN_TABLE_NAME: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_char, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_TABLE_NAME: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_table_name( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_COLUMN_TABLE_NAME - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_TABLE_NAME.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_COLUMN_TABLE_NAME16: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_TABLE_NAME16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_table_name16( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_void { - let fun = __SQLITE3_COLUMN_TABLE_NAME16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_TABLE_NAME16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_COLUMN_TEXT: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - iCol: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_uchar, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_TEXT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_text( arg1: *mut sqlite3_stmt, iCol: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_uchar { - let fun = __SQLITE3_COLUMN_TEXT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_TEXT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_uchar = ::std::mem::transmute(ptr); (fun)(arg1, iCol) } -static __SQLITE3_COLUMN_TEXT16: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - iCol: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_TEXT16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_text16( arg1: *mut sqlite3_stmt, iCol: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_void { - let fun = __SQLITE3_COLUMN_TEXT16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_TEXT16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, iCol) } -static __SQLITE3_COLUMN_TYPE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - iCol: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_TYPE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_type( arg1: *mut sqlite3_stmt, iCol: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_COLUMN_TYPE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_TYPE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, iCol) } -static __SQLITE3_COLUMN_VALUE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - iCol: ::std::os::raw::c_int, - ) -> *mut sqlite3_value, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_VALUE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_value( arg1: *mut sqlite3_stmt, iCol: ::std::os::raw::c_int, ) -> *mut sqlite3_value { - let fun = __SQLITE3_COLUMN_VALUE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_VALUE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> *mut sqlite3_value = ::std::mem::transmute(ptr); (fun)(arg1, iCol) } -static __SQLITE3_COMMIT_HOOK: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - ) -> ::std::os::raw::c_int, - >, - arg3: *mut ::std::os::raw::c_void, - ) -> *mut ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COMMIT_HOOK: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_commit_hook( arg1: *mut sqlite3, arg2: ::std::option::Option< @@ -3256,59 +3192,51 @@ pub unsafe fn sqlite3_commit_hook( >, arg3: *mut ::std::os::raw::c_void, ) -> *mut ::std::os::raw::c_void { - let fun = __SQLITE3_COMMIT_HOOK - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COMMIT_HOOK.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_COMPLETE: ::atomic::Atomic< - Option< - unsafe extern "C" fn(sql: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COMPLETE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_complete( sql: *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_COMPLETE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COMPLETE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + sql: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(sql) } -static __SQLITE3_COMPLETE16: ::atomic::Atomic< - Option< - unsafe extern "C" fn(sql: *const ::std::os::raw::c_void) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COMPLETE16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_complete16( sql: *const ::std::os::raw::c_void, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_COMPLETE16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COMPLETE16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + sql: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(sql) } -static __SQLITE3_CREATE_COLLATION: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: ::std::os::raw::c_int, - arg4: *mut ::std::os::raw::c_void, - arg5: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - arg2: ::std::os::raw::c_int, - arg3: *const ::std::os::raw::c_void, - arg4: ::std::os::raw::c_int, - arg5: *const ::std::os::raw::c_void, - ) -> ::std::os::raw::c_int, - >, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_CREATE_COLLATION: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_create_collation( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, @@ -3324,31 +3252,29 @@ pub unsafe fn sqlite3_create_collation( ) -> ::std::os::raw::c_int, >, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_CREATE_COLLATION - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_CREATE_COLLATION.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, + arg5: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: ::std::os::raw::c_int, + arg5: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5) } -static __SQLITE3_CREATE_COLLATION16: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_void, - arg3: ::std::os::raw::c_int, - arg4: *mut ::std::os::raw::c_void, - arg5: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - arg2: ::std::os::raw::c_int, - arg3: *const ::std::os::raw::c_void, - arg4: ::std::os::raw::c_int, - arg5: *const ::std::os::raw::c_void, - ) -> ::std::os::raw::c_int, - >, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_CREATE_COLLATION16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_create_collation16( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_void, @@ -3364,40 +3290,29 @@ pub unsafe fn sqlite3_create_collation16( ) -> ::std::os::raw::c_int, >, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_CREATE_COLLATION16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_CREATE_COLLATION16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, + arg5: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: ::std::os::raw::c_int, + arg5: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5) } -static __SQLITE3_CREATE_FUNCTION: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: ::std::os::raw::c_int, - arg4: ::std::os::raw::c_int, - arg5: *mut ::std::os::raw::c_void, - xFunc: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: ::std::os::raw::c_int, - arg3: *mut *mut sqlite3_value, - ), - >, - xStep: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: ::std::os::raw::c_int, - arg3: *mut *mut sqlite3_value, - ), - >, - xFinal: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut sqlite3_context), - >, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_CREATE_FUNCTION: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_create_function( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, @@ -3420,40 +3335,36 @@ pub unsafe fn sqlite3_create_function( >, xFinal: ::std::option::Option, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_CREATE_FUNCTION - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_CREATE_FUNCTION.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_void, + xFunc: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xStep: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xFinal: ::std::option::Option, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5, xFunc, xStep, xFinal) } -static __SQLITE3_CREATE_FUNCTION16: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_void, - arg3: ::std::os::raw::c_int, - arg4: ::std::os::raw::c_int, - arg5: *mut ::std::os::raw::c_void, - xFunc: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: ::std::os::raw::c_int, - arg3: *mut *mut sqlite3_value, - ), - >, - xStep: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: ::std::os::raw::c_int, - arg3: *mut *mut sqlite3_value, - ), - >, - xFinal: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut sqlite3_context), - >, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_CREATE_FUNCTION16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_create_function16( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_void, @@ -3476,125 +3387,146 @@ pub unsafe fn sqlite3_create_function16( >, xFinal: ::std::option::Option, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_CREATE_FUNCTION16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_CREATE_FUNCTION16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_void, + xFunc: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xStep: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xFinal: ::std::option::Option, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5, xFunc, xStep, xFinal) } -static __SQLITE3_CREATE_MODULE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: *const sqlite3_module, - arg4: *mut ::std::os::raw::c_void, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_CREATE_MODULE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_create_module( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, arg3: *const sqlite3_module, arg4: *mut ::std::os::raw::c_void, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_CREATE_MODULE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_CREATE_MODULE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const sqlite3_module, + arg4: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_DATA_COUNT: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_DATA_COUNT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_data_count(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int { - let fun = __SQLITE3_DATA_COUNT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_DATA_COUNT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(pStmt) } -static __SQLITE3_DB_HANDLE: ::atomic::Atomic< - Option *mut sqlite3>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_DB_HANDLE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_db_handle(arg1: *mut sqlite3_stmt) -> *mut sqlite3 { - let fun = __SQLITE3_DB_HANDLE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_DB_HANDLE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> *mut sqlite3 = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_DECLARE_VTAB: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_DECLARE_VTAB: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_declare_vtab( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_DECLARE_VTAB - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_DECLARE_VTAB.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_ENABLE_SHARED_CACHE: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_ENABLE_SHARED_CACHE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_enable_shared_cache( arg1: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_ENABLE_SHARED_CACHE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_ENABLE_SHARED_CACHE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_ERRCODE: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_ERRCODE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_errcode(db: *mut sqlite3) -> ::std::os::raw::c_int { - let fun = __SQLITE3_ERRCODE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_ERRCODE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(db: *mut sqlite3) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(db) } -static __SQLITE3_ERRMSG: ::atomic::Atomic< - Option *const ::std::os::raw::c_char>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_ERRMSG: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_errmsg(arg1: *mut sqlite3) -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_ERRMSG - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_ERRMSG.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> *const ::std::os::raw::c_char = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_ERRMSG16: ::atomic::Atomic< - Option *const ::std::os::raw::c_void>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_ERRMSG16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_errmsg16(arg1: *mut sqlite3) -> *const ::std::os::raw::c_void { - let fun = __SQLITE3_ERRMSG16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_ERRMSG16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> *const ::std::os::raw::c_void = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_EXEC: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: sqlite3_callback, - arg4: *mut ::std::os::raw::c_void, - arg5: *mut *mut ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_EXEC: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_exec( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, @@ -3602,82 +3534,85 @@ pub unsafe fn sqlite3_exec( arg4: *mut ::std::os::raw::c_void, arg5: *mut *mut ::std::os::raw::c_char, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_EXEC - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_EXEC.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: sqlite3_callback, + arg4: *mut ::std::os::raw::c_void, + arg5: *mut *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5) } -static __SQLITE3_FINALIZE: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_FINALIZE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_finalize(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int { - let fun = __SQLITE3_FINALIZE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_FINALIZE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(pStmt) } -static __SQLITE3_FREE: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_FREE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_free(arg1: *mut ::std::os::raw::c_void) { - let fun = __SQLITE3_FREE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_FREE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void) = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_FREE_TABLE: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_FREE_TABLE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_free_table(result: *mut *mut ::std::os::raw::c_char) { - let fun = __SQLITE3_FREE_TABLE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_FREE_TABLE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(result: *mut *mut ::std::os::raw::c_char) = ::std::mem::transmute( + ptr, + ); (fun)(result) } -static __SQLITE3_GET_AUTOCOMMIT: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_GET_AUTOCOMMIT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_get_autocommit(arg1: *mut sqlite3) -> ::std::os::raw::c_int { - let fun = __SQLITE3_GET_AUTOCOMMIT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_GET_AUTOCOMMIT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_GET_AUXDATA: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: ::std::os::raw::c_int, - ) -> *mut ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_GET_AUXDATA: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_get_auxdata( arg1: *mut sqlite3_context, arg2: ::std::os::raw::c_int, ) -> *mut ::std::os::raw::c_void { - let fun = __SQLITE3_GET_AUXDATA - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_GET_AUXDATA.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + ) -> *mut ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_GET_TABLE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: *mut *mut *mut ::std::os::raw::c_char, - arg4: *mut ::std::os::raw::c_int, - arg5: *mut ::std::os::raw::c_int, - arg6: *mut *mut ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_GET_TABLE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_get_table( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, @@ -3686,113 +3621,114 @@ pub unsafe fn sqlite3_get_table( arg5: *mut ::std::os::raw::c_int, arg6: *mut *mut ::std::os::raw::c_char, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_GET_TABLE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_GET_TABLE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *mut *mut *mut ::std::os::raw::c_char, + arg4: *mut ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_int, + arg6: *mut *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5, arg6) } -static __SQLITE3_INTERRUPT: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_INTERRUPT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_interrupt(arg1: *mut sqlite3) { - let fun = __SQLITE3_INTERRUPT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_INTERRUPT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_LAST_INSERT_ROWID: ::atomic::Atomic< - Option sqlite_int64>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_LAST_INSERT_ROWID: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_last_insert_rowid(arg1: *mut sqlite3) -> sqlite_int64 { - let fun = __SQLITE3_LAST_INSERT_ROWID - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_LAST_INSERT_ROWID.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> sqlite_int64 = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_LIBVERSION: ::atomic::Atomic< - Option *const ::std::os::raw::c_char>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_LIBVERSION: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_libversion() -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_LIBVERSION - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_LIBVERSION.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn() -> *const ::std::os::raw::c_char = ::std::mem::transmute( + ptr, + ); (fun)() } -static __SQLITE3_LIBVERSION_NUMBER: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_LIBVERSION_NUMBER: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_libversion_number() -> ::std::os::raw::c_int { - let fun = __SQLITE3_LIBVERSION_NUMBER - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_LIBVERSION_NUMBER.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn() -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)() } -static __SQLITE3_MALLOC: ::atomic::Atomic< - Option< - unsafe extern "C" fn(arg1: ::std::os::raw::c_int) -> *mut ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_MALLOC: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_malloc( arg1: ::std::os::raw::c_int, ) -> *mut ::std::os::raw::c_void { - let fun = __SQLITE3_MALLOC - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_MALLOC.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + ) -> *mut ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_OPEN: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *const ::std::os::raw::c_char, - arg2: *mut *mut sqlite3, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_OPEN: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_open( arg1: *const ::std::os::raw::c_char, arg2: *mut *mut sqlite3, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_OPEN - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_OPEN.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *mut *mut sqlite3, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_OPEN16: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *const ::std::os::raw::c_void, - arg2: *mut *mut sqlite3, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_OPEN16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_open16( arg1: *const ::std::os::raw::c_void, arg2: *mut *mut sqlite3, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_OPEN16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_OPEN16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_void, + arg2: *mut *mut sqlite3, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_PREPARE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: ::std::os::raw::c_int, - arg4: *mut *mut sqlite3_stmt, - arg5: *mut *const ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_PREPARE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_prepare( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, @@ -3800,23 +3736,21 @@ pub unsafe fn sqlite3_prepare( arg4: *mut *mut sqlite3_stmt, arg5: *mut *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_PREPARE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_PREPARE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut *mut sqlite3_stmt, + arg5: *mut *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5) } -static __SQLITE3_PREPARE16: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_void, - arg3: ::std::os::raw::c_int, - arg4: *mut *mut sqlite3_stmt, - arg5: *mut *const ::std::os::raw::c_void, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_PREPARE16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_prepare16( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_void, @@ -3824,27 +3758,21 @@ pub unsafe fn sqlite3_prepare16( arg4: *mut *mut sqlite3_stmt, arg5: *mut *const ::std::os::raw::c_void, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_PREPARE16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_PREPARE16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: *mut *mut sqlite3_stmt, + arg5: *mut *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5) } -static __SQLITE3_PROFILE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - arg2: *const ::std::os::raw::c_char, - arg3: sqlite_uint64, - ), - >, - arg3: *mut ::std::os::raw::c_void, - ) -> *mut ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_PROFILE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_profile( arg1: *mut sqlite3, arg2: ::std::option::Option< @@ -3856,26 +3784,25 @@ pub unsafe fn sqlite3_profile( >, arg3: *mut ::std::os::raw::c_void, ) -> *mut ::std::os::raw::c_void { - let fun = __SQLITE3_PROFILE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_PROFILE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *const ::std::os::raw::c_char, + arg3: sqlite_uint64, + ), + >, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_PROGRESS_HANDLER: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: ::std::os::raw::c_int, - arg3: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - ) -> ::std::os::raw::c_int, - >, - arg4: *mut ::std::os::raw::c_void, - ), - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_PROGRESS_HANDLER: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_progress_handler( arg1: *mut sqlite3, arg2: ::std::os::raw::c_int, @@ -3884,296 +3811,286 @@ pub unsafe fn sqlite3_progress_handler( >, arg4: *mut ::std::os::raw::c_void, ) { - let fun = __SQLITE3_PROGRESS_HANDLER - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_PROGRESS_HANDLER.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + arg3: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + arg4: *mut ::std::os::raw::c_void, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_REALLOC: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - arg2: ::std::os::raw::c_int, - ) -> *mut ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_REALLOC: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_realloc( arg1: *mut ::std::os::raw::c_void, arg2: ::std::os::raw::c_int, ) -> *mut ::std::os::raw::c_void { - let fun = __SQLITE3_REALLOC - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_REALLOC.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + ) -> *mut ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_RESET: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESET: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_reset(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int { - let fun = __SQLITE3_RESET - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESET.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(pStmt) } -static __SQLITE3_RESULT_BLOB: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: *const ::std::os::raw::c_void, - arg3: ::std::os::raw::c_int, - arg4: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ), - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_BLOB: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_blob( arg1: *mut sqlite3_context, arg2: *const ::std::os::raw::c_void, arg3: ::std::os::raw::c_int, arg4: ::std::option::Option, ) { - let fun = __SQLITE3_RESULT_BLOB - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_BLOB.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_RESULT_DOUBLE: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_DOUBLE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_double(arg1: *mut sqlite3_context, arg2: f64) { - let fun = __SQLITE3_RESULT_DOUBLE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_DOUBLE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_context, arg2: f64) = ::std::mem::transmute( + ptr, + ); (fun)(arg1, arg2) } -static __SQLITE3_RESULT_ERROR: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: *const ::std::os::raw::c_char, - arg3: ::std::os::raw::c_int, - ), - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_ERROR: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_error( arg1: *mut sqlite3_context, arg2: *const ::std::os::raw::c_char, arg3: ::std::os::raw::c_int, ) { - let fun = __SQLITE3_RESULT_ERROR - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_ERROR.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_RESULT_ERROR16: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: *const ::std::os::raw::c_void, - arg3: ::std::os::raw::c_int, - ), - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_ERROR16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_error16( arg1: *mut sqlite3_context, arg2: *const ::std::os::raw::c_void, arg3: ::std::os::raw::c_int, ) { - let fun = __SQLITE3_RESULT_ERROR16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_ERROR16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_RESULT_INT: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_INT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_int( arg1: *mut sqlite3_context, arg2: ::std::os::raw::c_int, ) { - let fun = __SQLITE3_RESULT_INT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_INT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_RESULT_INT64: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_INT64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_int64(arg1: *mut sqlite3_context, arg2: sqlite_int64) { - let fun = __SQLITE3_RESULT_INT64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_INT64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_context, arg2: sqlite_int64) = ::std::mem::transmute( + ptr, + ); (fun)(arg1, arg2) } -static __SQLITE3_RESULT_NULL: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_NULL: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_null(arg1: *mut sqlite3_context) { - let fun = __SQLITE3_RESULT_NULL - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_NULL.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_context) = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_RESULT_TEXT: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: *const ::std::os::raw::c_char, - arg3: ::std::os::raw::c_int, - arg4: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ), - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_TEXT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_text( arg1: *mut sqlite3_context, arg2: *const ::std::os::raw::c_char, arg3: ::std::os::raw::c_int, arg4: ::std::option::Option, ) { - let fun = __SQLITE3_RESULT_TEXT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_TEXT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_RESULT_TEXT16: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: *const ::std::os::raw::c_void, - arg3: ::std::os::raw::c_int, - arg4: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ), - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_TEXT16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_text16( arg1: *mut sqlite3_context, arg2: *const ::std::os::raw::c_void, arg3: ::std::os::raw::c_int, arg4: ::std::option::Option, ) { - let fun = __SQLITE3_RESULT_TEXT16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_TEXT16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_RESULT_TEXT16BE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: *const ::std::os::raw::c_void, - arg3: ::std::os::raw::c_int, - arg4: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ), - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_TEXT16BE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_text16be( arg1: *mut sqlite3_context, arg2: *const ::std::os::raw::c_void, arg3: ::std::os::raw::c_int, arg4: ::std::option::Option, ) { - let fun = __SQLITE3_RESULT_TEXT16BE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_TEXT16BE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_RESULT_TEXT16LE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: *const ::std::os::raw::c_void, - arg3: ::std::os::raw::c_int, - arg4: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ), - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_TEXT16LE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_text16le( arg1: *mut sqlite3_context, arg2: *const ::std::os::raw::c_void, arg3: ::std::os::raw::c_int, arg4: ::std::option::Option, ) { - let fun = __SQLITE3_RESULT_TEXT16LE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_TEXT16LE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_RESULT_VALUE: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_VALUE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_value( arg1: *mut sqlite3_context, arg2: *mut sqlite3_value, ) { - let fun = __SQLITE3_RESULT_VALUE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_VALUE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *mut sqlite3_value, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_ROLLBACK_HOOK: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - arg3: *mut ::std::os::raw::c_void, - ) -> *mut ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_ROLLBACK_HOOK: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_rollback_hook( arg1: *mut sqlite3, arg2: ::std::option::Option, arg3: *mut ::std::os::raw::c_void, ) -> *mut ::std::os::raw::c_void { - let fun = __SQLITE3_ROLLBACK_HOOK - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_ROLLBACK_HOOK.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_SET_AUTHORIZER: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - arg2: ::std::os::raw::c_int, - arg3: *const ::std::os::raw::c_char, - arg4: *const ::std::os::raw::c_char, - arg5: *const ::std::os::raw::c_char, - arg6: *const ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, - >, - arg3: *mut ::std::os::raw::c_void, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_SET_AUTHORIZER: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_set_authorizer( arg1: *mut sqlite3, arg2: ::std::option::Option< @@ -4188,61 +4105,62 @@ pub unsafe fn sqlite3_set_authorizer( >, arg3: *mut ::std::os::raw::c_void, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_SET_AUTHORIZER - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_SET_AUTHORIZER.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + arg4: *const ::std::os::raw::c_char, + arg5: *const ::std::os::raw::c_char, + arg6: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_SET_AUXDATA: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: ::std::os::raw::c_int, - arg3: *mut ::std::os::raw::c_void, - arg4: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ), - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_SET_AUXDATA: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_set_auxdata( arg1: *mut sqlite3_context, arg2: ::std::os::raw::c_int, arg3: *mut ::std::os::raw::c_void, arg4: ::std::option::Option, ) { - let fun = __SQLITE3_SET_AUXDATA - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_SET_AUXDATA.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut ::std::os::raw::c_void, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_STEP: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_STEP: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_step(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int { - let fun = __SQLITE3_STEP - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_STEP.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_TABLE_COLUMN_METADATA: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: *const ::std::os::raw::c_char, - arg4: *const ::std::os::raw::c_char, - arg5: *mut *const ::std::os::raw::c_char, - arg6: *mut *const ::std::os::raw::c_char, - arg7: *mut ::std::os::raw::c_int, - arg8: *mut ::std::os::raw::c_int, - arg9: *mut ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_TABLE_COLUMN_METADATA: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_table_column_metadata( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, @@ -4254,36 +4172,38 @@ pub unsafe fn sqlite3_table_column_metadata( arg8: *mut ::std::os::raw::c_int, arg9: *mut ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_TABLE_COLUMN_METADATA - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_TABLE_COLUMN_METADATA + .load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: *const ::std::os::raw::c_char, + arg5: *mut *const ::std::os::raw::c_char, + arg6: *mut *const ::std::os::raw::c_char, + arg7: *mut ::std::os::raw::c_int, + arg8: *mut ::std::os::raw::c_int, + arg9: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) } -static __SQLITE3_TOTAL_CHANGES: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_TOTAL_CHANGES: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_total_changes(arg1: *mut sqlite3) -> ::std::os::raw::c_int { - let fun = __SQLITE3_TOTAL_CHANGES - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_TOTAL_CHANGES.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_TRACE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - xTrace: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - arg2: *const ::std::os::raw::c_char, - ), - >, - arg2: *mut ::std::os::raw::c_void, - ) -> *mut ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_TRACE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_trace( arg1: *mut sqlite3, xTrace: ::std::option::Option< @@ -4294,29 +4214,24 @@ pub unsafe fn sqlite3_trace( >, arg2: *mut ::std::os::raw::c_void, ) -> *mut ::std::os::raw::c_void { - let fun = __SQLITE3_TRACE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_TRACE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + xTrace: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *const ::std::os::raw::c_char, + ), + >, + arg2: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, xTrace, arg2) } -static __SQLITE3_UPDATE_HOOK: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - arg2: ::std::os::raw::c_int, - arg3: *const ::std::os::raw::c_char, - arg4: *const ::std::os::raw::c_char, - arg5: sqlite_int64, - ), - >, - arg3: *mut ::std::os::raw::c_void, - ) -> *mut ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_UPDATE_HOOK: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_update_hook( arg1: *mut sqlite3, arg2: ::std::option::Option< @@ -4330,199 +4245,215 @@ pub unsafe fn sqlite3_update_hook( >, arg3: *mut ::std::os::raw::c_void, ) -> *mut ::std::os::raw::c_void { - let fun = __SQLITE3_UPDATE_HOOK - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_UPDATE_HOOK.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + arg4: *const ::std::os::raw::c_char, + arg5: sqlite_int64, + ), + >, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_USER_DATA: ::atomic::Atomic< - Option< - unsafe extern "C" fn(arg1: *mut sqlite3_context) -> *mut ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_USER_DATA: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_user_data( arg1: *mut sqlite3_context, ) -> *mut ::std::os::raw::c_void { - let fun = __SQLITE3_USER_DATA - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_USER_DATA.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + ) -> *mut ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_VALUE_BLOB: ::atomic::Atomic< - Option< - unsafe extern "C" fn(arg1: *mut sqlite3_value) -> *const ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_BLOB: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_blob( arg1: *mut sqlite3_value, ) -> *const ::std::os::raw::c_void { - let fun = __SQLITE3_VALUE_BLOB - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_BLOB.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_value, + ) -> *const ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_VALUE_BYTES: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_BYTES: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_bytes(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int { - let fun = __SQLITE3_VALUE_BYTES - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_BYTES.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_VALUE_BYTES16: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_BYTES16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_bytes16(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int { - let fun = __SQLITE3_VALUE_BYTES16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_BYTES16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_VALUE_DOUBLE: ::atomic::Atomic< - Option f64>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_DOUBLE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_double(arg1: *mut sqlite3_value) -> f64 { - let fun = __SQLITE3_VALUE_DOUBLE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_DOUBLE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_value) -> f64 = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_VALUE_INT: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_INT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_int(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int { - let fun = __SQLITE3_VALUE_INT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_INT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_VALUE_INT64: ::atomic::Atomic< - Option sqlite_int64>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_INT64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_int64(arg1: *mut sqlite3_value) -> sqlite_int64 { - let fun = __SQLITE3_VALUE_INT64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_INT64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_value) -> sqlite_int64 = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_VALUE_NUMERIC_TYPE: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_NUMERIC_TYPE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_numeric_type( arg1: *mut sqlite3_value, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_VALUE_NUMERIC_TYPE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_NUMERIC_TYPE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_VALUE_TEXT: ::atomic::Atomic< - Option< - unsafe extern "C" fn(arg1: *mut sqlite3_value) -> *const ::std::os::raw::c_uchar, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_TEXT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_text( arg1: *mut sqlite3_value, ) -> *const ::std::os::raw::c_uchar { - let fun = __SQLITE3_VALUE_TEXT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_TEXT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_value, + ) -> *const ::std::os::raw::c_uchar = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_VALUE_TEXT16: ::atomic::Atomic< - Option< - unsafe extern "C" fn(arg1: *mut sqlite3_value) -> *const ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_TEXT16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_text16( arg1: *mut sqlite3_value, ) -> *const ::std::os::raw::c_void { - let fun = __SQLITE3_VALUE_TEXT16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_TEXT16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_value, + ) -> *const ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_VALUE_TEXT16BE: ::atomic::Atomic< - Option< - unsafe extern "C" fn(arg1: *mut sqlite3_value) -> *const ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_TEXT16BE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_text16be( arg1: *mut sqlite3_value, ) -> *const ::std::os::raw::c_void { - let fun = __SQLITE3_VALUE_TEXT16BE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_TEXT16BE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_value, + ) -> *const ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_VALUE_TEXT16LE: ::atomic::Atomic< - Option< - unsafe extern "C" fn(arg1: *mut sqlite3_value) -> *const ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_TEXT16LE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_text16le( arg1: *mut sqlite3_value, ) -> *const ::std::os::raw::c_void { - let fun = __SQLITE3_VALUE_TEXT16LE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_TEXT16LE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_value, + ) -> *const ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_VALUE_TYPE: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_TYPE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_type(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int { - let fun = __SQLITE3_VALUE_TYPE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_TYPE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_OVERLOAD_FUNCTION: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - zFuncName: *const ::std::os::raw::c_char, - nArg: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_OVERLOAD_FUNCTION: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_overload_function( arg1: *mut sqlite3, zFuncName: *const ::std::os::raw::c_char, nArg: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_OVERLOAD_FUNCTION - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_OVERLOAD_FUNCTION.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + zFuncName: *const ::std::os::raw::c_char, + nArg: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, zFuncName, nArg) } -static __SQLITE3_PREPARE_V2: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: ::std::os::raw::c_int, - arg4: *mut *mut sqlite3_stmt, - arg5: *mut *const ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_PREPARE_V2: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_prepare_v2( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, @@ -4530,23 +4461,21 @@ pub unsafe fn sqlite3_prepare_v2( arg4: *mut *mut sqlite3_stmt, arg5: *mut *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_PREPARE_V2 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_PREPARE_V2.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut *mut sqlite3_stmt, + arg5: *mut *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5) } -static __SQLITE3_PREPARE16_V2: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_void, - arg3: ::std::os::raw::c_int, - arg4: *mut *mut sqlite3_stmt, - arg5: *mut *const ::std::os::raw::c_void, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_PREPARE16_V2: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_prepare16_v2( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_void, @@ -4554,35 +4483,33 @@ pub unsafe fn sqlite3_prepare16_v2( arg4: *mut *mut sqlite3_stmt, arg5: *mut *const ::std::os::raw::c_void, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_PREPARE16_V2 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_PREPARE16_V2.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: *mut *mut sqlite3_stmt, + arg5: *mut *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5) } -static __SQLITE3_CLEAR_BINDINGS: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_CLEAR_BINDINGS: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_clear_bindings(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int { - let fun = __SQLITE3_CLEAR_BINDINGS - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_CLEAR_BINDINGS.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_CREATE_MODULE_V2: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: *const sqlite3_module, - arg4: *mut ::std::os::raw::c_void, - xDestroy: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_CREATE_MODULE_V2: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_create_module_v2( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, @@ -4592,65 +4519,65 @@ pub unsafe fn sqlite3_create_module_v2( unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), >, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_CREATE_MODULE_V2 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_CREATE_MODULE_V2.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const sqlite3_module, + arg4: *mut ::std::os::raw::c_void, + xDestroy: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, xDestroy) } -static __SQLITE3_BIND_ZEROBLOB: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - arg3: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BIND_ZEROBLOB: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_bind_zeroblob( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, arg3: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BIND_ZEROBLOB - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BIND_ZEROBLOB.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_BLOB_BYTES: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BLOB_BYTES: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_blob_bytes(arg1: *mut sqlite3_blob) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BLOB_BYTES - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BLOB_BYTES.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_blob) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_BLOB_CLOSE: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BLOB_CLOSE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_blob_close(arg1: *mut sqlite3_blob) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BLOB_CLOSE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BLOB_CLOSE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_blob) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_BLOB_OPEN: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: *const ::std::os::raw::c_char, - arg4: *const ::std::os::raw::c_char, - arg5: sqlite3_int64, - arg6: ::std::os::raw::c_int, - arg7: *mut *mut sqlite3_blob, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BLOB_OPEN: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_blob_open( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, @@ -4660,78 +4587,63 @@ pub unsafe fn sqlite3_blob_open( arg6: ::std::os::raw::c_int, arg7: *mut *mut sqlite3_blob, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BLOB_OPEN - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BLOB_OPEN.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: *const ::std::os::raw::c_char, + arg5: sqlite3_int64, + arg6: ::std::os::raw::c_int, + arg7: *mut *mut sqlite3_blob, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5, arg6, arg7) } -static __SQLITE3_BLOB_READ: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_blob, - arg2: *mut ::std::os::raw::c_void, - arg3: ::std::os::raw::c_int, - arg4: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BLOB_READ: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_blob_read( arg1: *mut sqlite3_blob, arg2: *mut ::std::os::raw::c_void, arg3: ::std::os::raw::c_int, arg4: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BLOB_READ - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BLOB_READ.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_blob, + arg2: *mut ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_BLOB_WRITE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_blob, - arg2: *const ::std::os::raw::c_void, - arg3: ::std::os::raw::c_int, - arg4: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BLOB_WRITE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_blob_write( arg1: *mut sqlite3_blob, arg2: *const ::std::os::raw::c_void, arg3: ::std::os::raw::c_int, arg4: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BLOB_WRITE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BLOB_WRITE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_blob, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_CREATE_COLLATION_V2: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: ::std::os::raw::c_int, - arg4: *mut ::std::os::raw::c_void, - arg5: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - arg2: ::std::os::raw::c_int, - arg3: *const ::std::os::raw::c_void, - arg4: ::std::os::raw::c_int, - arg5: *const ::std::os::raw::c_void, - ) -> ::std::os::raw::c_int, - >, - arg6: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_CREATE_COLLATION_V2: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_create_collation_v2( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, @@ -4748,507 +4660,509 @@ pub unsafe fn sqlite3_create_collation_v2( >, arg6: ::std::option::Option, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_CREATE_COLLATION_V2 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_CREATE_COLLATION_V2.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, + arg5: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: ::std::os::raw::c_int, + arg5: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + arg6: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5, arg6) } -static __SQLITE3_FILE_CONTROL: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: ::std::os::raw::c_int, - arg4: *mut ::std::os::raw::c_void, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_FILE_CONTROL: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_file_control( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, arg3: ::std::os::raw::c_int, arg4: *mut ::std::os::raw::c_void, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_FILE_CONTROL - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_FILE_CONTROL.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_MEMORY_HIGHWATER: ::atomic::Atomic< - Option sqlite3_int64>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_MEMORY_HIGHWATER: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_memory_highwater(arg1: ::std::os::raw::c_int) -> sqlite3_int64 { - let fun = __SQLITE3_MEMORY_HIGHWATER - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_MEMORY_HIGHWATER.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: ::std::os::raw::c_int) -> sqlite3_int64 = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_MEMORY_USED: ::atomic::Atomic< - Option sqlite3_int64>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_MEMORY_USED: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_memory_used() -> sqlite3_int64 { - let fun = __SQLITE3_MEMORY_USED - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_MEMORY_USED.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn() -> sqlite3_int64 = ::std::mem::transmute(ptr); (fun)() } -static __SQLITE3_MUTEX_ALLOC: ::atomic::Atomic< - Option *mut sqlite3_mutex>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_MUTEX_ALLOC: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_mutex_alloc(arg1: ::std::os::raw::c_int) -> *mut sqlite3_mutex { - let fun = __SQLITE3_MUTEX_ALLOC - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_MUTEX_ALLOC.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: ::std::os::raw::c_int) -> *mut sqlite3_mutex = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_MUTEX_ENTER: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_MUTEX_ENTER: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_mutex_enter(arg1: *mut sqlite3_mutex) { - let fun = __SQLITE3_MUTEX_ENTER - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_MUTEX_ENTER.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_mutex) = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_MUTEX_FREE: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_MUTEX_FREE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_mutex_free(arg1: *mut sqlite3_mutex) { - let fun = __SQLITE3_MUTEX_FREE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_MUTEX_FREE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_mutex) = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_MUTEX_LEAVE: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_MUTEX_LEAVE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_mutex_leave(arg1: *mut sqlite3_mutex) { - let fun = __SQLITE3_MUTEX_LEAVE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_MUTEX_LEAVE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_mutex) = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_MUTEX_TRY: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_MUTEX_TRY: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_mutex_try(arg1: *mut sqlite3_mutex) -> ::std::os::raw::c_int { - let fun = __SQLITE3_MUTEX_TRY - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_MUTEX_TRY.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_mutex) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_OPEN_V2: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *const ::std::os::raw::c_char, - arg2: *mut *mut sqlite3, - arg3: ::std::os::raw::c_int, - arg4: *const ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_OPEN_V2: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_open_v2( arg1: *const ::std::os::raw::c_char, arg2: *mut *mut sqlite3, arg3: ::std::os::raw::c_int, arg4: *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_OPEN_V2 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_OPEN_V2.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *mut *mut sqlite3, + arg3: ::std::os::raw::c_int, + arg4: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_RELEASE_MEMORY: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RELEASE_MEMORY: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_release_memory( arg1: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_RELEASE_MEMORY - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RELEASE_MEMORY.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_RESULT_ERROR_NOMEM: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_ERROR_NOMEM: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_error_nomem(arg1: *mut sqlite3_context) { - let fun = __SQLITE3_RESULT_ERROR_NOMEM - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_ERROR_NOMEM.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_context) = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_RESULT_ERROR_TOOBIG: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_ERROR_TOOBIG: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_error_toobig(arg1: *mut sqlite3_context) { - let fun = __SQLITE3_RESULT_ERROR_TOOBIG - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_ERROR_TOOBIG.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_context) = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_SLEEP: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_SLEEP: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_sleep(arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int { - let fun = __SQLITE3_SLEEP - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_SLEEP.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_SOFT_HEAP_LIMIT: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_SOFT_HEAP_LIMIT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_soft_heap_limit(arg1: ::std::os::raw::c_int) { - let fun = __SQLITE3_SOFT_HEAP_LIMIT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_SOFT_HEAP_LIMIT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: ::std::os::raw::c_int) = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_VFS_FIND: ::atomic::Atomic< - Option *mut sqlite3_vfs>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VFS_FIND: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_vfs_find(arg1: *const ::std::os::raw::c_char) -> *mut sqlite3_vfs { - let fun = __SQLITE3_VFS_FIND - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VFS_FIND.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + ) -> *mut sqlite3_vfs = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_VFS_REGISTER: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_vfs, - arg2: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VFS_REGISTER: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_vfs_register( arg1: *mut sqlite3_vfs, arg2: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_VFS_REGISTER - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VFS_REGISTER.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_VFS_UNREGISTER: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VFS_UNREGISTER: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_vfs_unregister(arg1: *mut sqlite3_vfs) -> ::std::os::raw::c_int { - let fun = __SQLITE3_VFS_UNREGISTER - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VFS_UNREGISTER.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_vfs) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_THREADSAFE: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_THREADSAFE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_threadsafe() -> ::std::os::raw::c_int { - let fun = __SQLITE3_THREADSAFE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_THREADSAFE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn() -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)() } -static __SQLITE3_RESULT_ZEROBLOB: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_ZEROBLOB: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_zeroblob( arg1: *mut sqlite3_context, arg2: ::std::os::raw::c_int, ) { - let fun = __SQLITE3_RESULT_ZEROBLOB - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_ZEROBLOB.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_RESULT_ERROR_CODE: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_ERROR_CODE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_error_code( arg1: *mut sqlite3_context, arg2: ::std::os::raw::c_int, ) { - let fun = __SQLITE3_RESULT_ERROR_CODE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_ERROR_CODE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_RANDOMNESS: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: ::std::os::raw::c_int, - arg2: *mut ::std::os::raw::c_void, - ), - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RANDOMNESS: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_randomness( arg1: ::std::os::raw::c_int, arg2: *mut ::std::os::raw::c_void, ) { - let fun = __SQLITE3_RANDOMNESS - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RANDOMNESS.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + arg2: *mut ::std::os::raw::c_void, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_CONTEXT_DB_HANDLE: ::atomic::Atomic< - Option *mut sqlite3>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_CONTEXT_DB_HANDLE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_context_db_handle(arg1: *mut sqlite3_context) -> *mut sqlite3 { - let fun = __SQLITE3_CONTEXT_DB_HANDLE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_CONTEXT_DB_HANDLE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_context) -> *mut sqlite3 = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_EXTENDED_RESULT_CODES: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_EXTENDED_RESULT_CODES: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_extended_result_codes( arg1: *mut sqlite3, arg2: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_EXTENDED_RESULT_CODES - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_EXTENDED_RESULT_CODES + .load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_LIMIT: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: ::std::os::raw::c_int, - arg3: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_LIMIT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_limit( arg1: *mut sqlite3, arg2: ::std::os::raw::c_int, arg3: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_LIMIT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_LIMIT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_NEXT_STMT: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *mut sqlite3_stmt, - ) -> *mut sqlite3_stmt, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_NEXT_STMT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_next_stmt( arg1: *mut sqlite3, arg2: *mut sqlite3_stmt, ) -> *mut sqlite3_stmt { - let fun = __SQLITE3_NEXT_STMT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_NEXT_STMT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *mut sqlite3_stmt, + ) -> *mut sqlite3_stmt = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_SQL: ::atomic::Atomic< - Option< - unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> *const ::std::os::raw::c_char, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_SQL: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_sql(arg1: *mut sqlite3_stmt) -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_SQL - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_SQL.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + ) -> *const ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_STATUS: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: ::std::os::raw::c_int, - arg2: *mut ::std::os::raw::c_int, - arg3: *mut ::std::os::raw::c_int, - arg4: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_STATUS: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_status( arg1: ::std::os::raw::c_int, arg2: *mut ::std::os::raw::c_int, arg3: *mut ::std::os::raw::c_int, arg4: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_STATUS - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_STATUS.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + arg2: *mut ::std::os::raw::c_int, + arg3: *mut ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_BACKUP_FINISH: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BACKUP_FINISH: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_backup_finish(arg1: *mut sqlite3_backup) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BACKUP_FINISH - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BACKUP_FINISH.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_backup) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_BACKUP_INIT: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: *mut sqlite3, - arg4: *const ::std::os::raw::c_char, - ) -> *mut sqlite3_backup, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BACKUP_INIT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_backup_init( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, arg3: *mut sqlite3, arg4: *const ::std::os::raw::c_char, ) -> *mut sqlite3_backup { - let fun = __SQLITE3_BACKUP_INIT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BACKUP_INIT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *mut sqlite3, + arg4: *const ::std::os::raw::c_char, + ) -> *mut sqlite3_backup = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_BACKUP_PAGECOUNT: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BACKUP_PAGECOUNT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_backup_pagecount( arg1: *mut sqlite3_backup, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BACKUP_PAGECOUNT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BACKUP_PAGECOUNT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_backup) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_BACKUP_REMAINING: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BACKUP_REMAINING: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_backup_remaining( arg1: *mut sqlite3_backup, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BACKUP_REMAINING - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BACKUP_REMAINING.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_backup) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_BACKUP_STEP: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_backup, - arg2: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BACKUP_STEP: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_backup_step( arg1: *mut sqlite3_backup, arg2: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BACKUP_STEP - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BACKUP_STEP.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_backup, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_COMPILEOPTION_GET: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_char, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COMPILEOPTION_GET: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_compileoption_get( arg1: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_COMPILEOPTION_GET - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COMPILEOPTION_GET.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_COMPILEOPTION_USED: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *const ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COMPILEOPTION_USED: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_compileoption_used( arg1: *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_COMPILEOPTION_USED - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COMPILEOPTION_USED.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_CREATE_FUNCTION_V2: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: ::std::os::raw::c_int, - arg4: ::std::os::raw::c_int, - arg5: *mut ::std::os::raw::c_void, - xFunc: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: ::std::os::raw::c_int, - arg3: *mut *mut sqlite3_value, - ), - >, - xStep: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: ::std::os::raw::c_int, - arg3: *mut *mut sqlite3_value, - ), - >, - xFinal: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut sqlite3_context), - >, - xDestroy: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_CREATE_FUNCTION_V2: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_create_function_v2( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, @@ -5274,54 +5188,70 @@ pub unsafe fn sqlite3_create_function_v2( unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), >, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_CREATE_FUNCTION_V2 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_CREATE_FUNCTION_V2.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_void, + xFunc: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xStep: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xFinal: ::std::option::Option, + xDestroy: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5, xFunc, xStep, xFinal, xDestroy) } -static __SQLITE3_DB_CONFIG: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: ::std::os::raw::c_int, - ... - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_DB_CONFIG: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_db_config( arg1: *mut sqlite3, arg2: ::std::os::raw::c_int, arg3: ::std::os::raw::c_int, arg4: *mut ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_DB_CONFIG - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized"); + let ptr = __SQLITE3_DB_CONFIG.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + ... + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_DB_MUTEX: ::atomic::Atomic< - Option *mut sqlite3_mutex>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_DB_MUTEX: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_db_mutex(arg1: *mut sqlite3) -> *mut sqlite3_mutex { - let fun = __SQLITE3_DB_MUTEX - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_DB_MUTEX.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> *mut sqlite3_mutex = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_DB_STATUS: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: ::std::os::raw::c_int, - arg3: *mut ::std::os::raw::c_int, - arg4: *mut ::std::os::raw::c_int, - arg5: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_DB_STATUS: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_db_status( arg1: *mut sqlite3, arg2: ::std::os::raw::c_int, @@ -5329,116 +5259,111 @@ pub unsafe fn sqlite3_db_status( arg4: *mut ::std::os::raw::c_int, arg5: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_DB_STATUS - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_DB_STATUS.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + arg3: *mut ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_int, + arg5: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5) } -static __SQLITE3_EXTENDED_ERRCODE: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_EXTENDED_ERRCODE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_extended_errcode(arg1: *mut sqlite3) -> ::std::os::raw::c_int { - let fun = __SQLITE3_EXTENDED_ERRCODE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_EXTENDED_ERRCODE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_LOG: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: ::std::os::raw::c_int, - arg2: *const ::std::os::raw::c_char, - ... - ), - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_LOG: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_log( arg1: ::std::os::raw::c_int, arg2: *const ::std::os::raw::c_char, arg3: *const ::std::os::raw::c_char, ) { - let fun = __SQLITE3_LOG - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized"); + let ptr = __SQLITE3_LOG.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized"); + let fun: unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + arg2: *const ::std::os::raw::c_char, + ... + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_SOFT_HEAP_LIMIT64: ::atomic::Atomic< - Option sqlite3_int64>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_SOFT_HEAP_LIMIT64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_soft_heap_limit64(arg1: sqlite3_int64) -> sqlite3_int64 { - let fun = __SQLITE3_SOFT_HEAP_LIMIT64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_SOFT_HEAP_LIMIT64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: sqlite3_int64) -> sqlite3_int64 = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_SOURCEID: ::atomic::Atomic< - Option *const ::std::os::raw::c_char>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_SOURCEID: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_sourceid() -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_SOURCEID - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_SOURCEID.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn() -> *const ::std::os::raw::c_char = ::std::mem::transmute( + ptr, + ); (fun)() } -static __SQLITE3_STMT_STATUS: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - arg3: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_STMT_STATUS: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_stmt_status( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, arg3: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_STMT_STATUS - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_STMT_STATUS.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_STRNICMP: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *const ::std::os::raw::c_char, - arg2: *const ::std::os::raw::c_char, - arg3: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_STRNICMP: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_strnicmp( arg1: *const ::std::os::raw::c_char, arg2: *const ::std::os::raw::c_char, arg3: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_STRNICMP - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_STRNICMP.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_UNLOCK_NOTIFY: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut *mut ::std::os::raw::c_void, - arg2: ::std::os::raw::c_int, - ), - >, - arg3: *mut ::std::os::raw::c_void, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_UNLOCK_NOTIFY: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_unlock_notify( arg1: *mut sqlite3, arg2: ::std::option::Option< @@ -5449,64 +5374,56 @@ pub unsafe fn sqlite3_unlock_notify( >, arg3: *mut ::std::os::raw::c_void, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_UNLOCK_NOTIFY - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_UNLOCK_NOTIFY.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + ), + >, + arg3: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_WAL_AUTOCHECKPOINT: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_WAL_AUTOCHECKPOINT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_wal_autocheckpoint( arg1: *mut sqlite3, arg2: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_WAL_AUTOCHECKPOINT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_WAL_AUTOCHECKPOINT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_WAL_CHECKPOINT: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_WAL_CHECKPOINT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_wal_checkpoint( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_WAL_CHECKPOINT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_WAL_CHECKPOINT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_WAL_HOOK: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - arg2: *mut sqlite3, - arg3: *const ::std::os::raw::c_char, - arg4: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, - arg3: *mut ::std::os::raw::c_void, - ) -> *mut ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_WAL_HOOK: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_wal_hook( arg1: *mut sqlite3, arg2: ::std::option::Option< @@ -5519,238 +5436,253 @@ pub unsafe fn sqlite3_wal_hook( >, arg3: *mut ::std::os::raw::c_void, ) -> *mut ::std::os::raw::c_void { - let fun = __SQLITE3_WAL_HOOK - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_WAL_HOOK.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut sqlite3, + arg3: *const ::std::os::raw::c_char, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_BLOB_REOPEN: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_blob, - arg2: sqlite3_int64, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BLOB_REOPEN: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_blob_reopen( arg1: *mut sqlite3_blob, arg2: sqlite3_int64, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BLOB_REOPEN - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BLOB_REOPEN.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_blob, + arg2: sqlite3_int64, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_VTAB_CONFIG: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - op: ::std::os::raw::c_int, - ... - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VTAB_CONFIG: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_vtab_config( arg1: *mut sqlite3, op: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_VTAB_CONFIG - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VTAB_CONFIG.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + op: ::std::os::raw::c_int, + ... + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, op) } -static __SQLITE3_VTAB_ON_CONFLICT: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VTAB_ON_CONFLICT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_vtab_on_conflict(arg1: *mut sqlite3) -> ::std::os::raw::c_int { - let fun = __SQLITE3_VTAB_ON_CONFLICT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VTAB_ON_CONFLICT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_CLOSE_V2: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_CLOSE_V2: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_close_v2(arg1: *mut sqlite3) -> ::std::os::raw::c_int { - let fun = __SQLITE3_CLOSE_V2 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_CLOSE_V2.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_DB_FILENAME: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - ) -> *const ::std::os::raw::c_char, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_DB_FILENAME: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_db_filename( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, ) -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_DB_FILENAME - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_DB_FILENAME.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + ) -> *const ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_DB_READONLY: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_DB_READONLY: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_db_readonly( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_DB_READONLY - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_DB_READONLY.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_DB_RELEASE_MEMORY: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_DB_RELEASE_MEMORY: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_db_release_memory(arg1: *mut sqlite3) -> ::std::os::raw::c_int { - let fun = __SQLITE3_DB_RELEASE_MEMORY - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_DB_RELEASE_MEMORY.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_ERRSTR: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_char, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_ERRSTR: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_errstr( arg1: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_ERRSTR - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_ERRSTR.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_STMT_BUSY: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_STMT_BUSY: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_stmt_busy(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int { - let fun = __SQLITE3_STMT_BUSY - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_STMT_BUSY.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_STMT_READONLY: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_STMT_READONLY: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_stmt_readonly(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int { - let fun = __SQLITE3_STMT_READONLY - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_STMT_READONLY.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_STRICMP: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *const ::std::os::raw::c_char, - arg2: *const ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_STRICMP: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_stricmp( arg1: *const ::std::os::raw::c_char, arg2: *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_STRICMP - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_STRICMP.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_URI_BOOLEAN: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *const ::std::os::raw::c_char, - arg2: *const ::std::os::raw::c_char, - arg3: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_URI_BOOLEAN: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_uri_boolean( arg1: *const ::std::os::raw::c_char, arg2: *const ::std::os::raw::c_char, arg3: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_URI_BOOLEAN - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_URI_BOOLEAN.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_URI_INT64: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *const ::std::os::raw::c_char, - arg2: *const ::std::os::raw::c_char, - arg3: sqlite3_int64, - ) -> sqlite3_int64, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_URI_INT64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_uri_int64( arg1: *const ::std::os::raw::c_char, arg2: *const ::std::os::raw::c_char, arg3: sqlite3_int64, ) -> sqlite3_int64 { - let fun = __SQLITE3_URI_INT64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_URI_INT64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: sqlite3_int64, + ) -> sqlite3_int64 = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_URI_PARAMETER: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *const ::std::os::raw::c_char, - arg2: *const ::std::os::raw::c_char, - ) -> *const ::std::os::raw::c_char, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_URI_PARAMETER: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_uri_parameter( arg1: *const ::std::os::raw::c_char, arg2: *const ::std::os::raw::c_char, ) -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_URI_PARAMETER - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_URI_PARAMETER.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + ) -> *const ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_WAL_CHECKPOINT_V2: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: ::std::os::raw::c_int, - arg4: *mut ::std::os::raw::c_int, - arg5: *mut ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VSNPRINTF: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); +pub unsafe fn sqlite3_vsnprintf( + arg1: ::std::os::raw::c_int, + arg2: *mut ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: *mut ::std::os::raw::c_void, +) -> *mut ::std::os::raw::c_char { + let ptr = __SQLITE3_VSNPRINTF.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + arg2: *mut ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_char = ::std::mem::transmute(ptr); + (fun)(arg1, arg2, arg3, arg4) +} + +static __SQLITE3_WAL_CHECKPOINT_V2: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_wal_checkpoint_v2( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, @@ -5758,41 +5690,35 @@ pub unsafe fn sqlite3_wal_checkpoint_v2( arg4: *mut ::std::os::raw::c_int, arg5: *mut ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_WAL_CHECKPOINT_V2 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_WAL_CHECKPOINT_V2.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5) } -static __SQLITE3_AUTO_EXTENSION: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: ::std::option::Option, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_AUTO_EXTENSION: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_auto_extension( arg1: ::std::option::Option, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_AUTO_EXTENSION - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_AUTO_EXTENSION.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: ::std::option::Option, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_BIND_BLOB64: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - arg3: *const ::std::os::raw::c_void, - arg4: sqlite3_uint64, - arg5: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BIND_BLOB64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_bind_blob64( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, @@ -5800,26 +5726,23 @@ pub unsafe fn sqlite3_bind_blob64( arg4: sqlite3_uint64, arg5: ::std::option::Option, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BIND_BLOB64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BIND_BLOB64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: sqlite3_uint64, + arg5: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5) } -static __SQLITE3_BIND_TEXT64: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - arg3: *const ::std::os::raw::c_char, - arg4: sqlite3_uint64, - arg5: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - arg6: ::std::os::raw::c_uchar, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BIND_TEXT64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_bind_text64( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, @@ -5828,135 +5751,132 @@ pub unsafe fn sqlite3_bind_text64( arg5: ::std::option::Option, arg6: ::std::os::raw::c_uchar, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BIND_TEXT64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BIND_TEXT64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + arg4: sqlite3_uint64, + arg5: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + arg6: ::std::os::raw::c_uchar, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5, arg6) } -static __SQLITE3_CANCEL_AUTO_EXTENSION: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: ::std::option::Option, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_CANCEL_AUTO_EXTENSION: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_cancel_auto_extension( arg1: ::std::option::Option, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_CANCEL_AUTO_EXTENSION - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_CANCEL_AUTO_EXTENSION + .load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: ::std::option::Option, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_LOAD_EXTENSION: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: *const ::std::os::raw::c_char, - arg4: *mut *mut ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_LOAD_EXTENSION: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_load_extension( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, arg3: *const ::std::os::raw::c_char, arg4: *mut *mut ::std::os::raw::c_char, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_LOAD_EXTENSION - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_LOAD_EXTENSION.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: *mut *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_MALLOC64: ::atomic::Atomic< - Option *mut ::std::os::raw::c_void>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_MALLOC64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_malloc64(arg1: sqlite3_uint64) -> *mut ::std::os::raw::c_void { - let fun = __SQLITE3_MALLOC64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_MALLOC64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: sqlite3_uint64) -> *mut ::std::os::raw::c_void = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_MSIZE: ::atomic::Atomic< - Option sqlite3_uint64>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_MSIZE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_msize(arg1: *mut ::std::os::raw::c_void) -> sqlite3_uint64 { - let fun = __SQLITE3_MSIZE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_MSIZE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void) -> sqlite3_uint64 = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_REALLOC64: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - arg2: sqlite3_uint64, - ) -> *mut ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_REALLOC64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_realloc64( arg1: *mut ::std::os::raw::c_void, arg2: sqlite3_uint64, ) -> *mut ::std::os::raw::c_void { - let fun = __SQLITE3_REALLOC64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_REALLOC64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: sqlite3_uint64, + ) -> *mut ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_RESET_AUTO_EXTENSION: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESET_AUTO_EXTENSION: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_reset_auto_extension() { - let fun = __SQLITE3_RESET_AUTO_EXTENSION - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESET_AUTO_EXTENSION + .load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn() = ::std::mem::transmute(ptr); (fun)() } -static __SQLITE3_RESULT_BLOB64: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: *const ::std::os::raw::c_void, - arg3: sqlite3_uint64, - arg4: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ), - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_BLOB64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_blob64( arg1: *mut sqlite3_context, arg2: *const ::std::os::raw::c_void, arg3: sqlite3_uint64, arg4: ::std::option::Option, ) { - let fun = __SQLITE3_RESULT_BLOB64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_BLOB64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: sqlite3_uint64, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_RESULT_TEXT64: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: *const ::std::os::raw::c_char, - arg3: sqlite3_uint64, - arg4: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - arg5: ::std::os::raw::c_uchar, - ), - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_TEXT64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_text64( arg1: *mut sqlite3_context, arg2: *const ::std::os::raw::c_char, @@ -5964,192 +5884,185 @@ pub unsafe fn sqlite3_result_text64( arg4: ::std::option::Option, arg5: ::std::os::raw::c_uchar, ) { - let fun = __SQLITE3_RESULT_TEXT64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_TEXT64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_char, + arg3: sqlite3_uint64, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + arg5: ::std::os::raw::c_uchar, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5) } -static __SQLITE3_STRGLOB: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *const ::std::os::raw::c_char, - arg2: *const ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_STRGLOB: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_strglob( arg1: *const ::std::os::raw::c_char, arg2: *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_STRGLOB - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_STRGLOB.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_VALUE_DUP: ::atomic::Atomic< - Option *mut sqlite3_value>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_DUP: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_dup(arg1: *const sqlite3_value) -> *mut sqlite3_value { - let fun = __SQLITE3_VALUE_DUP - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_DUP.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *const sqlite3_value) -> *mut sqlite3_value = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_VALUE_FREE: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_FREE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_free(arg1: *mut sqlite3_value) { - let fun = __SQLITE3_VALUE_FREE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_FREE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_value) = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_RESULT_ZEROBLOB64: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: sqlite3_uint64, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_ZEROBLOB64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_zeroblob64( arg1: *mut sqlite3_context, arg2: sqlite3_uint64, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_RESULT_ZEROBLOB64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_ZEROBLOB64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: sqlite3_uint64, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_BIND_ZEROBLOB64: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - arg3: sqlite3_uint64, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BIND_ZEROBLOB64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_bind_zeroblob64( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, arg3: sqlite3_uint64, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BIND_ZEROBLOB64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BIND_ZEROBLOB64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: sqlite3_uint64, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_VALUE_SUBTYPE: ::atomic::Atomic< - Option ::std::os::raw::c_uint>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_SUBTYPE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_subtype(arg1: *mut sqlite3_value) -> ::std::os::raw::c_uint { - let fun = __SQLITE3_VALUE_SUBTYPE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_SUBTYPE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_value) -> ::std::os::raw::c_uint = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_RESULT_SUBTYPE: ::atomic::Atomic< - Option< - unsafe extern "C" fn(arg1: *mut sqlite3_context, arg2: ::std::os::raw::c_uint), - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_SUBTYPE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_subtype( arg1: *mut sqlite3_context, arg2: ::std::os::raw::c_uint, ) { - let fun = __SQLITE3_RESULT_SUBTYPE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_SUBTYPE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_uint, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_STATUS64: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: ::std::os::raw::c_int, - arg2: *mut sqlite3_int64, - arg3: *mut sqlite3_int64, - arg4: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_STATUS64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_status64( arg1: ::std::os::raw::c_int, arg2: *mut sqlite3_int64, arg3: *mut sqlite3_int64, arg4: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_STATUS64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_STATUS64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + arg2: *mut sqlite3_int64, + arg3: *mut sqlite3_int64, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_STRLIKE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *const ::std::os::raw::c_char, - arg2: *const ::std::os::raw::c_char, - arg3: ::std::os::raw::c_uint, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_STRLIKE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_strlike( arg1: *const ::std::os::raw::c_char, arg2: *const ::std::os::raw::c_char, arg3: ::std::os::raw::c_uint, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_STRLIKE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_STRLIKE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_uint, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_DB_CACHEFLUSH: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_DB_CACHEFLUSH: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_db_cacheflush(arg1: *mut sqlite3) -> ::std::os::raw::c_int { - let fun = __SQLITE3_DB_CACHEFLUSH - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_DB_CACHEFLUSH.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_SYSTEM_ERRNO: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_SYSTEM_ERRNO: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_system_errno(arg1: *mut sqlite3) -> ::std::os::raw::c_int { - let fun = __SQLITE3_SYSTEM_ERRNO - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_SYSTEM_ERRNO.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_TRACE_V2: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: ::std::os::raw::c_uint, - arg3: ::std::option::Option< - unsafe extern "C" fn( - arg1: ::std::os::raw::c_uint, - arg2: *mut ::std::os::raw::c_void, - arg3: *mut ::std::os::raw::c_void, - arg4: *mut ::std::os::raw::c_void, - ) -> ::std::os::raw::c_int, - >, - arg4: *mut ::std::os::raw::c_void, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_TRACE_V2: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_trace_v2( arg1: *mut sqlite3, arg2: ::std::os::raw::c_uint, @@ -6163,21 +6076,35 @@ pub unsafe fn sqlite3_trace_v2( >, arg4: *mut ::std::os::raw::c_void, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_TRACE_V2 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_TRACE_V2.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_uint, + arg3: ::std::option::Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_uint, + arg2: *mut ::std::os::raw::c_void, + arg3: *mut ::std::os::raw::c_void, + arg4: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + arg4: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_EXPANDED_SQL: ::atomic::Atomic< - Option *mut ::std::os::raw::c_char>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_EXPANDED_SQL: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_expanded_sql( arg1: *mut sqlite3_stmt, ) -> *mut ::std::os::raw::c_char { - let fun = __SQLITE3_EXPANDED_SQL - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_EXPANDED_SQL.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + ) -> *mut ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1) } @@ -6185,7 +6112,10 @@ pub unsafe fn sqlite3_expanded_sql( pub unsafe fn rusqlite_extension_init2( p_api: *mut sqlite3_api_routines, ) -> ::std::result::Result<(), crate::InitError> { - __SQLITE3_MALLOC.store((*p_api).malloc, ::atomic::Ordering::Release); + if let Some(fun) = (*p_api).malloc { + __SQLITE3_MALLOC + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } if let Some(fun) = (*p_api).libversion_number { let version = fun(); if SQLITE_VERSION_NUMBER > version { @@ -6197,263 +6127,830 @@ pub unsafe fn rusqlite_extension_init2( } else { return Err(crate::InitError::NullFunctionPointer); } - __SQLITE3_AGGREGATE_CONTEXT - .store((*p_api).aggregate_context, ::atomic::Ordering::Release); - __SQLITE3_BIND_BLOB.store((*p_api).bind_blob, ::atomic::Ordering::Release); - __SQLITE3_BIND_DOUBLE.store((*p_api).bind_double, ::atomic::Ordering::Release); - __SQLITE3_BIND_INT.store((*p_api).bind_int, ::atomic::Ordering::Release); - __SQLITE3_BIND_INT64.store((*p_api).bind_int64, ::atomic::Ordering::Release); - __SQLITE3_BIND_NULL.store((*p_api).bind_null, ::atomic::Ordering::Release); - __SQLITE3_BIND_PARAMETER_COUNT - .store((*p_api).bind_parameter_count, ::atomic::Ordering::Release); - __SQLITE3_BIND_PARAMETER_INDEX - .store((*p_api).bind_parameter_index, ::atomic::Ordering::Release); - __SQLITE3_BIND_PARAMETER_NAME - .store((*p_api).bind_parameter_name, ::atomic::Ordering::Release); - __SQLITE3_BIND_TEXT.store((*p_api).bind_text, ::atomic::Ordering::Release); - __SQLITE3_BIND_TEXT16.store((*p_api).bind_text16, ::atomic::Ordering::Release); - __SQLITE3_BIND_VALUE.store((*p_api).bind_value, ::atomic::Ordering::Release); - __SQLITE3_BUSY_HANDLER.store((*p_api).busy_handler, ::atomic::Ordering::Release); - __SQLITE3_BUSY_TIMEOUT.store((*p_api).busy_timeout, ::atomic::Ordering::Release); - __SQLITE3_CHANGES.store((*p_api).changes, ::atomic::Ordering::Release); - __SQLITE3_CLOSE.store((*p_api).close, ::atomic::Ordering::Release); - __SQLITE3_COLLATION_NEEDED - .store((*p_api).collation_needed, ::atomic::Ordering::Release); - __SQLITE3_COLLATION_NEEDED16 - .store((*p_api).collation_needed16, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_BLOB.store((*p_api).column_blob, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_BYTES.store((*p_api).column_bytes, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_BYTES16.store((*p_api).column_bytes16, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_COUNT.store((*p_api).column_count, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_DATABASE_NAME - .store((*p_api).column_database_name, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_DATABASE_NAME16 - .store((*p_api).column_database_name16, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_DECLTYPE - .store((*p_api).column_decltype, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_DECLTYPE16 - .store((*p_api).column_decltype16, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_DOUBLE.store((*p_api).column_double, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_INT.store((*p_api).column_int, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_INT64.store((*p_api).column_int64, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_NAME.store((*p_api).column_name, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_NAME16.store((*p_api).column_name16, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_ORIGIN_NAME - .store((*p_api).column_origin_name, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_ORIGIN_NAME16 - .store((*p_api).column_origin_name16, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_TABLE_NAME - .store((*p_api).column_table_name, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_TABLE_NAME16 - .store((*p_api).column_table_name16, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_TEXT.store((*p_api).column_text, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_TEXT16.store((*p_api).column_text16, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_TYPE.store((*p_api).column_type, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_VALUE.store((*p_api).column_value, ::atomic::Ordering::Release); - __SQLITE3_COMMIT_HOOK.store((*p_api).commit_hook, ::atomic::Ordering::Release); - __SQLITE3_COMPLETE.store((*p_api).complete, ::atomic::Ordering::Release); - __SQLITE3_COMPLETE16.store((*p_api).complete16, ::atomic::Ordering::Release); - __SQLITE3_CREATE_COLLATION - .store((*p_api).create_collation, ::atomic::Ordering::Release); - __SQLITE3_CREATE_COLLATION16 - .store((*p_api).create_collation16, ::atomic::Ordering::Release); - __SQLITE3_CREATE_FUNCTION - .store((*p_api).create_function, ::atomic::Ordering::Release); - __SQLITE3_CREATE_FUNCTION16 - .store((*p_api).create_function16, ::atomic::Ordering::Release); - __SQLITE3_CREATE_MODULE.store((*p_api).create_module, ::atomic::Ordering::Release); - __SQLITE3_DATA_COUNT.store((*p_api).data_count, ::atomic::Ordering::Release); - __SQLITE3_DB_HANDLE.store((*p_api).db_handle, ::atomic::Ordering::Release); - __SQLITE3_DECLARE_VTAB.store((*p_api).declare_vtab, ::atomic::Ordering::Release); - __SQLITE3_ENABLE_SHARED_CACHE - .store((*p_api).enable_shared_cache, ::atomic::Ordering::Release); - __SQLITE3_ERRCODE.store((*p_api).errcode, ::atomic::Ordering::Release); - __SQLITE3_ERRMSG.store((*p_api).errmsg, ::atomic::Ordering::Release); - __SQLITE3_ERRMSG16.store((*p_api).errmsg16, ::atomic::Ordering::Release); - __SQLITE3_EXEC.store((*p_api).exec, ::atomic::Ordering::Release); - __SQLITE3_FINALIZE.store((*p_api).finalize, ::atomic::Ordering::Release); - __SQLITE3_FREE.store((*p_api).free, ::atomic::Ordering::Release); - __SQLITE3_FREE_TABLE.store((*p_api).free_table, ::atomic::Ordering::Release); - __SQLITE3_GET_AUTOCOMMIT.store((*p_api).get_autocommit, ::atomic::Ordering::Release); - __SQLITE3_GET_AUXDATA.store((*p_api).get_auxdata, ::atomic::Ordering::Release); - __SQLITE3_GET_TABLE.store((*p_api).get_table, ::atomic::Ordering::Release); - __SQLITE3_INTERRUPT.store((*p_api).interruptx, ::atomic::Ordering::Release); - __SQLITE3_LAST_INSERT_ROWID - .store((*p_api).last_insert_rowid, ::atomic::Ordering::Release); - __SQLITE3_LIBVERSION.store((*p_api).libversion, ::atomic::Ordering::Release); - __SQLITE3_LIBVERSION_NUMBER - .store((*p_api).libversion_number, ::atomic::Ordering::Release); - __SQLITE3_OPEN.store((*p_api).open, ::atomic::Ordering::Release); - __SQLITE3_OPEN16.store((*p_api).open16, ::atomic::Ordering::Release); - __SQLITE3_PREPARE.store((*p_api).prepare, ::atomic::Ordering::Release); - __SQLITE3_PREPARE16.store((*p_api).prepare16, ::atomic::Ordering::Release); - __SQLITE3_PROFILE.store((*p_api).profile, ::atomic::Ordering::Release); - __SQLITE3_PROGRESS_HANDLER - .store((*p_api).progress_handler, ::atomic::Ordering::Release); - __SQLITE3_REALLOC.store((*p_api).realloc, ::atomic::Ordering::Release); - __SQLITE3_RESET.store((*p_api).reset, ::atomic::Ordering::Release); - __SQLITE3_RESULT_BLOB.store((*p_api).result_blob, ::atomic::Ordering::Release); - __SQLITE3_RESULT_DOUBLE.store((*p_api).result_double, ::atomic::Ordering::Release); - __SQLITE3_RESULT_ERROR.store((*p_api).result_error, ::atomic::Ordering::Release); - __SQLITE3_RESULT_ERROR16.store((*p_api).result_error16, ::atomic::Ordering::Release); - __SQLITE3_RESULT_INT.store((*p_api).result_int, ::atomic::Ordering::Release); - __SQLITE3_RESULT_INT64.store((*p_api).result_int64, ::atomic::Ordering::Release); - __SQLITE3_RESULT_NULL.store((*p_api).result_null, ::atomic::Ordering::Release); - __SQLITE3_RESULT_TEXT.store((*p_api).result_text, ::atomic::Ordering::Release); - __SQLITE3_RESULT_TEXT16.store((*p_api).result_text16, ::atomic::Ordering::Release); - __SQLITE3_RESULT_TEXT16BE - .store((*p_api).result_text16be, ::atomic::Ordering::Release); - __SQLITE3_RESULT_TEXT16LE - .store((*p_api).result_text16le, ::atomic::Ordering::Release); - __SQLITE3_RESULT_VALUE.store((*p_api).result_value, ::atomic::Ordering::Release); - __SQLITE3_ROLLBACK_HOOK.store((*p_api).rollback_hook, ::atomic::Ordering::Release); - __SQLITE3_SET_AUTHORIZER.store((*p_api).set_authorizer, ::atomic::Ordering::Release); - __SQLITE3_SET_AUXDATA.store((*p_api).set_auxdata, ::atomic::Ordering::Release); - __SQLITE3_STEP.store((*p_api).step, ::atomic::Ordering::Release); - __SQLITE3_TABLE_COLUMN_METADATA - .store((*p_api).table_column_metadata, ::atomic::Ordering::Release); - __SQLITE3_TOTAL_CHANGES.store((*p_api).total_changes, ::atomic::Ordering::Release); - __SQLITE3_TRACE.store((*p_api).trace, ::atomic::Ordering::Release); - __SQLITE3_UPDATE_HOOK.store((*p_api).update_hook, ::atomic::Ordering::Release); - __SQLITE3_USER_DATA.store((*p_api).user_data, ::atomic::Ordering::Release); - __SQLITE3_VALUE_BLOB.store((*p_api).value_blob, ::atomic::Ordering::Release); - __SQLITE3_VALUE_BYTES.store((*p_api).value_bytes, ::atomic::Ordering::Release); - __SQLITE3_VALUE_BYTES16.store((*p_api).value_bytes16, ::atomic::Ordering::Release); - __SQLITE3_VALUE_DOUBLE.store((*p_api).value_double, ::atomic::Ordering::Release); - __SQLITE3_VALUE_INT.store((*p_api).value_int, ::atomic::Ordering::Release); - __SQLITE3_VALUE_INT64.store((*p_api).value_int64, ::atomic::Ordering::Release); - __SQLITE3_VALUE_NUMERIC_TYPE - .store((*p_api).value_numeric_type, ::atomic::Ordering::Release); - __SQLITE3_VALUE_TEXT.store((*p_api).value_text, ::atomic::Ordering::Release); - __SQLITE3_VALUE_TEXT16.store((*p_api).value_text16, ::atomic::Ordering::Release); - __SQLITE3_VALUE_TEXT16BE.store((*p_api).value_text16be, ::atomic::Ordering::Release); - __SQLITE3_VALUE_TEXT16LE.store((*p_api).value_text16le, ::atomic::Ordering::Release); - __SQLITE3_VALUE_TYPE.store((*p_api).value_type, ::atomic::Ordering::Release); - __SQLITE3_OVERLOAD_FUNCTION - .store((*p_api).overload_function, ::atomic::Ordering::Release); - __SQLITE3_PREPARE_V2.store((*p_api).prepare_v2, ::atomic::Ordering::Release); - __SQLITE3_PREPARE16_V2.store((*p_api).prepare16_v2, ::atomic::Ordering::Release); - __SQLITE3_CLEAR_BINDINGS.store((*p_api).clear_bindings, ::atomic::Ordering::Release); - __SQLITE3_CREATE_MODULE_V2 - .store((*p_api).create_module_v2, ::atomic::Ordering::Release); - __SQLITE3_BIND_ZEROBLOB.store((*p_api).bind_zeroblob, ::atomic::Ordering::Release); - __SQLITE3_BLOB_BYTES.store((*p_api).blob_bytes, ::atomic::Ordering::Release); - __SQLITE3_BLOB_CLOSE.store((*p_api).blob_close, ::atomic::Ordering::Release); - __SQLITE3_BLOB_OPEN.store((*p_api).blob_open, ::atomic::Ordering::Release); - __SQLITE3_BLOB_READ.store((*p_api).blob_read, ::atomic::Ordering::Release); - __SQLITE3_BLOB_WRITE.store((*p_api).blob_write, ::atomic::Ordering::Release); - __SQLITE3_CREATE_COLLATION_V2 - .store((*p_api).create_collation_v2, ::atomic::Ordering::Release); - __SQLITE3_FILE_CONTROL.store((*p_api).file_control, ::atomic::Ordering::Release); - __SQLITE3_MEMORY_HIGHWATER - .store((*p_api).memory_highwater, ::atomic::Ordering::Release); - __SQLITE3_MEMORY_USED.store((*p_api).memory_used, ::atomic::Ordering::Release); - __SQLITE3_MUTEX_ALLOC.store((*p_api).mutex_alloc, ::atomic::Ordering::Release); - __SQLITE3_MUTEX_ENTER.store((*p_api).mutex_enter, ::atomic::Ordering::Release); - __SQLITE3_MUTEX_FREE.store((*p_api).mutex_free, ::atomic::Ordering::Release); - __SQLITE3_MUTEX_LEAVE.store((*p_api).mutex_leave, ::atomic::Ordering::Release); - __SQLITE3_MUTEX_TRY.store((*p_api).mutex_try, ::atomic::Ordering::Release); - __SQLITE3_OPEN_V2.store((*p_api).open_v2, ::atomic::Ordering::Release); - __SQLITE3_RELEASE_MEMORY.store((*p_api).release_memory, ::atomic::Ordering::Release); - __SQLITE3_RESULT_ERROR_NOMEM - .store((*p_api).result_error_nomem, ::atomic::Ordering::Release); - __SQLITE3_RESULT_ERROR_TOOBIG - .store((*p_api).result_error_toobig, ::atomic::Ordering::Release); - __SQLITE3_SLEEP.store((*p_api).sleep, ::atomic::Ordering::Release); - __SQLITE3_SOFT_HEAP_LIMIT - .store((*p_api).soft_heap_limit, ::atomic::Ordering::Release); - __SQLITE3_VFS_FIND.store((*p_api).vfs_find, ::atomic::Ordering::Release); - __SQLITE3_VFS_REGISTER.store((*p_api).vfs_register, ::atomic::Ordering::Release); - __SQLITE3_VFS_UNREGISTER.store((*p_api).vfs_unregister, ::atomic::Ordering::Release); - __SQLITE3_THREADSAFE.store((*p_api).xthreadsafe, ::atomic::Ordering::Release); - __SQLITE3_RESULT_ZEROBLOB - .store((*p_api).result_zeroblob, ::atomic::Ordering::Release); - __SQLITE3_RESULT_ERROR_CODE - .store((*p_api).result_error_code, ::atomic::Ordering::Release); - __SQLITE3_RANDOMNESS.store((*p_api).randomness, ::atomic::Ordering::Release); - __SQLITE3_CONTEXT_DB_HANDLE - .store((*p_api).context_db_handle, ::atomic::Ordering::Release); - __SQLITE3_EXTENDED_RESULT_CODES - .store((*p_api).extended_result_codes, ::atomic::Ordering::Release); - __SQLITE3_LIMIT.store((*p_api).limit, ::atomic::Ordering::Release); - __SQLITE3_NEXT_STMT.store((*p_api).next_stmt, ::atomic::Ordering::Release); - __SQLITE3_SQL.store((*p_api).sql, ::atomic::Ordering::Release); - __SQLITE3_STATUS.store((*p_api).status, ::atomic::Ordering::Release); - __SQLITE3_BACKUP_FINISH.store((*p_api).backup_finish, ::atomic::Ordering::Release); - __SQLITE3_BACKUP_INIT.store((*p_api).backup_init, ::atomic::Ordering::Release); - __SQLITE3_BACKUP_PAGECOUNT - .store((*p_api).backup_pagecount, ::atomic::Ordering::Release); - __SQLITE3_BACKUP_REMAINING - .store((*p_api).backup_remaining, ::atomic::Ordering::Release); - __SQLITE3_BACKUP_STEP.store((*p_api).backup_step, ::atomic::Ordering::Release); - __SQLITE3_COMPILEOPTION_GET - .store((*p_api).compileoption_get, ::atomic::Ordering::Release); - __SQLITE3_COMPILEOPTION_USED - .store((*p_api).compileoption_used, ::atomic::Ordering::Release); - __SQLITE3_CREATE_FUNCTION_V2 - .store((*p_api).create_function_v2, ::atomic::Ordering::Release); - __SQLITE3_DB_CONFIG.store((*p_api).db_config, ::atomic::Ordering::Release); - __SQLITE3_DB_MUTEX.store((*p_api).db_mutex, ::atomic::Ordering::Release); - __SQLITE3_DB_STATUS.store((*p_api).db_status, ::atomic::Ordering::Release); - __SQLITE3_EXTENDED_ERRCODE - .store((*p_api).extended_errcode, ::atomic::Ordering::Release); - __SQLITE3_LOG.store((*p_api).log, ::atomic::Ordering::Release); - __SQLITE3_SOFT_HEAP_LIMIT64 - .store((*p_api).soft_heap_limit64, ::atomic::Ordering::Release); - __SQLITE3_SOURCEID.store((*p_api).sourceid, ::atomic::Ordering::Release); - __SQLITE3_STMT_STATUS.store((*p_api).stmt_status, ::atomic::Ordering::Release); - __SQLITE3_STRNICMP.store((*p_api).strnicmp, ::atomic::Ordering::Release); - __SQLITE3_UNLOCK_NOTIFY.store((*p_api).unlock_notify, ::atomic::Ordering::Release); - __SQLITE3_WAL_AUTOCHECKPOINT - .store((*p_api).wal_autocheckpoint, ::atomic::Ordering::Release); - __SQLITE3_WAL_CHECKPOINT.store((*p_api).wal_checkpoint, ::atomic::Ordering::Release); - __SQLITE3_WAL_HOOK.store((*p_api).wal_hook, ::atomic::Ordering::Release); - __SQLITE3_BLOB_REOPEN.store((*p_api).blob_reopen, ::atomic::Ordering::Release); - __SQLITE3_VTAB_CONFIG.store((*p_api).vtab_config, ::atomic::Ordering::Release); - __SQLITE3_VTAB_ON_CONFLICT - .store((*p_api).vtab_on_conflict, ::atomic::Ordering::Release); - __SQLITE3_CLOSE_V2.store((*p_api).close_v2, ::atomic::Ordering::Release); - __SQLITE3_DB_FILENAME.store((*p_api).db_filename, ::atomic::Ordering::Release); - __SQLITE3_DB_READONLY.store((*p_api).db_readonly, ::atomic::Ordering::Release); - __SQLITE3_DB_RELEASE_MEMORY - .store((*p_api).db_release_memory, ::atomic::Ordering::Release); - __SQLITE3_ERRSTR.store((*p_api).errstr, ::atomic::Ordering::Release); - __SQLITE3_STMT_BUSY.store((*p_api).stmt_busy, ::atomic::Ordering::Release); - __SQLITE3_STMT_READONLY.store((*p_api).stmt_readonly, ::atomic::Ordering::Release); - __SQLITE3_STRICMP.store((*p_api).stricmp, ::atomic::Ordering::Release); - __SQLITE3_URI_BOOLEAN.store((*p_api).uri_boolean, ::atomic::Ordering::Release); - __SQLITE3_URI_INT64.store((*p_api).uri_int64, ::atomic::Ordering::Release); - __SQLITE3_URI_PARAMETER.store((*p_api).uri_parameter, ::atomic::Ordering::Release); - __SQLITE3_WAL_CHECKPOINT_V2 - .store((*p_api).wal_checkpoint_v2, ::atomic::Ordering::Release); - __SQLITE3_AUTO_EXTENSION.store((*p_api).auto_extension, ::atomic::Ordering::Release); - __SQLITE3_BIND_BLOB64.store((*p_api).bind_blob64, ::atomic::Ordering::Release); - __SQLITE3_BIND_TEXT64.store((*p_api).bind_text64, ::atomic::Ordering::Release); - __SQLITE3_CANCEL_AUTO_EXTENSION - .store((*p_api).cancel_auto_extension, ::atomic::Ordering::Release); - __SQLITE3_LOAD_EXTENSION.store((*p_api).load_extension, ::atomic::Ordering::Release); - __SQLITE3_MALLOC64.store((*p_api).malloc64, ::atomic::Ordering::Release); - __SQLITE3_MSIZE.store((*p_api).msize, ::atomic::Ordering::Release); - __SQLITE3_REALLOC64.store((*p_api).realloc64, ::atomic::Ordering::Release); - __SQLITE3_RESET_AUTO_EXTENSION - .store((*p_api).reset_auto_extension, ::atomic::Ordering::Release); - __SQLITE3_RESULT_BLOB64.store((*p_api).result_blob64, ::atomic::Ordering::Release); - __SQLITE3_RESULT_TEXT64.store((*p_api).result_text64, ::atomic::Ordering::Release); - __SQLITE3_STRGLOB.store((*p_api).strglob, ::atomic::Ordering::Release); - __SQLITE3_VALUE_DUP.store((*p_api).value_dup, ::atomic::Ordering::Release); - __SQLITE3_VALUE_FREE.store((*p_api).value_free, ::atomic::Ordering::Release); - __SQLITE3_RESULT_ZEROBLOB64 - .store((*p_api).result_zeroblob64, ::atomic::Ordering::Release); - __SQLITE3_BIND_ZEROBLOB64 - .store((*p_api).bind_zeroblob64, ::atomic::Ordering::Release); - __SQLITE3_VALUE_SUBTYPE.store((*p_api).value_subtype, ::atomic::Ordering::Release); - __SQLITE3_RESULT_SUBTYPE.store((*p_api).result_subtype, ::atomic::Ordering::Release); - __SQLITE3_STATUS64.store((*p_api).status64, ::atomic::Ordering::Release); - __SQLITE3_STRLIKE.store((*p_api).strlike, ::atomic::Ordering::Release); - __SQLITE3_DB_CACHEFLUSH.store((*p_api).db_cacheflush, ::atomic::Ordering::Release); - __SQLITE3_SYSTEM_ERRNO.store((*p_api).system_errno, ::atomic::Ordering::Release); - __SQLITE3_TRACE_V2.store((*p_api).trace_v2, ::atomic::Ordering::Release); - __SQLITE3_EXPANDED_SQL.store((*p_api).expanded_sql, ::atomic::Ordering::Release); + if let Some(fun) = (*p_api).aggregate_context { + __SQLITE3_AGGREGATE_CONTEXT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).bind_blob { + __SQLITE3_BIND_BLOB + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).bind_double { + __SQLITE3_BIND_DOUBLE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).bind_int { + __SQLITE3_BIND_INT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).bind_int64 { + __SQLITE3_BIND_INT64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).bind_null { + __SQLITE3_BIND_NULL + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).bind_parameter_count { + __SQLITE3_BIND_PARAMETER_COUNT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).bind_parameter_index { + __SQLITE3_BIND_PARAMETER_INDEX + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).bind_parameter_name { + __SQLITE3_BIND_PARAMETER_NAME + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).bind_text { + __SQLITE3_BIND_TEXT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).bind_text16 { + __SQLITE3_BIND_TEXT16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).bind_value { + __SQLITE3_BIND_VALUE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).busy_handler { + __SQLITE3_BUSY_HANDLER + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).busy_timeout { + __SQLITE3_BUSY_TIMEOUT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).changes { + __SQLITE3_CHANGES + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).close { + __SQLITE3_CLOSE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).collation_needed { + __SQLITE3_COLLATION_NEEDED + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).collation_needed16 { + __SQLITE3_COLLATION_NEEDED16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_blob { + __SQLITE3_COLUMN_BLOB + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_bytes { + __SQLITE3_COLUMN_BYTES + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_bytes16 { + __SQLITE3_COLUMN_BYTES16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_count { + __SQLITE3_COLUMN_COUNT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_database_name { + __SQLITE3_COLUMN_DATABASE_NAME + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_database_name16 { + __SQLITE3_COLUMN_DATABASE_NAME16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_decltype { + __SQLITE3_COLUMN_DECLTYPE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_decltype16 { + __SQLITE3_COLUMN_DECLTYPE16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_double { + __SQLITE3_COLUMN_DOUBLE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_int { + __SQLITE3_COLUMN_INT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_int64 { + __SQLITE3_COLUMN_INT64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_name { + __SQLITE3_COLUMN_NAME + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_name16 { + __SQLITE3_COLUMN_NAME16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_origin_name { + __SQLITE3_COLUMN_ORIGIN_NAME + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_origin_name16 { + __SQLITE3_COLUMN_ORIGIN_NAME16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_table_name { + __SQLITE3_COLUMN_TABLE_NAME + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_table_name16 { + __SQLITE3_COLUMN_TABLE_NAME16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_text { + __SQLITE3_COLUMN_TEXT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_text16 { + __SQLITE3_COLUMN_TEXT16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_type { + __SQLITE3_COLUMN_TYPE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_value { + __SQLITE3_COLUMN_VALUE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).commit_hook { + __SQLITE3_COMMIT_HOOK + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).complete { + __SQLITE3_COMPLETE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).complete16 { + __SQLITE3_COMPLETE16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).create_collation { + __SQLITE3_CREATE_COLLATION + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).create_collation16 { + __SQLITE3_CREATE_COLLATION16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).create_function { + __SQLITE3_CREATE_FUNCTION + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).create_function16 { + __SQLITE3_CREATE_FUNCTION16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).create_module { + __SQLITE3_CREATE_MODULE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).data_count { + __SQLITE3_DATA_COUNT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).db_handle { + __SQLITE3_DB_HANDLE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).declare_vtab { + __SQLITE3_DECLARE_VTAB + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).enable_shared_cache { + __SQLITE3_ENABLE_SHARED_CACHE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).errcode { + __SQLITE3_ERRCODE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).errmsg { + __SQLITE3_ERRMSG + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).errmsg16 { + __SQLITE3_ERRMSG16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).exec { + __SQLITE3_EXEC + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).finalize { + __SQLITE3_FINALIZE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).free { + __SQLITE3_FREE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).free_table { + __SQLITE3_FREE_TABLE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).get_autocommit { + __SQLITE3_GET_AUTOCOMMIT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).get_auxdata { + __SQLITE3_GET_AUXDATA + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).get_table { + __SQLITE3_GET_TABLE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).interruptx { + __SQLITE3_INTERRUPT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).last_insert_rowid { + __SQLITE3_LAST_INSERT_ROWID + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).libversion { + __SQLITE3_LIBVERSION + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).libversion_number { + __SQLITE3_LIBVERSION_NUMBER + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).open { + __SQLITE3_OPEN + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).open16 { + __SQLITE3_OPEN16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).prepare { + __SQLITE3_PREPARE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).prepare16 { + __SQLITE3_PREPARE16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).profile { + __SQLITE3_PROFILE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).progress_handler { + __SQLITE3_PROGRESS_HANDLER + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).realloc { + __SQLITE3_REALLOC + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).reset { + __SQLITE3_RESET + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_blob { + __SQLITE3_RESULT_BLOB + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_double { + __SQLITE3_RESULT_DOUBLE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_error { + __SQLITE3_RESULT_ERROR + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_error16 { + __SQLITE3_RESULT_ERROR16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_int { + __SQLITE3_RESULT_INT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_int64 { + __SQLITE3_RESULT_INT64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_null { + __SQLITE3_RESULT_NULL + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_text { + __SQLITE3_RESULT_TEXT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_text16 { + __SQLITE3_RESULT_TEXT16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_text16be { + __SQLITE3_RESULT_TEXT16BE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_text16le { + __SQLITE3_RESULT_TEXT16LE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_value { + __SQLITE3_RESULT_VALUE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).rollback_hook { + __SQLITE3_ROLLBACK_HOOK + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).set_authorizer { + __SQLITE3_SET_AUTHORIZER + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).set_auxdata { + __SQLITE3_SET_AUXDATA + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).step { + __SQLITE3_STEP + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).table_column_metadata { + __SQLITE3_TABLE_COLUMN_METADATA + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).total_changes { + __SQLITE3_TOTAL_CHANGES + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).trace { + __SQLITE3_TRACE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).update_hook { + __SQLITE3_UPDATE_HOOK + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).user_data { + __SQLITE3_USER_DATA + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_blob { + __SQLITE3_VALUE_BLOB + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_bytes { + __SQLITE3_VALUE_BYTES + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_bytes16 { + __SQLITE3_VALUE_BYTES16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_double { + __SQLITE3_VALUE_DOUBLE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_int { + __SQLITE3_VALUE_INT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_int64 { + __SQLITE3_VALUE_INT64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_numeric_type { + __SQLITE3_VALUE_NUMERIC_TYPE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_text { + __SQLITE3_VALUE_TEXT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_text16 { + __SQLITE3_VALUE_TEXT16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_text16be { + __SQLITE3_VALUE_TEXT16BE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_text16le { + __SQLITE3_VALUE_TEXT16LE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_type { + __SQLITE3_VALUE_TYPE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).overload_function { + __SQLITE3_OVERLOAD_FUNCTION + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).prepare_v2 { + __SQLITE3_PREPARE_V2 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).prepare16_v2 { + __SQLITE3_PREPARE16_V2 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).clear_bindings { + __SQLITE3_CLEAR_BINDINGS + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).create_module_v2 { + __SQLITE3_CREATE_MODULE_V2 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).bind_zeroblob { + __SQLITE3_BIND_ZEROBLOB + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).blob_bytes { + __SQLITE3_BLOB_BYTES + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).blob_close { + __SQLITE3_BLOB_CLOSE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).blob_open { + __SQLITE3_BLOB_OPEN + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).blob_read { + __SQLITE3_BLOB_READ + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).blob_write { + __SQLITE3_BLOB_WRITE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).create_collation_v2 { + __SQLITE3_CREATE_COLLATION_V2 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).file_control { + __SQLITE3_FILE_CONTROL + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).memory_highwater { + __SQLITE3_MEMORY_HIGHWATER + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).memory_used { + __SQLITE3_MEMORY_USED + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).mutex_alloc { + __SQLITE3_MUTEX_ALLOC + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).mutex_enter { + __SQLITE3_MUTEX_ENTER + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).mutex_free { + __SQLITE3_MUTEX_FREE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).mutex_leave { + __SQLITE3_MUTEX_LEAVE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).mutex_try { + __SQLITE3_MUTEX_TRY + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).open_v2 { + __SQLITE3_OPEN_V2 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).release_memory { + __SQLITE3_RELEASE_MEMORY + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_error_nomem { + __SQLITE3_RESULT_ERROR_NOMEM + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_error_toobig { + __SQLITE3_RESULT_ERROR_TOOBIG + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).sleep { + __SQLITE3_SLEEP + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).soft_heap_limit { + __SQLITE3_SOFT_HEAP_LIMIT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).vfs_find { + __SQLITE3_VFS_FIND + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).vfs_register { + __SQLITE3_VFS_REGISTER + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).vfs_unregister { + __SQLITE3_VFS_UNREGISTER + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).xthreadsafe { + __SQLITE3_THREADSAFE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_zeroblob { + __SQLITE3_RESULT_ZEROBLOB + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_error_code { + __SQLITE3_RESULT_ERROR_CODE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).randomness { + __SQLITE3_RANDOMNESS + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).context_db_handle { + __SQLITE3_CONTEXT_DB_HANDLE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).extended_result_codes { + __SQLITE3_EXTENDED_RESULT_CODES + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).limit { + __SQLITE3_LIMIT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).next_stmt { + __SQLITE3_NEXT_STMT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).sql { + __SQLITE3_SQL + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).status { + __SQLITE3_STATUS + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).backup_finish { + __SQLITE3_BACKUP_FINISH + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).backup_init { + __SQLITE3_BACKUP_INIT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).backup_pagecount { + __SQLITE3_BACKUP_PAGECOUNT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).backup_remaining { + __SQLITE3_BACKUP_REMAINING + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).backup_step { + __SQLITE3_BACKUP_STEP + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).compileoption_get { + __SQLITE3_COMPILEOPTION_GET + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).compileoption_used { + __SQLITE3_COMPILEOPTION_USED + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).create_function_v2 { + __SQLITE3_CREATE_FUNCTION_V2 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).db_config { + __SQLITE3_DB_CONFIG + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).db_mutex { + __SQLITE3_DB_MUTEX + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).db_status { + __SQLITE3_DB_STATUS + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).extended_errcode { + __SQLITE3_EXTENDED_ERRCODE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).log { + __SQLITE3_LOG + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).soft_heap_limit64 { + __SQLITE3_SOFT_HEAP_LIMIT64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).sourceid { + __SQLITE3_SOURCEID + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).stmt_status { + __SQLITE3_STMT_STATUS + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).strnicmp { + __SQLITE3_STRNICMP + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).unlock_notify { + __SQLITE3_UNLOCK_NOTIFY + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).wal_autocheckpoint { + __SQLITE3_WAL_AUTOCHECKPOINT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).wal_checkpoint { + __SQLITE3_WAL_CHECKPOINT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).wal_hook { + __SQLITE3_WAL_HOOK + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).blob_reopen { + __SQLITE3_BLOB_REOPEN + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).vtab_config { + __SQLITE3_VTAB_CONFIG + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).vtab_on_conflict { + __SQLITE3_VTAB_ON_CONFLICT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).close_v2 { + __SQLITE3_CLOSE_V2 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).db_filename { + __SQLITE3_DB_FILENAME + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).db_readonly { + __SQLITE3_DB_READONLY + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).db_release_memory { + __SQLITE3_DB_RELEASE_MEMORY + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).errstr { + __SQLITE3_ERRSTR + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).stmt_busy { + __SQLITE3_STMT_BUSY + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).stmt_readonly { + __SQLITE3_STMT_READONLY + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).stricmp { + __SQLITE3_STRICMP + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).uri_boolean { + __SQLITE3_URI_BOOLEAN + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).uri_int64 { + __SQLITE3_URI_INT64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).uri_parameter { + __SQLITE3_URI_PARAMETER + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).vsnprintf { + __SQLITE3_VSNPRINTF + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).wal_checkpoint_v2 { + __SQLITE3_WAL_CHECKPOINT_V2 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).auto_extension { + __SQLITE3_AUTO_EXTENSION + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).bind_blob64 { + __SQLITE3_BIND_BLOB64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).bind_text64 { + __SQLITE3_BIND_TEXT64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).cancel_auto_extension { + __SQLITE3_CANCEL_AUTO_EXTENSION + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).load_extension { + __SQLITE3_LOAD_EXTENSION + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).malloc64 { + __SQLITE3_MALLOC64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).msize { + __SQLITE3_MSIZE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).realloc64 { + __SQLITE3_REALLOC64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).reset_auto_extension { + __SQLITE3_RESET_AUTO_EXTENSION + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_blob64 { + __SQLITE3_RESULT_BLOB64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_text64 { + __SQLITE3_RESULT_TEXT64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).strglob { + __SQLITE3_STRGLOB + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_dup { + __SQLITE3_VALUE_DUP + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_free { + __SQLITE3_VALUE_FREE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_zeroblob64 { + __SQLITE3_RESULT_ZEROBLOB64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).bind_zeroblob64 { + __SQLITE3_BIND_ZEROBLOB64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_subtype { + __SQLITE3_VALUE_SUBTYPE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_subtype { + __SQLITE3_RESULT_SUBTYPE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).status64 { + __SQLITE3_STATUS64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).strlike { + __SQLITE3_STRLIKE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).db_cacheflush { + __SQLITE3_DB_CACHEFLUSH + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).system_errno { + __SQLITE3_SYSTEM_ERRNO + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).trace_v2 { + __SQLITE3_TRACE_V2 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).expanded_sql { + __SQLITE3_EXPANDED_SQL + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } Ok(()) } diff --git a/libsqlite3-sys/build.rs b/libsqlite3-sys/build.rs index 6541e7d..cff173e 100644 --- a/libsqlite3-sys/build.rs +++ b/libsqlite3-sys/build.rs @@ -745,25 +745,31 @@ mod loadable_extension { let ty = &method.output; let tokens = if "db_config" == name { quote::quote! { - static #ptr_name: ::atomic::Atomic> = ::atomic::Atomic::new(None); + static #ptr_name: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new(::std::ptr::null_mut()); pub unsafe fn #sqlite3_fn_name(#args arg3: ::std::os::raw::c_int, arg4: *mut ::std::os::raw::c_int) #ty { - let fun = #ptr_name.load(::atomic::Ordering::Acquire).expect("SQLite API not initialized"); + let ptr = #ptr_name.load(::std::sync::atomic::Ordering::Acquire); + assert!(!ptr.is_null(), "SQLite API not initialized"); + let fun: unsafe extern "C" fn(#args #varargs) #ty = ::std::mem::transmute(ptr); (fun)(#arg_names, arg3, arg4) } } } else if "log" == name { quote::quote! { - static #ptr_name: ::atomic::Atomic> = ::atomic::Atomic::new(None); + static #ptr_name: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new(::std::ptr::null_mut()); pub unsafe fn #sqlite3_fn_name(#args arg3: *const ::std::os::raw::c_char) #ty { - let fun = #ptr_name.load(::atomic::Ordering::Acquire).expect("SQLite API not initialized"); + let ptr = #ptr_name.load(::std::sync::atomic::Ordering::Acquire); + assert!(!ptr.is_null(), "SQLite API not initialized"); + let fun: unsafe extern "C" fn(#args #varargs) #ty = ::std::mem::transmute(ptr); (fun)(#arg_names, arg3) } } } else { quote::quote! { - static #ptr_name: ::atomic::Atomic> = ::atomic::Atomic::new(None); + static #ptr_name: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new(::std::ptr::null_mut()); pub unsafe fn #sqlite3_fn_name(#args) #ty { - let fun = #ptr_name.load(::atomic::Ordering::Acquire).expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = #ptr_name.load(::std::sync::atomic::Ordering::Acquire); + assert!(!ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(#args #varargs) #ty = ::std::mem::transmute(ptr); (fun)(#arg_names) } } @@ -778,10 +784,12 @@ mod loadable_extension { &mut stores } .push(quote::quote! { - #ptr_name.store( - (*#p_api).#ident, - ::atomic::Ordering::Release, - ); + if let Some(fun) = (*#p_api).#ident { + #ptr_name.store( + fun as usize as *mut (), + ::std::sync::atomic::Ordering::Release, + ); + } }); } // (3) generate rust code similar to SQLITE_EXTENSION_INIT2 macro diff --git a/libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs b/libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs index f64ecd2..fdd6d5e 100644 --- a/libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs +++ b/libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs @@ -2904,37 +2904,25 @@ pub type sqlite3_loadext_entry = ::std::option::Option< pThunk: *const sqlite3_api_routines, ) -> ::std::os::raw::c_int, >; -static __SQLITE3_AGGREGATE_CONTEXT: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - nBytes: ::std::os::raw::c_int, - ) -> *mut ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_AGGREGATE_CONTEXT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_aggregate_context( arg1: *mut sqlite3_context, nBytes: ::std::os::raw::c_int, ) -> *mut ::std::os::raw::c_void { - let fun = __SQLITE3_AGGREGATE_CONTEXT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_AGGREGATE_CONTEXT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + nBytes: ::std::os::raw::c_int, + ) -> *mut ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, nBytes) } -static __SQLITE3_BIND_BLOB: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - arg3: *const ::std::os::raw::c_void, - n: ::std::os::raw::c_int, - arg4: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BIND_BLOB: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_bind_blob( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, @@ -2942,151 +2930,141 @@ pub unsafe fn sqlite3_bind_blob( n: ::std::os::raw::c_int, arg4: ::std::option::Option, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BIND_BLOB - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BIND_BLOB.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + n: ::std::os::raw::c_int, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, n, arg4) } -static __SQLITE3_BIND_DOUBLE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - arg3: f64, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BIND_DOUBLE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_bind_double( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, arg3: f64, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BIND_DOUBLE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BIND_DOUBLE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: f64, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_BIND_INT: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - arg3: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BIND_INT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_bind_int( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, arg3: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BIND_INT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BIND_INT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_BIND_INT64: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - arg3: sqlite_int64, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BIND_INT64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_bind_int64( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, arg3: sqlite_int64, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BIND_INT64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BIND_INT64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: sqlite_int64, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_BIND_NULL: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BIND_NULL: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_bind_null( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BIND_NULL - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BIND_NULL.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_BIND_PARAMETER_COUNT: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BIND_PARAMETER_COUNT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_bind_parameter_count( arg1: *mut sqlite3_stmt, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BIND_PARAMETER_COUNT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BIND_PARAMETER_COUNT + .load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_BIND_PARAMETER_INDEX: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - zName: *const ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BIND_PARAMETER_INDEX: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_bind_parameter_index( arg1: *mut sqlite3_stmt, zName: *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BIND_PARAMETER_INDEX - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BIND_PARAMETER_INDEX + .load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + zName: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, zName) } -static __SQLITE3_BIND_PARAMETER_NAME: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_char, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BIND_PARAMETER_NAME: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_bind_parameter_name( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_BIND_PARAMETER_NAME - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BIND_PARAMETER_NAME.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_BIND_TEXT: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - arg3: *const ::std::os::raw::c_char, - n: ::std::os::raw::c_int, - arg4: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BIND_TEXT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_bind_text( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, @@ -3094,25 +3072,23 @@ pub unsafe fn sqlite3_bind_text( n: ::std::os::raw::c_int, arg4: ::std::option::Option, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BIND_TEXT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BIND_TEXT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + n: ::std::os::raw::c_int, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, n, arg4) } -static __SQLITE3_BIND_TEXT16: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - arg3: *const ::std::os::raw::c_void, - arg4: ::std::os::raw::c_int, - arg5: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BIND_TEXT16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_bind_text16( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, @@ -3120,46 +3096,41 @@ pub unsafe fn sqlite3_bind_text16( arg4: ::std::os::raw::c_int, arg5: ::std::option::Option, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BIND_TEXT16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BIND_TEXT16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: ::std::os::raw::c_int, + arg5: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5) } -static __SQLITE3_BIND_VALUE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - arg3: *const sqlite3_value, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BIND_VALUE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_bind_value( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, arg3: *const sqlite3_value, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BIND_VALUE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BIND_VALUE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const sqlite3_value, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_BUSY_HANDLER: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - arg2: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, - arg3: *mut ::std::os::raw::c_void, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BUSY_HANDLER: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_busy_handler( arg1: *mut sqlite3, arg2: ::std::option::Option< @@ -3170,66 +3141,64 @@ pub unsafe fn sqlite3_busy_handler( >, arg3: *mut ::std::os::raw::c_void, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BUSY_HANDLER - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BUSY_HANDLER.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_BUSY_TIMEOUT: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - ms: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BUSY_TIMEOUT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_busy_timeout( arg1: *mut sqlite3, ms: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BUSY_TIMEOUT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BUSY_TIMEOUT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + ms: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, ms) } -static __SQLITE3_CHANGES: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_CHANGES: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_changes(arg1: *mut sqlite3) -> ::std::os::raw::c_int { - let fun = __SQLITE3_CHANGES - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_CHANGES.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_CLOSE: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_CLOSE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_close(arg1: *mut sqlite3) -> ::std::os::raw::c_int { - let fun = __SQLITE3_CLOSE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_CLOSE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_COLLATION_NEEDED: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *mut ::std::os::raw::c_void, - arg3: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - arg2: *mut sqlite3, - eTextRep: ::std::os::raw::c_int, - arg3: *const ::std::os::raw::c_char, - ), - >, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLLATION_NEEDED: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_collation_needed( arg1: *mut sqlite3, arg2: *mut ::std::os::raw::c_void, @@ -3242,28 +3211,26 @@ pub unsafe fn sqlite3_collation_needed( ), >, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_COLLATION_NEEDED - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLLATION_NEEDED.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *mut ::std::os::raw::c_void, + arg3: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut sqlite3, + eTextRep: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + ), + >, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_COLLATION_NEEDED16: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *mut ::std::os::raw::c_void, - arg3: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - arg2: *mut sqlite3, - eTextRep: ::std::os::raw::c_int, - arg3: *const ::std::os::raw::c_void, - ), - >, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLLATION_NEEDED16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_collation_needed16( arg1: *mut sqlite3, arg2: *mut ::std::os::raw::c_void, @@ -3276,392 +3243,361 @@ pub unsafe fn sqlite3_collation_needed16( ), >, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_COLLATION_NEEDED16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLLATION_NEEDED16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *mut ::std::os::raw::c_void, + arg3: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut sqlite3, + eTextRep: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + ), + >, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_COLUMN_BLOB: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - iCol: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_BLOB: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_blob( arg1: *mut sqlite3_stmt, iCol: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_void { - let fun = __SQLITE3_COLUMN_BLOB - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_BLOB.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, iCol) } -static __SQLITE3_COLUMN_BYTES: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - iCol: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_BYTES: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_bytes( arg1: *mut sqlite3_stmt, iCol: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_COLUMN_BYTES - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_BYTES.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, iCol) } -static __SQLITE3_COLUMN_BYTES16: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - iCol: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_BYTES16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_bytes16( arg1: *mut sqlite3_stmt, iCol: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_COLUMN_BYTES16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_BYTES16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, iCol) } -static __SQLITE3_COLUMN_COUNT: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_COUNT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_count(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int { - let fun = __SQLITE3_COLUMN_COUNT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_COUNT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(pStmt) } -static __SQLITE3_COLUMN_DATABASE_NAME: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_char, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_DATABASE_NAME: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_database_name( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_COLUMN_DATABASE_NAME - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_DATABASE_NAME + .load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_COLUMN_DATABASE_NAME16: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_DATABASE_NAME16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_database_name16( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_void { - let fun = __SQLITE3_COLUMN_DATABASE_NAME16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_DATABASE_NAME16 + .load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_COLUMN_DECLTYPE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - i: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_char, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_DECLTYPE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_decltype( arg1: *mut sqlite3_stmt, i: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_COLUMN_DECLTYPE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_DECLTYPE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + i: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1, i) } -static __SQLITE3_COLUMN_DECLTYPE16: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_DECLTYPE16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_decltype16( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_void { - let fun = __SQLITE3_COLUMN_DECLTYPE16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_DECLTYPE16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_COLUMN_DOUBLE: ::atomic::Atomic< - Option< - unsafe extern "C" fn(arg1: *mut sqlite3_stmt, iCol: ::std::os::raw::c_int) -> f64, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_DOUBLE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_double( arg1: *mut sqlite3_stmt, iCol: ::std::os::raw::c_int, ) -> f64 { - let fun = __SQLITE3_COLUMN_DOUBLE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_DOUBLE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> f64 = ::std::mem::transmute(ptr); (fun)(arg1, iCol) } -static __SQLITE3_COLUMN_INT: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - iCol: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_INT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_int( arg1: *mut sqlite3_stmt, iCol: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_COLUMN_INT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_INT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, iCol) } -static __SQLITE3_COLUMN_INT64: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - iCol: ::std::os::raw::c_int, - ) -> sqlite_int64, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_INT64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_int64( arg1: *mut sqlite3_stmt, iCol: ::std::os::raw::c_int, ) -> sqlite_int64 { - let fun = __SQLITE3_COLUMN_INT64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_INT64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> sqlite_int64 = ::std::mem::transmute(ptr); (fun)(arg1, iCol) } -static __SQLITE3_COLUMN_NAME: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_char, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_NAME: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_name( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_COLUMN_NAME - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_NAME.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_COLUMN_NAME16: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_NAME16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_name16( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_void { - let fun = __SQLITE3_COLUMN_NAME16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_NAME16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_COLUMN_ORIGIN_NAME: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_char, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_ORIGIN_NAME: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_origin_name( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_COLUMN_ORIGIN_NAME - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_ORIGIN_NAME.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_COLUMN_ORIGIN_NAME16: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_ORIGIN_NAME16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_origin_name16( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_void { - let fun = __SQLITE3_COLUMN_ORIGIN_NAME16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_ORIGIN_NAME16 + .load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_COLUMN_TABLE_NAME: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_char, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_TABLE_NAME: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_table_name( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_COLUMN_TABLE_NAME - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_TABLE_NAME.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_COLUMN_TABLE_NAME16: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_TABLE_NAME16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_table_name16( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_void { - let fun = __SQLITE3_COLUMN_TABLE_NAME16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_TABLE_NAME16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_COLUMN_TEXT: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - iCol: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_uchar, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_TEXT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_text( arg1: *mut sqlite3_stmt, iCol: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_uchar { - let fun = __SQLITE3_COLUMN_TEXT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_TEXT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_uchar = ::std::mem::transmute(ptr); (fun)(arg1, iCol) } -static __SQLITE3_COLUMN_TEXT16: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - iCol: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_TEXT16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_text16( arg1: *mut sqlite3_stmt, iCol: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_void { - let fun = __SQLITE3_COLUMN_TEXT16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_TEXT16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, iCol) } -static __SQLITE3_COLUMN_TYPE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - iCol: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_TYPE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_type( arg1: *mut sqlite3_stmt, iCol: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_COLUMN_TYPE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_TYPE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, iCol) } -static __SQLITE3_COLUMN_VALUE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - iCol: ::std::os::raw::c_int, - ) -> *mut sqlite3_value, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COLUMN_VALUE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_column_value( arg1: *mut sqlite3_stmt, iCol: ::std::os::raw::c_int, ) -> *mut sqlite3_value { - let fun = __SQLITE3_COLUMN_VALUE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COLUMN_VALUE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + iCol: ::std::os::raw::c_int, + ) -> *mut sqlite3_value = ::std::mem::transmute(ptr); (fun)(arg1, iCol) } -static __SQLITE3_COMMIT_HOOK: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - ) -> ::std::os::raw::c_int, - >, - arg3: *mut ::std::os::raw::c_void, - ) -> *mut ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COMMIT_HOOK: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_commit_hook( arg1: *mut sqlite3, arg2: ::std::option::Option< @@ -3669,59 +3605,51 @@ pub unsafe fn sqlite3_commit_hook( >, arg3: *mut ::std::os::raw::c_void, ) -> *mut ::std::os::raw::c_void { - let fun = __SQLITE3_COMMIT_HOOK - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COMMIT_HOOK.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_COMPLETE: ::atomic::Atomic< - Option< - unsafe extern "C" fn(sql: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COMPLETE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_complete( sql: *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_COMPLETE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COMPLETE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + sql: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(sql) } -static __SQLITE3_COMPLETE16: ::atomic::Atomic< - Option< - unsafe extern "C" fn(sql: *const ::std::os::raw::c_void) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COMPLETE16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_complete16( sql: *const ::std::os::raw::c_void, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_COMPLETE16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COMPLETE16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + sql: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(sql) } -static __SQLITE3_CREATE_COLLATION: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: ::std::os::raw::c_int, - arg4: *mut ::std::os::raw::c_void, - arg5: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - arg2: ::std::os::raw::c_int, - arg3: *const ::std::os::raw::c_void, - arg4: ::std::os::raw::c_int, - arg5: *const ::std::os::raw::c_void, - ) -> ::std::os::raw::c_int, - >, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_CREATE_COLLATION: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_create_collation( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, @@ -3737,31 +3665,29 @@ pub unsafe fn sqlite3_create_collation( ) -> ::std::os::raw::c_int, >, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_CREATE_COLLATION - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_CREATE_COLLATION.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, + arg5: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: ::std::os::raw::c_int, + arg5: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5) } -static __SQLITE3_CREATE_COLLATION16: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_void, - arg3: ::std::os::raw::c_int, - arg4: *mut ::std::os::raw::c_void, - arg5: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - arg2: ::std::os::raw::c_int, - arg3: *const ::std::os::raw::c_void, - arg4: ::std::os::raw::c_int, - arg5: *const ::std::os::raw::c_void, - ) -> ::std::os::raw::c_int, - >, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_CREATE_COLLATION16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_create_collation16( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_void, @@ -3777,40 +3703,29 @@ pub unsafe fn sqlite3_create_collation16( ) -> ::std::os::raw::c_int, >, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_CREATE_COLLATION16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_CREATE_COLLATION16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, + arg5: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: ::std::os::raw::c_int, + arg5: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5) } -static __SQLITE3_CREATE_FUNCTION: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: ::std::os::raw::c_int, - arg4: ::std::os::raw::c_int, - arg5: *mut ::std::os::raw::c_void, - xFunc: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: ::std::os::raw::c_int, - arg3: *mut *mut sqlite3_value, - ), - >, - xStep: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: ::std::os::raw::c_int, - arg3: *mut *mut sqlite3_value, - ), - >, - xFinal: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut sqlite3_context), - >, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_CREATE_FUNCTION: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_create_function( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, @@ -3833,40 +3748,36 @@ pub unsafe fn sqlite3_create_function( >, xFinal: ::std::option::Option, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_CREATE_FUNCTION - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_CREATE_FUNCTION.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_void, + xFunc: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xStep: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xFinal: ::std::option::Option, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5, xFunc, xStep, xFinal) } -static __SQLITE3_CREATE_FUNCTION16: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_void, - arg3: ::std::os::raw::c_int, - arg4: ::std::os::raw::c_int, - arg5: *mut ::std::os::raw::c_void, - xFunc: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: ::std::os::raw::c_int, - arg3: *mut *mut sqlite3_value, - ), - >, - xStep: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: ::std::os::raw::c_int, - arg3: *mut *mut sqlite3_value, - ), - >, - xFinal: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut sqlite3_context), - >, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_CREATE_FUNCTION16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_create_function16( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_void, @@ -3889,125 +3800,146 @@ pub unsafe fn sqlite3_create_function16( >, xFinal: ::std::option::Option, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_CREATE_FUNCTION16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_CREATE_FUNCTION16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_void, + xFunc: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xStep: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xFinal: ::std::option::Option, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5, xFunc, xStep, xFinal) } -static __SQLITE3_CREATE_MODULE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: *const sqlite3_module, - arg4: *mut ::std::os::raw::c_void, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_CREATE_MODULE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_create_module( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, arg3: *const sqlite3_module, arg4: *mut ::std::os::raw::c_void, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_CREATE_MODULE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_CREATE_MODULE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const sqlite3_module, + arg4: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_DATA_COUNT: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_DATA_COUNT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_data_count(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int { - let fun = __SQLITE3_DATA_COUNT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_DATA_COUNT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(pStmt) } -static __SQLITE3_DB_HANDLE: ::atomic::Atomic< - Option *mut sqlite3>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_DB_HANDLE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_db_handle(arg1: *mut sqlite3_stmt) -> *mut sqlite3 { - let fun = __SQLITE3_DB_HANDLE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_DB_HANDLE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> *mut sqlite3 = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_DECLARE_VTAB: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_DECLARE_VTAB: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_declare_vtab( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_DECLARE_VTAB - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_DECLARE_VTAB.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_ENABLE_SHARED_CACHE: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_ENABLE_SHARED_CACHE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_enable_shared_cache( arg1: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_ENABLE_SHARED_CACHE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_ENABLE_SHARED_CACHE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_ERRCODE: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_ERRCODE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_errcode(db: *mut sqlite3) -> ::std::os::raw::c_int { - let fun = __SQLITE3_ERRCODE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_ERRCODE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(db: *mut sqlite3) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(db) } -static __SQLITE3_ERRMSG: ::atomic::Atomic< - Option *const ::std::os::raw::c_char>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_ERRMSG: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_errmsg(arg1: *mut sqlite3) -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_ERRMSG - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_ERRMSG.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> *const ::std::os::raw::c_char = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_ERRMSG16: ::atomic::Atomic< - Option *const ::std::os::raw::c_void>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_ERRMSG16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_errmsg16(arg1: *mut sqlite3) -> *const ::std::os::raw::c_void { - let fun = __SQLITE3_ERRMSG16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_ERRMSG16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> *const ::std::os::raw::c_void = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_EXEC: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: sqlite3_callback, - arg4: *mut ::std::os::raw::c_void, - arg5: *mut *mut ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_EXEC: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_exec( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, @@ -4015,82 +3947,85 @@ pub unsafe fn sqlite3_exec( arg4: *mut ::std::os::raw::c_void, arg5: *mut *mut ::std::os::raw::c_char, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_EXEC - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_EXEC.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: sqlite3_callback, + arg4: *mut ::std::os::raw::c_void, + arg5: *mut *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5) } -static __SQLITE3_FINALIZE: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_FINALIZE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_finalize(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int { - let fun = __SQLITE3_FINALIZE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_FINALIZE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(pStmt) } -static __SQLITE3_FREE: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_FREE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_free(arg1: *mut ::std::os::raw::c_void) { - let fun = __SQLITE3_FREE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_FREE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void) = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_FREE_TABLE: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_FREE_TABLE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_free_table(result: *mut *mut ::std::os::raw::c_char) { - let fun = __SQLITE3_FREE_TABLE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_FREE_TABLE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(result: *mut *mut ::std::os::raw::c_char) = ::std::mem::transmute( + ptr, + ); (fun)(result) } -static __SQLITE3_GET_AUTOCOMMIT: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_GET_AUTOCOMMIT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_get_autocommit(arg1: *mut sqlite3) -> ::std::os::raw::c_int { - let fun = __SQLITE3_GET_AUTOCOMMIT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_GET_AUTOCOMMIT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_GET_AUXDATA: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: ::std::os::raw::c_int, - ) -> *mut ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_GET_AUXDATA: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_get_auxdata( arg1: *mut sqlite3_context, arg2: ::std::os::raw::c_int, ) -> *mut ::std::os::raw::c_void { - let fun = __SQLITE3_GET_AUXDATA - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_GET_AUXDATA.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + ) -> *mut ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_GET_TABLE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: *mut *mut *mut ::std::os::raw::c_char, - arg4: *mut ::std::os::raw::c_int, - arg5: *mut ::std::os::raw::c_int, - arg6: *mut *mut ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_GET_TABLE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_get_table( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, @@ -4099,113 +4034,114 @@ pub unsafe fn sqlite3_get_table( arg5: *mut ::std::os::raw::c_int, arg6: *mut *mut ::std::os::raw::c_char, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_GET_TABLE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_GET_TABLE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *mut *mut *mut ::std::os::raw::c_char, + arg4: *mut ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_int, + arg6: *mut *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5, arg6) } -static __SQLITE3_INTERRUPT: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_INTERRUPT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_interrupt(arg1: *mut sqlite3) { - let fun = __SQLITE3_INTERRUPT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_INTERRUPT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_LAST_INSERT_ROWID: ::atomic::Atomic< - Option sqlite_int64>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_LAST_INSERT_ROWID: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_last_insert_rowid(arg1: *mut sqlite3) -> sqlite_int64 { - let fun = __SQLITE3_LAST_INSERT_ROWID - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_LAST_INSERT_ROWID.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> sqlite_int64 = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_LIBVERSION: ::atomic::Atomic< - Option *const ::std::os::raw::c_char>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_LIBVERSION: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_libversion() -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_LIBVERSION - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_LIBVERSION.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn() -> *const ::std::os::raw::c_char = ::std::mem::transmute( + ptr, + ); (fun)() } -static __SQLITE3_LIBVERSION_NUMBER: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_LIBVERSION_NUMBER: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_libversion_number() -> ::std::os::raw::c_int { - let fun = __SQLITE3_LIBVERSION_NUMBER - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_LIBVERSION_NUMBER.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn() -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)() } -static __SQLITE3_MALLOC: ::atomic::Atomic< - Option< - unsafe extern "C" fn(arg1: ::std::os::raw::c_int) -> *mut ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_MALLOC: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_malloc( arg1: ::std::os::raw::c_int, ) -> *mut ::std::os::raw::c_void { - let fun = __SQLITE3_MALLOC - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_MALLOC.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + ) -> *mut ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_OPEN: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *const ::std::os::raw::c_char, - arg2: *mut *mut sqlite3, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_OPEN: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_open( arg1: *const ::std::os::raw::c_char, arg2: *mut *mut sqlite3, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_OPEN - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_OPEN.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *mut *mut sqlite3, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_OPEN16: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *const ::std::os::raw::c_void, - arg2: *mut *mut sqlite3, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_OPEN16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_open16( arg1: *const ::std::os::raw::c_void, arg2: *mut *mut sqlite3, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_OPEN16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_OPEN16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_void, + arg2: *mut *mut sqlite3, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_PREPARE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: ::std::os::raw::c_int, - arg4: *mut *mut sqlite3_stmt, - arg5: *mut *const ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_PREPARE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_prepare( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, @@ -4213,23 +4149,21 @@ pub unsafe fn sqlite3_prepare( arg4: *mut *mut sqlite3_stmt, arg5: *mut *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_PREPARE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_PREPARE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut *mut sqlite3_stmt, + arg5: *mut *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5) } -static __SQLITE3_PREPARE16: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_void, - arg3: ::std::os::raw::c_int, - arg4: *mut *mut sqlite3_stmt, - arg5: *mut *const ::std::os::raw::c_void, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_PREPARE16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_prepare16( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_void, @@ -4237,27 +4171,21 @@ pub unsafe fn sqlite3_prepare16( arg4: *mut *mut sqlite3_stmt, arg5: *mut *const ::std::os::raw::c_void, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_PREPARE16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_PREPARE16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: *mut *mut sqlite3_stmt, + arg5: *mut *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5) } -static __SQLITE3_PROFILE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - arg2: *const ::std::os::raw::c_char, - arg3: sqlite_uint64, - ), - >, - arg3: *mut ::std::os::raw::c_void, - ) -> *mut ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_PROFILE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_profile( arg1: *mut sqlite3, arg2: ::std::option::Option< @@ -4269,26 +4197,25 @@ pub unsafe fn sqlite3_profile( >, arg3: *mut ::std::os::raw::c_void, ) -> *mut ::std::os::raw::c_void { - let fun = __SQLITE3_PROFILE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_PROFILE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *const ::std::os::raw::c_char, + arg3: sqlite_uint64, + ), + >, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_PROGRESS_HANDLER: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: ::std::os::raw::c_int, - arg3: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - ) -> ::std::os::raw::c_int, - >, - arg4: *mut ::std::os::raw::c_void, - ), - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_PROGRESS_HANDLER: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_progress_handler( arg1: *mut sqlite3, arg2: ::std::os::raw::c_int, @@ -4297,296 +4224,286 @@ pub unsafe fn sqlite3_progress_handler( >, arg4: *mut ::std::os::raw::c_void, ) { - let fun = __SQLITE3_PROGRESS_HANDLER - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_PROGRESS_HANDLER.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + arg3: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + arg4: *mut ::std::os::raw::c_void, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_REALLOC: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - arg2: ::std::os::raw::c_int, - ) -> *mut ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_REALLOC: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_realloc( arg1: *mut ::std::os::raw::c_void, arg2: ::std::os::raw::c_int, ) -> *mut ::std::os::raw::c_void { - let fun = __SQLITE3_REALLOC - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_REALLOC.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + ) -> *mut ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_RESET: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESET: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_reset(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int { - let fun = __SQLITE3_RESET - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESET.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(pStmt: *mut sqlite3_stmt) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(pStmt) } -static __SQLITE3_RESULT_BLOB: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: *const ::std::os::raw::c_void, - arg3: ::std::os::raw::c_int, - arg4: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ), - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_BLOB: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_blob( arg1: *mut sqlite3_context, arg2: *const ::std::os::raw::c_void, arg3: ::std::os::raw::c_int, arg4: ::std::option::Option, ) { - let fun = __SQLITE3_RESULT_BLOB - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_BLOB.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_RESULT_DOUBLE: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_DOUBLE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_double(arg1: *mut sqlite3_context, arg2: f64) { - let fun = __SQLITE3_RESULT_DOUBLE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_DOUBLE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_context, arg2: f64) = ::std::mem::transmute( + ptr, + ); (fun)(arg1, arg2) } -static __SQLITE3_RESULT_ERROR: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: *const ::std::os::raw::c_char, - arg3: ::std::os::raw::c_int, - ), - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_ERROR: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_error( arg1: *mut sqlite3_context, arg2: *const ::std::os::raw::c_char, arg3: ::std::os::raw::c_int, ) { - let fun = __SQLITE3_RESULT_ERROR - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_ERROR.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_RESULT_ERROR16: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: *const ::std::os::raw::c_void, - arg3: ::std::os::raw::c_int, - ), - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_ERROR16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_error16( arg1: *mut sqlite3_context, arg2: *const ::std::os::raw::c_void, arg3: ::std::os::raw::c_int, ) { - let fun = __SQLITE3_RESULT_ERROR16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_ERROR16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_RESULT_INT: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_INT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_int( arg1: *mut sqlite3_context, arg2: ::std::os::raw::c_int, ) { - let fun = __SQLITE3_RESULT_INT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_INT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_RESULT_INT64: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_INT64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_int64(arg1: *mut sqlite3_context, arg2: sqlite_int64) { - let fun = __SQLITE3_RESULT_INT64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_INT64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_context, arg2: sqlite_int64) = ::std::mem::transmute( + ptr, + ); (fun)(arg1, arg2) } -static __SQLITE3_RESULT_NULL: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_NULL: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_null(arg1: *mut sqlite3_context) { - let fun = __SQLITE3_RESULT_NULL - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_NULL.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_context) = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_RESULT_TEXT: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: *const ::std::os::raw::c_char, - arg3: ::std::os::raw::c_int, - arg4: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ), - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_TEXT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_text( arg1: *mut sqlite3_context, arg2: *const ::std::os::raw::c_char, arg3: ::std::os::raw::c_int, arg4: ::std::option::Option, ) { - let fun = __SQLITE3_RESULT_TEXT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_TEXT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_RESULT_TEXT16: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: *const ::std::os::raw::c_void, - arg3: ::std::os::raw::c_int, - arg4: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ), - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_TEXT16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_text16( arg1: *mut sqlite3_context, arg2: *const ::std::os::raw::c_void, arg3: ::std::os::raw::c_int, arg4: ::std::option::Option, ) { - let fun = __SQLITE3_RESULT_TEXT16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_TEXT16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_RESULT_TEXT16BE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: *const ::std::os::raw::c_void, - arg3: ::std::os::raw::c_int, - arg4: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ), - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_TEXT16BE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_text16be( arg1: *mut sqlite3_context, arg2: *const ::std::os::raw::c_void, arg3: ::std::os::raw::c_int, arg4: ::std::option::Option, ) { - let fun = __SQLITE3_RESULT_TEXT16BE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_TEXT16BE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_RESULT_TEXT16LE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: *const ::std::os::raw::c_void, - arg3: ::std::os::raw::c_int, - arg4: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ), - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_TEXT16LE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_text16le( arg1: *mut sqlite3_context, arg2: *const ::std::os::raw::c_void, arg3: ::std::os::raw::c_int, arg4: ::std::option::Option, ) { - let fun = __SQLITE3_RESULT_TEXT16LE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_TEXT16LE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_RESULT_VALUE: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_VALUE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_value( arg1: *mut sqlite3_context, arg2: *mut sqlite3_value, ) { - let fun = __SQLITE3_RESULT_VALUE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_VALUE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *mut sqlite3_value, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_ROLLBACK_HOOK: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - arg3: *mut ::std::os::raw::c_void, - ) -> *mut ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_ROLLBACK_HOOK: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_rollback_hook( arg1: *mut sqlite3, arg2: ::std::option::Option, arg3: *mut ::std::os::raw::c_void, ) -> *mut ::std::os::raw::c_void { - let fun = __SQLITE3_ROLLBACK_HOOK - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_ROLLBACK_HOOK.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_SET_AUTHORIZER: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - arg2: ::std::os::raw::c_int, - arg3: *const ::std::os::raw::c_char, - arg4: *const ::std::os::raw::c_char, - arg5: *const ::std::os::raw::c_char, - arg6: *const ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, - >, - arg3: *mut ::std::os::raw::c_void, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_SET_AUTHORIZER: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_set_authorizer( arg1: *mut sqlite3, arg2: ::std::option::Option< @@ -4601,61 +4518,62 @@ pub unsafe fn sqlite3_set_authorizer( >, arg3: *mut ::std::os::raw::c_void, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_SET_AUTHORIZER - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_SET_AUTHORIZER.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + arg4: *const ::std::os::raw::c_char, + arg5: *const ::std::os::raw::c_char, + arg6: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_SET_AUXDATA: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: ::std::os::raw::c_int, - arg3: *mut ::std::os::raw::c_void, - arg4: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ), - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_SET_AUXDATA: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_set_auxdata( arg1: *mut sqlite3_context, arg2: ::std::os::raw::c_int, arg3: *mut ::std::os::raw::c_void, arg4: ::std::option::Option, ) { - let fun = __SQLITE3_SET_AUXDATA - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_SET_AUXDATA.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut ::std::os::raw::c_void, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_STEP: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_STEP: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_step(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int { - let fun = __SQLITE3_STEP - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_STEP.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_TABLE_COLUMN_METADATA: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: *const ::std::os::raw::c_char, - arg4: *const ::std::os::raw::c_char, - arg5: *mut *const ::std::os::raw::c_char, - arg6: *mut *const ::std::os::raw::c_char, - arg7: *mut ::std::os::raw::c_int, - arg8: *mut ::std::os::raw::c_int, - arg9: *mut ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_TABLE_COLUMN_METADATA: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_table_column_metadata( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, @@ -4667,36 +4585,38 @@ pub unsafe fn sqlite3_table_column_metadata( arg8: *mut ::std::os::raw::c_int, arg9: *mut ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_TABLE_COLUMN_METADATA - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_TABLE_COLUMN_METADATA + .load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: *const ::std::os::raw::c_char, + arg5: *mut *const ::std::os::raw::c_char, + arg6: *mut *const ::std::os::raw::c_char, + arg7: *mut ::std::os::raw::c_int, + arg8: *mut ::std::os::raw::c_int, + arg9: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) } -static __SQLITE3_TOTAL_CHANGES: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_TOTAL_CHANGES: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_total_changes(arg1: *mut sqlite3) -> ::std::os::raw::c_int { - let fun = __SQLITE3_TOTAL_CHANGES - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_TOTAL_CHANGES.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_TRACE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - xTrace: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - arg2: *const ::std::os::raw::c_char, - ), - >, - arg2: *mut ::std::os::raw::c_void, - ) -> *mut ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_TRACE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_trace( arg1: *mut sqlite3, xTrace: ::std::option::Option< @@ -4707,29 +4627,24 @@ pub unsafe fn sqlite3_trace( >, arg2: *mut ::std::os::raw::c_void, ) -> *mut ::std::os::raw::c_void { - let fun = __SQLITE3_TRACE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_TRACE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + xTrace: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *const ::std::os::raw::c_char, + ), + >, + arg2: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, xTrace, arg2) } -static __SQLITE3_UPDATE_HOOK: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - arg2: ::std::os::raw::c_int, - arg3: *const ::std::os::raw::c_char, - arg4: *const ::std::os::raw::c_char, - arg5: sqlite_int64, - ), - >, - arg3: *mut ::std::os::raw::c_void, - ) -> *mut ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_UPDATE_HOOK: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_update_hook( arg1: *mut sqlite3, arg2: ::std::option::Option< @@ -4743,199 +4658,215 @@ pub unsafe fn sqlite3_update_hook( >, arg3: *mut ::std::os::raw::c_void, ) -> *mut ::std::os::raw::c_void { - let fun = __SQLITE3_UPDATE_HOOK - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_UPDATE_HOOK.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + arg4: *const ::std::os::raw::c_char, + arg5: sqlite_int64, + ), + >, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_USER_DATA: ::atomic::Atomic< - Option< - unsafe extern "C" fn(arg1: *mut sqlite3_context) -> *mut ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_USER_DATA: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_user_data( arg1: *mut sqlite3_context, ) -> *mut ::std::os::raw::c_void { - let fun = __SQLITE3_USER_DATA - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_USER_DATA.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + ) -> *mut ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_VALUE_BLOB: ::atomic::Atomic< - Option< - unsafe extern "C" fn(arg1: *mut sqlite3_value) -> *const ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_BLOB: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_blob( arg1: *mut sqlite3_value, ) -> *const ::std::os::raw::c_void { - let fun = __SQLITE3_VALUE_BLOB - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_BLOB.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_value, + ) -> *const ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_VALUE_BYTES: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_BYTES: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_bytes(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int { - let fun = __SQLITE3_VALUE_BYTES - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_BYTES.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_VALUE_BYTES16: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_BYTES16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_bytes16(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int { - let fun = __SQLITE3_VALUE_BYTES16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_BYTES16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_VALUE_DOUBLE: ::atomic::Atomic< - Option f64>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_DOUBLE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_double(arg1: *mut sqlite3_value) -> f64 { - let fun = __SQLITE3_VALUE_DOUBLE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_DOUBLE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_value) -> f64 = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_VALUE_INT: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_INT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_int(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int { - let fun = __SQLITE3_VALUE_INT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_INT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_VALUE_INT64: ::atomic::Atomic< - Option sqlite_int64>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_INT64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_int64(arg1: *mut sqlite3_value) -> sqlite_int64 { - let fun = __SQLITE3_VALUE_INT64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_INT64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_value) -> sqlite_int64 = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_VALUE_NUMERIC_TYPE: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_NUMERIC_TYPE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_numeric_type( arg1: *mut sqlite3_value, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_VALUE_NUMERIC_TYPE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_NUMERIC_TYPE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_VALUE_TEXT: ::atomic::Atomic< - Option< - unsafe extern "C" fn(arg1: *mut sqlite3_value) -> *const ::std::os::raw::c_uchar, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_TEXT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_text( arg1: *mut sqlite3_value, ) -> *const ::std::os::raw::c_uchar { - let fun = __SQLITE3_VALUE_TEXT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_TEXT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_value, + ) -> *const ::std::os::raw::c_uchar = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_VALUE_TEXT16: ::atomic::Atomic< - Option< - unsafe extern "C" fn(arg1: *mut sqlite3_value) -> *const ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_TEXT16: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_text16( arg1: *mut sqlite3_value, ) -> *const ::std::os::raw::c_void { - let fun = __SQLITE3_VALUE_TEXT16 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_TEXT16.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_value, + ) -> *const ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_VALUE_TEXT16BE: ::atomic::Atomic< - Option< - unsafe extern "C" fn(arg1: *mut sqlite3_value) -> *const ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_TEXT16BE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_text16be( arg1: *mut sqlite3_value, ) -> *const ::std::os::raw::c_void { - let fun = __SQLITE3_VALUE_TEXT16BE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_TEXT16BE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_value, + ) -> *const ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_VALUE_TEXT16LE: ::atomic::Atomic< - Option< - unsafe extern "C" fn(arg1: *mut sqlite3_value) -> *const ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_TEXT16LE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_text16le( arg1: *mut sqlite3_value, ) -> *const ::std::os::raw::c_void { - let fun = __SQLITE3_VALUE_TEXT16LE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_TEXT16LE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_value, + ) -> *const ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_VALUE_TYPE: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_TYPE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_type(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int { - let fun = __SQLITE3_VALUE_TYPE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_TYPE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_OVERLOAD_FUNCTION: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - zFuncName: *const ::std::os::raw::c_char, - nArg: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_OVERLOAD_FUNCTION: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_overload_function( arg1: *mut sqlite3, zFuncName: *const ::std::os::raw::c_char, nArg: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_OVERLOAD_FUNCTION - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_OVERLOAD_FUNCTION.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + zFuncName: *const ::std::os::raw::c_char, + nArg: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, zFuncName, nArg) } -static __SQLITE3_PREPARE_V2: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: ::std::os::raw::c_int, - arg4: *mut *mut sqlite3_stmt, - arg5: *mut *const ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_PREPARE_V2: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_prepare_v2( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, @@ -4943,23 +4874,21 @@ pub unsafe fn sqlite3_prepare_v2( arg4: *mut *mut sqlite3_stmt, arg5: *mut *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_PREPARE_V2 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_PREPARE_V2.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut *mut sqlite3_stmt, + arg5: *mut *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5) } -static __SQLITE3_PREPARE16_V2: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_void, - arg3: ::std::os::raw::c_int, - arg4: *mut *mut sqlite3_stmt, - arg5: *mut *const ::std::os::raw::c_void, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_PREPARE16_V2: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_prepare16_v2( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_void, @@ -4967,35 +4896,33 @@ pub unsafe fn sqlite3_prepare16_v2( arg4: *mut *mut sqlite3_stmt, arg5: *mut *const ::std::os::raw::c_void, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_PREPARE16_V2 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_PREPARE16_V2.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: *mut *mut sqlite3_stmt, + arg5: *mut *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5) } -static __SQLITE3_CLEAR_BINDINGS: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_CLEAR_BINDINGS: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_clear_bindings(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int { - let fun = __SQLITE3_CLEAR_BINDINGS - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_CLEAR_BINDINGS.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_CREATE_MODULE_V2: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: *const sqlite3_module, - arg4: *mut ::std::os::raw::c_void, - xDestroy: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_CREATE_MODULE_V2: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_create_module_v2( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, @@ -5005,65 +4932,65 @@ pub unsafe fn sqlite3_create_module_v2( unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), >, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_CREATE_MODULE_V2 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_CREATE_MODULE_V2.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const sqlite3_module, + arg4: *mut ::std::os::raw::c_void, + xDestroy: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, xDestroy) } -static __SQLITE3_BIND_ZEROBLOB: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - arg3: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BIND_ZEROBLOB: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_bind_zeroblob( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, arg3: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BIND_ZEROBLOB - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BIND_ZEROBLOB.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_BLOB_BYTES: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BLOB_BYTES: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_blob_bytes(arg1: *mut sqlite3_blob) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BLOB_BYTES - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BLOB_BYTES.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_blob) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_BLOB_CLOSE: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BLOB_CLOSE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_blob_close(arg1: *mut sqlite3_blob) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BLOB_CLOSE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BLOB_CLOSE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_blob) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_BLOB_OPEN: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: *const ::std::os::raw::c_char, - arg4: *const ::std::os::raw::c_char, - arg5: sqlite3_int64, - arg6: ::std::os::raw::c_int, - arg7: *mut *mut sqlite3_blob, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BLOB_OPEN: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_blob_open( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, @@ -5073,78 +5000,63 @@ pub unsafe fn sqlite3_blob_open( arg6: ::std::os::raw::c_int, arg7: *mut *mut sqlite3_blob, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BLOB_OPEN - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BLOB_OPEN.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: *const ::std::os::raw::c_char, + arg5: sqlite3_int64, + arg6: ::std::os::raw::c_int, + arg7: *mut *mut sqlite3_blob, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5, arg6, arg7) } -static __SQLITE3_BLOB_READ: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_blob, - arg2: *mut ::std::os::raw::c_void, - arg3: ::std::os::raw::c_int, - arg4: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BLOB_READ: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_blob_read( arg1: *mut sqlite3_blob, arg2: *mut ::std::os::raw::c_void, arg3: ::std::os::raw::c_int, arg4: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BLOB_READ - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BLOB_READ.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_blob, + arg2: *mut ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_BLOB_WRITE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_blob, - arg2: *const ::std::os::raw::c_void, - arg3: ::std::os::raw::c_int, - arg4: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BLOB_WRITE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_blob_write( arg1: *mut sqlite3_blob, arg2: *const ::std::os::raw::c_void, arg3: ::std::os::raw::c_int, arg4: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BLOB_WRITE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BLOB_WRITE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_blob, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_CREATE_COLLATION_V2: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: ::std::os::raw::c_int, - arg4: *mut ::std::os::raw::c_void, - arg5: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - arg2: ::std::os::raw::c_int, - arg3: *const ::std::os::raw::c_void, - arg4: ::std::os::raw::c_int, - arg5: *const ::std::os::raw::c_void, - ) -> ::std::os::raw::c_int, - >, - arg6: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_CREATE_COLLATION_V2: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_create_collation_v2( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, @@ -5161,507 +5073,509 @@ pub unsafe fn sqlite3_create_collation_v2( >, arg6: ::std::option::Option, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_CREATE_COLLATION_V2 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_CREATE_COLLATION_V2.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, + arg5: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: ::std::os::raw::c_int, + arg5: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + arg6: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5, arg6) } -static __SQLITE3_FILE_CONTROL: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: ::std::os::raw::c_int, - arg4: *mut ::std::os::raw::c_void, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_FILE_CONTROL: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_file_control( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, arg3: ::std::os::raw::c_int, arg4: *mut ::std::os::raw::c_void, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_FILE_CONTROL - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_FILE_CONTROL.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_MEMORY_HIGHWATER: ::atomic::Atomic< - Option sqlite3_int64>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_MEMORY_HIGHWATER: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_memory_highwater(arg1: ::std::os::raw::c_int) -> sqlite3_int64 { - let fun = __SQLITE3_MEMORY_HIGHWATER - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_MEMORY_HIGHWATER.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: ::std::os::raw::c_int) -> sqlite3_int64 = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_MEMORY_USED: ::atomic::Atomic< - Option sqlite3_int64>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_MEMORY_USED: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_memory_used() -> sqlite3_int64 { - let fun = __SQLITE3_MEMORY_USED - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_MEMORY_USED.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn() -> sqlite3_int64 = ::std::mem::transmute(ptr); (fun)() } -static __SQLITE3_MUTEX_ALLOC: ::atomic::Atomic< - Option *mut sqlite3_mutex>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_MUTEX_ALLOC: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_mutex_alloc(arg1: ::std::os::raw::c_int) -> *mut sqlite3_mutex { - let fun = __SQLITE3_MUTEX_ALLOC - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_MUTEX_ALLOC.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: ::std::os::raw::c_int) -> *mut sqlite3_mutex = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_MUTEX_ENTER: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_MUTEX_ENTER: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_mutex_enter(arg1: *mut sqlite3_mutex) { - let fun = __SQLITE3_MUTEX_ENTER - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_MUTEX_ENTER.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_mutex) = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_MUTEX_FREE: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_MUTEX_FREE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_mutex_free(arg1: *mut sqlite3_mutex) { - let fun = __SQLITE3_MUTEX_FREE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_MUTEX_FREE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_mutex) = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_MUTEX_LEAVE: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_MUTEX_LEAVE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_mutex_leave(arg1: *mut sqlite3_mutex) { - let fun = __SQLITE3_MUTEX_LEAVE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_MUTEX_LEAVE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_mutex) = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_MUTEX_TRY: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_MUTEX_TRY: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_mutex_try(arg1: *mut sqlite3_mutex) -> ::std::os::raw::c_int { - let fun = __SQLITE3_MUTEX_TRY - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_MUTEX_TRY.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_mutex) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_OPEN_V2: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *const ::std::os::raw::c_char, - arg2: *mut *mut sqlite3, - arg3: ::std::os::raw::c_int, - arg4: *const ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_OPEN_V2: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_open_v2( arg1: *const ::std::os::raw::c_char, arg2: *mut *mut sqlite3, arg3: ::std::os::raw::c_int, arg4: *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_OPEN_V2 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_OPEN_V2.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *mut *mut sqlite3, + arg3: ::std::os::raw::c_int, + arg4: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_RELEASE_MEMORY: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RELEASE_MEMORY: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_release_memory( arg1: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_RELEASE_MEMORY - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RELEASE_MEMORY.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_RESULT_ERROR_NOMEM: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_ERROR_NOMEM: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_error_nomem(arg1: *mut sqlite3_context) { - let fun = __SQLITE3_RESULT_ERROR_NOMEM - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_ERROR_NOMEM.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_context) = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_RESULT_ERROR_TOOBIG: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_ERROR_TOOBIG: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_error_toobig(arg1: *mut sqlite3_context) { - let fun = __SQLITE3_RESULT_ERROR_TOOBIG - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_ERROR_TOOBIG.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_context) = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_SLEEP: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_SLEEP: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_sleep(arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int { - let fun = __SQLITE3_SLEEP - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_SLEEP.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_SOFT_HEAP_LIMIT: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_SOFT_HEAP_LIMIT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_soft_heap_limit(arg1: ::std::os::raw::c_int) { - let fun = __SQLITE3_SOFT_HEAP_LIMIT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_SOFT_HEAP_LIMIT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: ::std::os::raw::c_int) = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_VFS_FIND: ::atomic::Atomic< - Option *mut sqlite3_vfs>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VFS_FIND: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_vfs_find(arg1: *const ::std::os::raw::c_char) -> *mut sqlite3_vfs { - let fun = __SQLITE3_VFS_FIND - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VFS_FIND.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + ) -> *mut sqlite3_vfs = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_VFS_REGISTER: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_vfs, - arg2: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VFS_REGISTER: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_vfs_register( arg1: *mut sqlite3_vfs, arg2: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_VFS_REGISTER - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VFS_REGISTER.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_vfs, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_VFS_UNREGISTER: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VFS_UNREGISTER: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_vfs_unregister(arg1: *mut sqlite3_vfs) -> ::std::os::raw::c_int { - let fun = __SQLITE3_VFS_UNREGISTER - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VFS_UNREGISTER.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_vfs) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_THREADSAFE: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_THREADSAFE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_threadsafe() -> ::std::os::raw::c_int { - let fun = __SQLITE3_THREADSAFE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_THREADSAFE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn() -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)() } -static __SQLITE3_RESULT_ZEROBLOB: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_ZEROBLOB: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_zeroblob( arg1: *mut sqlite3_context, arg2: ::std::os::raw::c_int, ) { - let fun = __SQLITE3_RESULT_ZEROBLOB - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_ZEROBLOB.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_RESULT_ERROR_CODE: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_ERROR_CODE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_error_code( arg1: *mut sqlite3_context, arg2: ::std::os::raw::c_int, ) { - let fun = __SQLITE3_RESULT_ERROR_CODE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_ERROR_CODE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_RANDOMNESS: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: ::std::os::raw::c_int, - arg2: *mut ::std::os::raw::c_void, - ), - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RANDOMNESS: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_randomness( arg1: ::std::os::raw::c_int, arg2: *mut ::std::os::raw::c_void, ) { - let fun = __SQLITE3_RANDOMNESS - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RANDOMNESS.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + arg2: *mut ::std::os::raw::c_void, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_CONTEXT_DB_HANDLE: ::atomic::Atomic< - Option *mut sqlite3>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_CONTEXT_DB_HANDLE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_context_db_handle(arg1: *mut sqlite3_context) -> *mut sqlite3 { - let fun = __SQLITE3_CONTEXT_DB_HANDLE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_CONTEXT_DB_HANDLE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_context) -> *mut sqlite3 = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_EXTENDED_RESULT_CODES: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_EXTENDED_RESULT_CODES: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_extended_result_codes( arg1: *mut sqlite3, arg2: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_EXTENDED_RESULT_CODES - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_EXTENDED_RESULT_CODES + .load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_LIMIT: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: ::std::os::raw::c_int, - arg3: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_LIMIT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_limit( arg1: *mut sqlite3, arg2: ::std::os::raw::c_int, arg3: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_LIMIT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_LIMIT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_NEXT_STMT: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *mut sqlite3_stmt, - ) -> *mut sqlite3_stmt, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_NEXT_STMT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_next_stmt( arg1: *mut sqlite3, arg2: *mut sqlite3_stmt, ) -> *mut sqlite3_stmt { - let fun = __SQLITE3_NEXT_STMT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_NEXT_STMT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *mut sqlite3_stmt, + ) -> *mut sqlite3_stmt = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_SQL: ::atomic::Atomic< - Option< - unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> *const ::std::os::raw::c_char, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_SQL: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_sql(arg1: *mut sqlite3_stmt) -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_SQL - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_SQL.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + ) -> *const ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_STATUS: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: ::std::os::raw::c_int, - arg2: *mut ::std::os::raw::c_int, - arg3: *mut ::std::os::raw::c_int, - arg4: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_STATUS: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_status( arg1: ::std::os::raw::c_int, arg2: *mut ::std::os::raw::c_int, arg3: *mut ::std::os::raw::c_int, arg4: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_STATUS - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_STATUS.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + arg2: *mut ::std::os::raw::c_int, + arg3: *mut ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_BACKUP_FINISH: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BACKUP_FINISH: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_backup_finish(arg1: *mut sqlite3_backup) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BACKUP_FINISH - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BACKUP_FINISH.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_backup) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_BACKUP_INIT: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: *mut sqlite3, - arg4: *const ::std::os::raw::c_char, - ) -> *mut sqlite3_backup, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BACKUP_INIT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_backup_init( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, arg3: *mut sqlite3, arg4: *const ::std::os::raw::c_char, ) -> *mut sqlite3_backup { - let fun = __SQLITE3_BACKUP_INIT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BACKUP_INIT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *mut sqlite3, + arg4: *const ::std::os::raw::c_char, + ) -> *mut sqlite3_backup = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_BACKUP_PAGECOUNT: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BACKUP_PAGECOUNT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_backup_pagecount( arg1: *mut sqlite3_backup, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BACKUP_PAGECOUNT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BACKUP_PAGECOUNT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_backup) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_BACKUP_REMAINING: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BACKUP_REMAINING: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_backup_remaining( arg1: *mut sqlite3_backup, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BACKUP_REMAINING - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BACKUP_REMAINING.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_backup) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_BACKUP_STEP: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_backup, - arg2: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BACKUP_STEP: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_backup_step( arg1: *mut sqlite3_backup, arg2: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BACKUP_STEP - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BACKUP_STEP.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_backup, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_COMPILEOPTION_GET: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_char, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COMPILEOPTION_GET: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_compileoption_get( arg1: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_COMPILEOPTION_GET - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COMPILEOPTION_GET.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_COMPILEOPTION_USED: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *const ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_COMPILEOPTION_USED: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_compileoption_used( arg1: *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_COMPILEOPTION_USED - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_COMPILEOPTION_USED.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_CREATE_FUNCTION_V2: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: ::std::os::raw::c_int, - arg4: ::std::os::raw::c_int, - arg5: *mut ::std::os::raw::c_void, - xFunc: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: ::std::os::raw::c_int, - arg3: *mut *mut sqlite3_value, - ), - >, - xStep: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: ::std::os::raw::c_int, - arg3: *mut *mut sqlite3_value, - ), - >, - xFinal: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut sqlite3_context), - >, - xDestroy: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_CREATE_FUNCTION_V2: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_create_function_v2( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, @@ -5687,54 +5601,70 @@ pub unsafe fn sqlite3_create_function_v2( unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), >, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_CREATE_FUNCTION_V2 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_CREATE_FUNCTION_V2.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_void, + xFunc: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xStep: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xFinal: ::std::option::Option, + xDestroy: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5, xFunc, xStep, xFinal, xDestroy) } -static __SQLITE3_DB_CONFIG: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: ::std::os::raw::c_int, - ... - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_DB_CONFIG: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_db_config( arg1: *mut sqlite3, arg2: ::std::os::raw::c_int, arg3: ::std::os::raw::c_int, arg4: *mut ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_DB_CONFIG - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized"); + let ptr = __SQLITE3_DB_CONFIG.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + ... + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_DB_MUTEX: ::atomic::Atomic< - Option *mut sqlite3_mutex>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_DB_MUTEX: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_db_mutex(arg1: *mut sqlite3) -> *mut sqlite3_mutex { - let fun = __SQLITE3_DB_MUTEX - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_DB_MUTEX.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> *mut sqlite3_mutex = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_DB_STATUS: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: ::std::os::raw::c_int, - arg3: *mut ::std::os::raw::c_int, - arg4: *mut ::std::os::raw::c_int, - arg5: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_DB_STATUS: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_db_status( arg1: *mut sqlite3, arg2: ::std::os::raw::c_int, @@ -5742,116 +5672,111 @@ pub unsafe fn sqlite3_db_status( arg4: *mut ::std::os::raw::c_int, arg5: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_DB_STATUS - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_DB_STATUS.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + arg3: *mut ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_int, + arg5: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5) } -static __SQLITE3_EXTENDED_ERRCODE: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_EXTENDED_ERRCODE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_extended_errcode(arg1: *mut sqlite3) -> ::std::os::raw::c_int { - let fun = __SQLITE3_EXTENDED_ERRCODE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_EXTENDED_ERRCODE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_LOG: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: ::std::os::raw::c_int, - arg2: *const ::std::os::raw::c_char, - ... - ), - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_LOG: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_log( arg1: ::std::os::raw::c_int, arg2: *const ::std::os::raw::c_char, arg3: *const ::std::os::raw::c_char, ) { - let fun = __SQLITE3_LOG - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized"); + let ptr = __SQLITE3_LOG.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized"); + let fun: unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + arg2: *const ::std::os::raw::c_char, + ... + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_SOFT_HEAP_LIMIT64: ::atomic::Atomic< - Option sqlite3_int64>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_SOFT_HEAP_LIMIT64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_soft_heap_limit64(arg1: sqlite3_int64) -> sqlite3_int64 { - let fun = __SQLITE3_SOFT_HEAP_LIMIT64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_SOFT_HEAP_LIMIT64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: sqlite3_int64) -> sqlite3_int64 = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_SOURCEID: ::atomic::Atomic< - Option *const ::std::os::raw::c_char>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_SOURCEID: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_sourceid() -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_SOURCEID - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_SOURCEID.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn() -> *const ::std::os::raw::c_char = ::std::mem::transmute( + ptr, + ); (fun)() } -static __SQLITE3_STMT_STATUS: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - arg3: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_STMT_STATUS: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_stmt_status( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, arg3: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_STMT_STATUS - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_STMT_STATUS.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_STRNICMP: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *const ::std::os::raw::c_char, - arg2: *const ::std::os::raw::c_char, - arg3: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_STRNICMP: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_strnicmp( arg1: *const ::std::os::raw::c_char, arg2: *const ::std::os::raw::c_char, arg3: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_STRNICMP - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_STRNICMP.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_UNLOCK_NOTIFY: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut *mut ::std::os::raw::c_void, - arg2: ::std::os::raw::c_int, - ), - >, - arg3: *mut ::std::os::raw::c_void, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_UNLOCK_NOTIFY: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_unlock_notify( arg1: *mut sqlite3, arg2: ::std::option::Option< @@ -5862,64 +5787,56 @@ pub unsafe fn sqlite3_unlock_notify( >, arg3: *mut ::std::os::raw::c_void, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_UNLOCK_NOTIFY - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_UNLOCK_NOTIFY.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut *mut ::std::os::raw::c_void, + arg2: ::std::os::raw::c_int, + ), + >, + arg3: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_WAL_AUTOCHECKPOINT: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_WAL_AUTOCHECKPOINT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_wal_autocheckpoint( arg1: *mut sqlite3, arg2: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_WAL_AUTOCHECKPOINT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_WAL_AUTOCHECKPOINT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_WAL_CHECKPOINT: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_WAL_CHECKPOINT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_wal_checkpoint( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_WAL_CHECKPOINT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_WAL_CHECKPOINT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_WAL_HOOK: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - arg2: *mut sqlite3, - arg3: *const ::std::os::raw::c_char, - arg4: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, - arg3: *mut ::std::os::raw::c_void, - ) -> *mut ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_WAL_HOOK: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_wal_hook( arg1: *mut sqlite3, arg2: ::std::option::Option< @@ -5932,238 +5849,233 @@ pub unsafe fn sqlite3_wal_hook( >, arg3: *mut ::std::os::raw::c_void, ) -> *mut ::std::os::raw::c_void { - let fun = __SQLITE3_WAL_HOOK - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_WAL_HOOK.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut sqlite3, + arg3: *const ::std::os::raw::c_char, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + arg3: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_BLOB_REOPEN: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_blob, - arg2: sqlite3_int64, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BLOB_REOPEN: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_blob_reopen( arg1: *mut sqlite3_blob, arg2: sqlite3_int64, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BLOB_REOPEN - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BLOB_REOPEN.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_blob, + arg2: sqlite3_int64, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_VTAB_CONFIG: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - op: ::std::os::raw::c_int, - ... - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VTAB_CONFIG: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_vtab_config( arg1: *mut sqlite3, op: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_VTAB_CONFIG - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VTAB_CONFIG.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + op: ::std::os::raw::c_int, + ... + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, op) } -static __SQLITE3_VTAB_ON_CONFLICT: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VTAB_ON_CONFLICT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_vtab_on_conflict(arg1: *mut sqlite3) -> ::std::os::raw::c_int { - let fun = __SQLITE3_VTAB_ON_CONFLICT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VTAB_ON_CONFLICT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_CLOSE_V2: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_CLOSE_V2: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_close_v2(arg1: *mut sqlite3) -> ::std::os::raw::c_int { - let fun = __SQLITE3_CLOSE_V2 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_CLOSE_V2.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_DB_FILENAME: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - ) -> *const ::std::os::raw::c_char, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_DB_FILENAME: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_db_filename( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, ) -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_DB_FILENAME - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_DB_FILENAME.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + ) -> *const ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_DB_READONLY: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_DB_READONLY: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_db_readonly( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_DB_READONLY - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_DB_READONLY.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_DB_RELEASE_MEMORY: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_DB_RELEASE_MEMORY: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_db_release_memory(arg1: *mut sqlite3) -> ::std::os::raw::c_int { - let fun = __SQLITE3_DB_RELEASE_MEMORY - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_DB_RELEASE_MEMORY.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_ERRSTR: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_char, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_ERRSTR: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_errstr( arg1: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_ERRSTR - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_ERRSTR.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_STMT_BUSY: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_STMT_BUSY: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_stmt_busy(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int { - let fun = __SQLITE3_STMT_BUSY - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_STMT_BUSY.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_STMT_READONLY: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_STMT_READONLY: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_stmt_readonly(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int { - let fun = __SQLITE3_STMT_READONLY - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_STMT_READONLY.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_STRICMP: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *const ::std::os::raw::c_char, - arg2: *const ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_STRICMP: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_stricmp( arg1: *const ::std::os::raw::c_char, arg2: *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_STRICMP - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_STRICMP.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_URI_BOOLEAN: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *const ::std::os::raw::c_char, - arg2: *const ::std::os::raw::c_char, - arg3: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_URI_BOOLEAN: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_uri_boolean( arg1: *const ::std::os::raw::c_char, arg2: *const ::std::os::raw::c_char, arg3: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_URI_BOOLEAN - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_URI_BOOLEAN.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_URI_INT64: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *const ::std::os::raw::c_char, - arg2: *const ::std::os::raw::c_char, - arg3: sqlite3_int64, - ) -> sqlite3_int64, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_URI_INT64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_uri_int64( arg1: *const ::std::os::raw::c_char, arg2: *const ::std::os::raw::c_char, arg3: sqlite3_int64, ) -> sqlite3_int64 { - let fun = __SQLITE3_URI_INT64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_URI_INT64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: sqlite3_int64, + ) -> sqlite3_int64 = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_URI_PARAMETER: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *const ::std::os::raw::c_char, - arg2: *const ::std::os::raw::c_char, - ) -> *const ::std::os::raw::c_char, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_URI_PARAMETER: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_uri_parameter( arg1: *const ::std::os::raw::c_char, arg2: *const ::std::os::raw::c_char, ) -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_URI_PARAMETER - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_URI_PARAMETER.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + ) -> *const ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_WAL_CHECKPOINT_V2: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: ::std::os::raw::c_int, - arg4: *mut ::std::os::raw::c_int, - arg5: *mut ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_WAL_CHECKPOINT_V2: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_wal_checkpoint_v2( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, @@ -6171,41 +6083,35 @@ pub unsafe fn sqlite3_wal_checkpoint_v2( arg4: *mut ::std::os::raw::c_int, arg5: *mut ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_WAL_CHECKPOINT_V2 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_WAL_CHECKPOINT_V2.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: *mut ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5) } -static __SQLITE3_AUTO_EXTENSION: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: ::std::option::Option, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_AUTO_EXTENSION: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_auto_extension( arg1: ::std::option::Option, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_AUTO_EXTENSION - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_AUTO_EXTENSION.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: ::std::option::Option, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_BIND_BLOB64: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - arg3: *const ::std::os::raw::c_void, - arg4: sqlite3_uint64, - arg5: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BIND_BLOB64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_bind_blob64( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, @@ -6213,26 +6119,23 @@ pub unsafe fn sqlite3_bind_blob64( arg4: sqlite3_uint64, arg5: ::std::option::Option, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BIND_BLOB64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BIND_BLOB64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_void, + arg4: sqlite3_uint64, + arg5: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5) } -static __SQLITE3_BIND_TEXT64: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - arg3: *const ::std::os::raw::c_char, - arg4: sqlite3_uint64, - arg5: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - arg6: ::std::os::raw::c_uchar, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BIND_TEXT64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_bind_text64( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, @@ -6241,135 +6144,132 @@ pub unsafe fn sqlite3_bind_text64( arg5: ::std::option::Option, arg6: ::std::os::raw::c_uchar, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BIND_TEXT64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BIND_TEXT64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *const ::std::os::raw::c_char, + arg4: sqlite3_uint64, + arg5: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + arg6: ::std::os::raw::c_uchar, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5, arg6) } -static __SQLITE3_CANCEL_AUTO_EXTENSION: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: ::std::option::Option, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_CANCEL_AUTO_EXTENSION: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_cancel_auto_extension( arg1: ::std::option::Option, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_CANCEL_AUTO_EXTENSION - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_CANCEL_AUTO_EXTENSION + .load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: ::std::option::Option, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_LOAD_EXTENSION: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: *const ::std::os::raw::c_char, - arg4: *mut *mut ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_LOAD_EXTENSION: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_load_extension( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, arg3: *const ::std::os::raw::c_char, arg4: *mut *mut ::std::os::raw::c_char, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_LOAD_EXTENSION - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_LOAD_EXTENSION.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: *mut *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_MALLOC64: ::atomic::Atomic< - Option *mut ::std::os::raw::c_void>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_MALLOC64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_malloc64(arg1: sqlite3_uint64) -> *mut ::std::os::raw::c_void { - let fun = __SQLITE3_MALLOC64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_MALLOC64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: sqlite3_uint64) -> *mut ::std::os::raw::c_void = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_MSIZE: ::atomic::Atomic< - Option sqlite3_uint64>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_MSIZE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_msize(arg1: *mut ::std::os::raw::c_void) -> sqlite3_uint64 { - let fun = __SQLITE3_MSIZE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_MSIZE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void) -> sqlite3_uint64 = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_REALLOC64: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - arg2: sqlite3_uint64, - ) -> *mut ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_REALLOC64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_realloc64( arg1: *mut ::std::os::raw::c_void, arg2: sqlite3_uint64, ) -> *mut ::std::os::raw::c_void { - let fun = __SQLITE3_REALLOC64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_REALLOC64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: sqlite3_uint64, + ) -> *mut ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_RESET_AUTO_EXTENSION: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESET_AUTO_EXTENSION: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_reset_auto_extension() { - let fun = __SQLITE3_RESET_AUTO_EXTENSION - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESET_AUTO_EXTENSION + .load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn() = ::std::mem::transmute(ptr); (fun)() } -static __SQLITE3_RESULT_BLOB64: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: *const ::std::os::raw::c_void, - arg3: sqlite3_uint64, - arg4: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ), - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_BLOB64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_blob64( arg1: *mut sqlite3_context, arg2: *const ::std::os::raw::c_void, arg3: sqlite3_uint64, arg4: ::std::option::Option, ) { - let fun = __SQLITE3_RESULT_BLOB64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_BLOB64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_void, + arg3: sqlite3_uint64, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_RESULT_TEXT64: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: *const ::std::os::raw::c_char, - arg3: sqlite3_uint64, - arg4: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - arg5: ::std::os::raw::c_uchar, - ), - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_TEXT64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_text64( arg1: *mut sqlite3_context, arg2: *const ::std::os::raw::c_char, @@ -6377,192 +6277,185 @@ pub unsafe fn sqlite3_result_text64( arg4: ::std::option::Option, arg5: ::std::os::raw::c_uchar, ) { - let fun = __SQLITE3_RESULT_TEXT64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_TEXT64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *const ::std::os::raw::c_char, + arg3: sqlite3_uint64, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + arg5: ::std::os::raw::c_uchar, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5) } -static __SQLITE3_STRGLOB: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *const ::std::os::raw::c_char, - arg2: *const ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_STRGLOB: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_strglob( arg1: *const ::std::os::raw::c_char, arg2: *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_STRGLOB - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_STRGLOB.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_VALUE_DUP: ::atomic::Atomic< - Option *mut sqlite3_value>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_DUP: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_dup(arg1: *const sqlite3_value) -> *mut sqlite3_value { - let fun = __SQLITE3_VALUE_DUP - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_DUP.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *const sqlite3_value) -> *mut sqlite3_value = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_VALUE_FREE: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_FREE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_free(arg1: *mut sqlite3_value) { - let fun = __SQLITE3_VALUE_FREE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_FREE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_value) = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_RESULT_ZEROBLOB64: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: sqlite3_uint64, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_ZEROBLOB64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_zeroblob64( arg1: *mut sqlite3_context, arg2: sqlite3_uint64, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_RESULT_ZEROBLOB64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_ZEROBLOB64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: sqlite3_uint64, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_BIND_ZEROBLOB64: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - arg3: sqlite3_uint64, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BIND_ZEROBLOB64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_bind_zeroblob64( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, arg3: sqlite3_uint64, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BIND_ZEROBLOB64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BIND_ZEROBLOB64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: sqlite3_uint64, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_VALUE_SUBTYPE: ::atomic::Atomic< - Option ::std::os::raw::c_uint>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_SUBTYPE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_subtype(arg1: *mut sqlite3_value) -> ::std::os::raw::c_uint { - let fun = __SQLITE3_VALUE_SUBTYPE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_SUBTYPE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_value) -> ::std::os::raw::c_uint = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_RESULT_SUBTYPE: ::atomic::Atomic< - Option< - unsafe extern "C" fn(arg1: *mut sqlite3_context, arg2: ::std::os::raw::c_uint), - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_SUBTYPE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_subtype( arg1: *mut sqlite3_context, arg2: ::std::os::raw::c_uint, ) { - let fun = __SQLITE3_RESULT_SUBTYPE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_SUBTYPE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_uint, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_STATUS64: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: ::std::os::raw::c_int, - arg2: *mut sqlite3_int64, - arg3: *mut sqlite3_int64, - arg4: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_STATUS64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_status64( arg1: ::std::os::raw::c_int, arg2: *mut sqlite3_int64, arg3: *mut sqlite3_int64, arg4: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_STATUS64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_STATUS64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + arg2: *mut sqlite3_int64, + arg3: *mut sqlite3_int64, + arg4: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_STRLIKE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *const ::std::os::raw::c_char, - arg2: *const ::std::os::raw::c_char, - arg3: ::std::os::raw::c_uint, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_STRLIKE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_strlike( arg1: *const ::std::os::raw::c_char, arg2: *const ::std::os::raw::c_char, arg3: ::std::os::raw::c_uint, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_STRLIKE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_STRLIKE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_uint, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_DB_CACHEFLUSH: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_DB_CACHEFLUSH: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_db_cacheflush(arg1: *mut sqlite3) -> ::std::os::raw::c_int { - let fun = __SQLITE3_DB_CACHEFLUSH - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_DB_CACHEFLUSH.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_SYSTEM_ERRNO: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_SYSTEM_ERRNO: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_system_errno(arg1: *mut sqlite3) -> ::std::os::raw::c_int { - let fun = __SQLITE3_SYSTEM_ERRNO - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_SYSTEM_ERRNO.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_TRACE_V2: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: ::std::os::raw::c_uint, - arg3: ::std::option::Option< - unsafe extern "C" fn( - arg1: ::std::os::raw::c_uint, - arg2: *mut ::std::os::raw::c_void, - arg3: *mut ::std::os::raw::c_void, - arg4: *mut ::std::os::raw::c_void, - ) -> ::std::os::raw::c_int, - >, - arg4: *mut ::std::os::raw::c_void, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_TRACE_V2: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_trace_v2( arg1: *mut sqlite3, arg2: ::std::os::raw::c_uint, @@ -6576,46 +6469,54 @@ pub unsafe fn sqlite3_trace_v2( >, arg4: *mut ::std::os::raw::c_void, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_TRACE_V2 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_TRACE_V2.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_uint, + arg3: ::std::option::Option< + unsafe extern "C" fn( + arg1: ::std::os::raw::c_uint, + arg2: *mut ::std::os::raw::c_void, + arg3: *mut ::std::os::raw::c_void, + arg4: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, + >, + arg4: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_EXPANDED_SQL: ::atomic::Atomic< - Option *mut ::std::os::raw::c_char>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_EXPANDED_SQL: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_expanded_sql( arg1: *mut sqlite3_stmt, ) -> *mut ::std::os::raw::c_char { - let fun = __SQLITE3_EXPANDED_SQL - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_EXPANDED_SQL.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + ) -> *mut ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_SET_LAST_INSERT_ROWID: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_SET_LAST_INSERT_ROWID: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_set_last_insert_rowid(arg1: *mut sqlite3, arg2: sqlite3_int64) { - let fun = __SQLITE3_SET_LAST_INSERT_ROWID - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_SET_LAST_INSERT_ROWID + .load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3, arg2: sqlite3_int64) = ::std::mem::transmute( + ptr, + ); (fun)(arg1, arg2) } -static __SQLITE3_PREPARE_V3: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: ::std::os::raw::c_int, - arg4: ::std::os::raw::c_uint, - arg5: *mut *mut sqlite3_stmt, - arg6: *mut *const ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_PREPARE_V3: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_prepare_v3( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, @@ -6624,24 +6525,22 @@ pub unsafe fn sqlite3_prepare_v3( arg5: *mut *mut sqlite3_stmt, arg6: *mut *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_PREPARE_V3 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_PREPARE_V3.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_uint, + arg5: *mut *mut sqlite3_stmt, + arg6: *mut *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5, arg6) } -static __SQLITE3_PREPARE16_V3: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_void, - arg3: ::std::os::raw::c_int, - arg4: ::std::os::raw::c_uint, - arg5: *mut *mut sqlite3_stmt, - arg6: *mut *const ::std::os::raw::c_void, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_PREPARE16_V3: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_prepare16_v3( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_void, @@ -6650,25 +6549,22 @@ pub unsafe fn sqlite3_prepare16_v3( arg5: *mut *mut sqlite3_stmt, arg6: *mut *const ::std::os::raw::c_void, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_PREPARE16_V3 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_PREPARE16_V3.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_void, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_uint, + arg5: *mut *mut sqlite3_stmt, + arg6: *mut *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5, arg6) } -static __SQLITE3_BIND_POINTER: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - arg3: *mut ::std::os::raw::c_void, - arg4: *const ::std::os::raw::c_char, - arg5: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_BIND_POINTER: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_bind_pointer( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, @@ -6676,291 +6572,271 @@ pub unsafe fn sqlite3_bind_pointer( arg4: *const ::std::os::raw::c_char, arg5: ::std::option::Option, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_BIND_POINTER - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_BIND_POINTER.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + arg3: *mut ::std::os::raw::c_void, + arg4: *const ::std::os::raw::c_char, + arg5: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5) } -static __SQLITE3_RESULT_POINTER: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: *mut ::std::os::raw::c_void, - arg3: *const ::std::os::raw::c_char, - arg4: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ), - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_RESULT_POINTER: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_result_pointer( arg1: *mut sqlite3_context, arg2: *mut ::std::os::raw::c_void, arg3: *const ::std::os::raw::c_char, arg4: ::std::option::Option, ) { - let fun = __SQLITE3_RESULT_POINTER - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_RESULT_POINTER.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: *mut ::std::os::raw::c_void, + arg3: *const ::std::os::raw::c_char, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_VALUE_POINTER: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_value, - arg2: *const ::std::os::raw::c_char, - ) -> *mut ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_POINTER: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_pointer( arg1: *mut sqlite3_value, arg2: *const ::std::os::raw::c_char, ) -> *mut ::std::os::raw::c_void { - let fun = __SQLITE3_VALUE_POINTER - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_POINTER.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_value, + arg2: *const ::std::os::raw::c_char, + ) -> *mut ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_VTAB_NOCHANGE: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VTAB_NOCHANGE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_vtab_nochange( arg1: *mut sqlite3_context, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_VTAB_NOCHANGE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VTAB_NOCHANGE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_context) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_VALUE_NOCHANGE: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_NOCHANGE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_nochange(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int { - let fun = __SQLITE3_VALUE_NOCHANGE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_NOCHANGE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_VTAB_COLLATION: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_index_info, - arg2: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_char, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VTAB_COLLATION: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_vtab_collation( arg1: *mut sqlite3_index_info, arg2: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_VTAB_COLLATION - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VTAB_COLLATION.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_index_info, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_KEYWORD_COUNT: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_KEYWORD_COUNT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_keyword_count() -> ::std::os::raw::c_int { - let fun = __SQLITE3_KEYWORD_COUNT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_KEYWORD_COUNT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn() -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)() } -static __SQLITE3_KEYWORD_NAME: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: ::std::os::raw::c_int, - arg2: *mut *const ::std::os::raw::c_char, - arg3: *mut ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_KEYWORD_NAME: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_keyword_name( arg1: ::std::os::raw::c_int, arg2: *mut *const ::std::os::raw::c_char, arg3: *mut ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_KEYWORD_NAME - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_KEYWORD_NAME.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: ::std::os::raw::c_int, + arg2: *mut *const ::std::os::raw::c_char, + arg3: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_KEYWORD_CHECK: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *const ::std::os::raw::c_char, - arg2: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_KEYWORD_CHECK: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_keyword_check( arg1: *const ::std::os::raw::c_char, arg2: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_KEYWORD_CHECK - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_KEYWORD_CHECK.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_STR_NEW: ::atomic::Atomic< - Option *mut sqlite3_str>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_STR_NEW: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_str_new(arg1: *mut sqlite3) -> *mut sqlite3_str { - let fun = __SQLITE3_STR_NEW - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_STR_NEW.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> *mut sqlite3_str = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_STR_FINISH: ::atomic::Atomic< - Option *mut ::std::os::raw::c_char>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_STR_FINISH: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_str_finish(arg1: *mut sqlite3_str) -> *mut ::std::os::raw::c_char { - let fun = __SQLITE3_STR_FINISH - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_STR_FINISH.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_str, + ) -> *mut ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_STR_APPEND: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_str, - zIn: *const ::std::os::raw::c_char, - N: ::std::os::raw::c_int, - ), - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_STR_APPEND: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_str_append( arg1: *mut sqlite3_str, zIn: *const ::std::os::raw::c_char, N: ::std::os::raw::c_int, ) { - let fun = __SQLITE3_STR_APPEND - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_STR_APPEND.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_str, + zIn: *const ::std::os::raw::c_char, + N: ::std::os::raw::c_int, + ) = ::std::mem::transmute(ptr); (fun)(arg1, zIn, N) } -static __SQLITE3_STR_APPENDALL: ::atomic::Atomic< - Option< - unsafe extern "C" fn(arg1: *mut sqlite3_str, zIn: *const ::std::os::raw::c_char), - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_STR_APPENDALL: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_str_appendall( arg1: *mut sqlite3_str, zIn: *const ::std::os::raw::c_char, ) { - let fun = __SQLITE3_STR_APPENDALL - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_STR_APPENDALL.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_str, + zIn: *const ::std::os::raw::c_char, + ) = ::std::mem::transmute(ptr); (fun)(arg1, zIn) } -static __SQLITE3_STR_APPENDCHAR: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_str, - N: ::std::os::raw::c_int, - C: ::std::os::raw::c_char, - ), - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_STR_APPENDCHAR: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_str_appendchar( arg1: *mut sqlite3_str, N: ::std::os::raw::c_int, C: ::std::os::raw::c_char, ) { - let fun = __SQLITE3_STR_APPENDCHAR - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_STR_APPENDCHAR.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_str, + N: ::std::os::raw::c_int, + C: ::std::os::raw::c_char, + ) = ::std::mem::transmute(ptr); (fun)(arg1, N, C) } -static __SQLITE3_STR_RESET: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_STR_RESET: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_str_reset(arg1: *mut sqlite3_str) { - let fun = __SQLITE3_STR_RESET - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_STR_RESET.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_str) = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_STR_ERRCODE: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_STR_ERRCODE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_str_errcode(arg1: *mut sqlite3_str) -> ::std::os::raw::c_int { - let fun = __SQLITE3_STR_ERRCODE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_STR_ERRCODE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_str) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_STR_LENGTH: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_STR_LENGTH: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_str_length(arg1: *mut sqlite3_str) -> ::std::os::raw::c_int { - let fun = __SQLITE3_STR_LENGTH - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_STR_LENGTH.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_str) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_STR_VALUE: ::atomic::Atomic< - Option *mut ::std::os::raw::c_char>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_STR_VALUE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_str_value(arg1: *mut sqlite3_str) -> *mut ::std::os::raw::c_char { - let fun = __SQLITE3_STR_VALUE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_STR_VALUE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_str, + ) -> *mut ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_CREATE_WINDOW_FUNCTION: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: ::std::os::raw::c_int, - arg4: ::std::os::raw::c_int, - arg5: *mut ::std::os::raw::c_void, - xStep: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: ::std::os::raw::c_int, - arg3: *mut *mut sqlite3_value, - ), - >, - xFinal: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut sqlite3_context), - >, - xValue: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut sqlite3_context), - >, - xInv: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_context, - arg2: ::std::os::raw::c_int, - arg3: *mut *mut sqlite3_value, - ), - >, - xDestroy: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_CREATE_WINDOW_FUNCTION: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_create_window_function( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, @@ -6987,151 +6863,165 @@ pub unsafe fn sqlite3_create_window_function( unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), >, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_CREATE_WINDOW_FUNCTION - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_CREATE_WINDOW_FUNCTION + .load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_int, + arg4: ::std::os::raw::c_int, + arg5: *mut ::std::os::raw::c_void, + xStep: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xFinal: ::std::option::Option, + xValue: ::std::option::Option, + xInv: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut sqlite3_context, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ), + >, + xDestroy: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5, xStep, xFinal, xValue, xInv, xDestroy) } -static __SQLITE3_NORMALIZED_SQL: ::atomic::Atomic< - Option< - unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> *const ::std::os::raw::c_char, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_NORMALIZED_SQL: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_normalized_sql( arg1: *mut sqlite3_stmt, ) -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_NORMALIZED_SQL - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_NORMALIZED_SQL.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + ) -> *const ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_STMT_ISEXPLAIN: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_STMT_ISEXPLAIN: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_stmt_isexplain(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int { - let fun = __SQLITE3_STMT_ISEXPLAIN - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_STMT_ISEXPLAIN.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_stmt) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_VALUE_FROMBIND: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_FROMBIND: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_frombind(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int { - let fun = __SQLITE3_VALUE_FROMBIND - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_FROMBIND.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_DROP_MODULES: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *mut *const ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_DROP_MODULES: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_drop_modules( arg1: *mut sqlite3, arg2: *mut *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_DROP_MODULES - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_DROP_MODULES.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *mut *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_HARD_HEAP_LIMIT64: ::atomic::Atomic< - Option sqlite3_int64>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_HARD_HEAP_LIMIT64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_hard_heap_limit64(arg1: sqlite3_int64) -> sqlite3_int64 { - let fun = __SQLITE3_HARD_HEAP_LIMIT64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_HARD_HEAP_LIMIT64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: sqlite3_int64) -> sqlite3_int64 = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_URI_KEY: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *const ::std::os::raw::c_char, - arg2: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_char, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_URI_KEY: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_uri_key( arg1: *const ::std::os::raw::c_char, arg2: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_URI_KEY - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_URI_KEY.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_FILENAME_DATABASE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *const ::std::os::raw::c_char, - ) -> *const ::std::os::raw::c_char, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_FILENAME_DATABASE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_filename_database( arg1: *const ::std::os::raw::c_char, ) -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_FILENAME_DATABASE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_FILENAME_DATABASE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + ) -> *const ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_FILENAME_JOURNAL: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *const ::std::os::raw::c_char, - ) -> *const ::std::os::raw::c_char, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_FILENAME_JOURNAL: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_filename_journal( arg1: *const ::std::os::raw::c_char, ) -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_FILENAME_JOURNAL - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_FILENAME_JOURNAL.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + ) -> *const ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_FILENAME_WAL: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *const ::std::os::raw::c_char, - ) -> *const ::std::os::raw::c_char, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_FILENAME_WAL: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_filename_wal( arg1: *const ::std::os::raw::c_char, ) -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_FILENAME_WAL - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_FILENAME_WAL.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + ) -> *const ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_CREATE_FILENAME: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *const ::std::os::raw::c_char, - arg2: *const ::std::os::raw::c_char, - arg3: *const ::std::os::raw::c_char, - arg4: ::std::os::raw::c_int, - arg5: *mut *const ::std::os::raw::c_char, - ) -> *const ::std::os::raw::c_char, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_CREATE_FILENAME: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_create_filename( arg1: *const ::std::os::raw::c_char, arg2: *const ::std::os::raw::c_char, @@ -7139,94 +7029,88 @@ pub unsafe fn sqlite3_create_filename( arg4: ::std::os::raw::c_int, arg5: *mut *const ::std::os::raw::c_char, ) -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_CREATE_FILENAME - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_CREATE_FILENAME.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + arg2: *const ::std::os::raw::c_char, + arg3: *const ::std::os::raw::c_char, + arg4: ::std::os::raw::c_int, + arg5: *mut *const ::std::os::raw::c_char, + ) -> *const ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5) } -static __SQLITE3_FREE_FILENAME: ::atomic::Atomic< - Option, -> = ::atomic::Atomic::new(None); +static __SQLITE3_FREE_FILENAME: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_free_filename(arg1: *const ::std::os::raw::c_char) { - let fun = __SQLITE3_FREE_FILENAME - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_FREE_FILENAME.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *const ::std::os::raw::c_char) = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_DATABASE_FILE_OBJECT: ::atomic::Atomic< - Option< - unsafe extern "C" fn(arg1: *const ::std::os::raw::c_char) -> *mut sqlite3_file, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_DATABASE_FILE_OBJECT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_database_file_object( arg1: *const ::std::os::raw::c_char, ) -> *mut sqlite3_file { - let fun = __SQLITE3_DATABASE_FILE_OBJECT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_DATABASE_FILE_OBJECT + .load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_char, + ) -> *mut sqlite3_file = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_TXN_STATE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_TXN_STATE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_txn_state( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_TXN_STATE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_TXN_STATE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_CHANGES64: ::atomic::Atomic< - Option sqlite3_int64>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_CHANGES64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_changes64(arg1: *mut sqlite3) -> sqlite3_int64 { - let fun = __SQLITE3_CHANGES64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_CHANGES64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> sqlite3_int64 = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_TOTAL_CHANGES64: ::atomic::Atomic< - Option sqlite3_int64>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_TOTAL_CHANGES64: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_total_changes64(arg1: *mut sqlite3) -> sqlite3_int64 { - let fun = __SQLITE3_TOTAL_CHANGES64 - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_TOTAL_CHANGES64.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> sqlite3_int64 = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_AUTOVACUUM_PAGES: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: ::std::option::Option< - unsafe extern "C" fn( - arg1: *mut ::std::os::raw::c_void, - arg2: *const ::std::os::raw::c_char, - arg3: ::std::os::raw::c_uint, - arg4: ::std::os::raw::c_uint, - arg5: ::std::os::raw::c_uint, - ) -> ::std::os::raw::c_uint, - >, - arg3: *mut ::std::os::raw::c_void, - arg4: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_AUTOVACUUM_PAGES: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_autovacuum_pages( arg1: *mut sqlite3, arg2: ::std::option::Option< @@ -7241,122 +7125,124 @@ pub unsafe fn sqlite3_autovacuum_pages( arg3: *mut ::std::os::raw::c_void, arg4: ::std::option::Option, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_AUTOVACUUM_PAGES - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_AUTOVACUUM_PAGES.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *const ::std::os::raw::c_char, + arg3: ::std::os::raw::c_uint, + arg4: ::std::os::raw::c_uint, + arg5: ::std::os::raw::c_uint, + ) -> ::std::os::raw::c_uint, + >, + arg3: *mut ::std::os::raw::c_void, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_ERROR_OFFSET: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_ERROR_OFFSET: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_error_offset(arg1: *mut sqlite3) -> ::std::os::raw::c_int { - let fun = __SQLITE3_ERROR_OFFSET - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_ERROR_OFFSET.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_VTAB_RHS_VALUE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_index_info, - arg2: ::std::os::raw::c_int, - arg3: *mut *mut sqlite3_value, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VTAB_RHS_VALUE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_vtab_rhs_value( arg1: *mut sqlite3_index_info, arg2: ::std::os::raw::c_int, arg3: *mut *mut sqlite3_value, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_VTAB_RHS_VALUE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VTAB_RHS_VALUE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_index_info, + arg2: ::std::os::raw::c_int, + arg3: *mut *mut sqlite3_value, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_VTAB_DISTINCT: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VTAB_DISTINCT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_vtab_distinct( arg1: *mut sqlite3_index_info, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_VTAB_DISTINCT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VTAB_DISTINCT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_index_info, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1) } -static __SQLITE3_VTAB_IN: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_index_info, - arg2: ::std::os::raw::c_int, - arg3: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VTAB_IN: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_vtab_in( arg1: *mut sqlite3_index_info, arg2: ::std::os::raw::c_int, arg3: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_VTAB_IN - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VTAB_IN.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_index_info, + arg2: ::std::os::raw::c_int, + arg3: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3) } -static __SQLITE3_VTAB_IN_FIRST: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_value, - arg2: *mut *mut sqlite3_value, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VTAB_IN_FIRST: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_vtab_in_first( arg1: *mut sqlite3_value, arg2: *mut *mut sqlite3_value, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_VTAB_IN_FIRST - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VTAB_IN_FIRST.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_value, + arg2: *mut *mut sqlite3_value, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_VTAB_IN_NEXT: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_value, - arg2: *mut *mut sqlite3_value, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VTAB_IN_NEXT: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_vtab_in_next( arg1: *mut sqlite3_value, arg2: *mut *mut sqlite3_value, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_VTAB_IN_NEXT - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VTAB_IN_NEXT.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_value, + arg2: *mut *mut sqlite3_value, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_DESERIALIZE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: *mut ::std::os::raw::c_uchar, - arg4: sqlite3_int64, - arg5: sqlite3_int64, - arg6: ::std::os::raw::c_uint, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_DESERIALIZE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_deserialize( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, @@ -7365,129 +7251,130 @@ pub unsafe fn sqlite3_deserialize( arg5: sqlite3_int64, arg6: ::std::os::raw::c_uint, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_DESERIALIZE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_DESERIALIZE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *mut ::std::os::raw::c_uchar, + arg4: sqlite3_int64, + arg5: sqlite3_int64, + arg6: ::std::os::raw::c_uint, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4, arg5, arg6) } -static __SQLITE3_SERIALIZE: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: *mut sqlite3_int64, - arg4: ::std::os::raw::c_uint, - ) -> *mut ::std::os::raw::c_uchar, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_SERIALIZE: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_serialize( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, arg3: *mut sqlite3_int64, arg4: ::std::os::raw::c_uint, ) -> *mut ::std::os::raw::c_uchar { - let fun = __SQLITE3_SERIALIZE - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_SERIALIZE.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *mut sqlite3_int64, + arg4: ::std::os::raw::c_uint, + ) -> *mut ::std::os::raw::c_uchar = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } -static __SQLITE3_DB_NAME: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_char, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_DB_NAME: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_db_name( arg1: *mut sqlite3, arg2: ::std::os::raw::c_int, ) -> *const ::std::os::raw::c_char { - let fun = __SQLITE3_DB_NAME - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_DB_NAME.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: ::std::os::raw::c_int, + ) -> *const ::std::os::raw::c_char = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_VALUE_ENCODING: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_VALUE_ENCODING: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_value_encoding(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int { - let fun = __SQLITE3_VALUE_ENCODING - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_VALUE_ENCODING.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3_value) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_IS_INTERRUPTED: ::atomic::Atomic< - Option ::std::os::raw::c_int>, -> = ::atomic::Atomic::new(None); +static __SQLITE3_IS_INTERRUPTED: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_is_interrupted(arg1: *mut sqlite3) -> ::std::os::raw::c_int { - let fun = __SQLITE3_IS_INTERRUPTED - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_IS_INTERRUPTED.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn(arg1: *mut sqlite3) -> ::std::os::raw::c_int = ::std::mem::transmute( + ptr, + ); (fun)(arg1) } -static __SQLITE3_STMT_EXPLAIN: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3_stmt, - arg2: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_STMT_EXPLAIN: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_stmt_explain( arg1: *mut sqlite3_stmt, arg2: ::std::os::raw::c_int, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_STMT_EXPLAIN - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_STMT_EXPLAIN.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3_stmt, + arg2: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_GET_CLIENTDATA: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - ) -> *mut ::std::os::raw::c_void, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_GET_CLIENTDATA: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_get_clientdata( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, ) -> *mut ::std::os::raw::c_void { - let fun = __SQLITE3_GET_CLIENTDATA - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_GET_CLIENTDATA.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + ) -> *mut ::std::os::raw::c_void = ::std::mem::transmute(ptr); (fun)(arg1, arg2) } -static __SQLITE3_SET_CLIENTDATA: ::atomic::Atomic< - Option< - unsafe extern "C" fn( - arg1: *mut sqlite3, - arg2: *const ::std::os::raw::c_char, - arg3: *mut ::std::os::raw::c_void, - arg4: ::std::option::Option< - unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), - >, - ) -> ::std::os::raw::c_int, - >, -> = ::atomic::Atomic::new(None); +static __SQLITE3_SET_CLIENTDATA: ::std::sync::atomic::AtomicPtr<()> = ::std::sync::atomic::AtomicPtr::new( + ::std::ptr::null_mut(), +); pub unsafe fn sqlite3_set_clientdata( arg1: *mut sqlite3, arg2: *const ::std::os::raw::c_char, arg3: *mut ::std::os::raw::c_void, arg4: ::std::option::Option, ) -> ::std::os::raw::c_int { - let fun = __SQLITE3_SET_CLIENTDATA - .load(::atomic::Ordering::Acquire) - .expect("SQLite API not initialized or SQLite feature omitted"); + let ptr = __SQLITE3_SET_CLIENTDATA.load(::std::sync::atomic::Ordering::Acquire); + assert!(! ptr.is_null(), "SQLite API not initialized or SQLite feature omitted"); + let fun: unsafe extern "C" fn( + arg1: *mut sqlite3, + arg2: *const ::std::os::raw::c_char, + arg3: *mut ::std::os::raw::c_void, + arg4: ::std::option::Option< + unsafe extern "C" fn(arg1: *mut ::std::os::raw::c_void), + >, + ) -> ::std::os::raw::c_int = ::std::mem::transmute(ptr); (fun)(arg1, arg2, arg3, arg4) } @@ -7495,7 +7382,10 @@ pub unsafe fn sqlite3_set_clientdata( pub unsafe fn rusqlite_extension_init2( p_api: *mut sqlite3_api_routines, ) -> ::std::result::Result<(), crate::InitError> { - __SQLITE3_MALLOC.store((*p_api).malloc, ::atomic::Ordering::Release); + if let Some(fun) = (*p_api).malloc { + __SQLITE3_MALLOC + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } if let Some(fun) = (*p_api).libversion_number { let version = fun(); if SQLITE_VERSION_NUMBER > version { @@ -7507,324 +7397,1034 @@ pub unsafe fn rusqlite_extension_init2( } else { return Err(crate::InitError::NullFunctionPointer); } - __SQLITE3_AGGREGATE_CONTEXT - .store((*p_api).aggregate_context, ::atomic::Ordering::Release); - __SQLITE3_BIND_BLOB.store((*p_api).bind_blob, ::atomic::Ordering::Release); - __SQLITE3_BIND_DOUBLE.store((*p_api).bind_double, ::atomic::Ordering::Release); - __SQLITE3_BIND_INT.store((*p_api).bind_int, ::atomic::Ordering::Release); - __SQLITE3_BIND_INT64.store((*p_api).bind_int64, ::atomic::Ordering::Release); - __SQLITE3_BIND_NULL.store((*p_api).bind_null, ::atomic::Ordering::Release); - __SQLITE3_BIND_PARAMETER_COUNT - .store((*p_api).bind_parameter_count, ::atomic::Ordering::Release); - __SQLITE3_BIND_PARAMETER_INDEX - .store((*p_api).bind_parameter_index, ::atomic::Ordering::Release); - __SQLITE3_BIND_PARAMETER_NAME - .store((*p_api).bind_parameter_name, ::atomic::Ordering::Release); - __SQLITE3_BIND_TEXT.store((*p_api).bind_text, ::atomic::Ordering::Release); - __SQLITE3_BIND_TEXT16.store((*p_api).bind_text16, ::atomic::Ordering::Release); - __SQLITE3_BIND_VALUE.store((*p_api).bind_value, ::atomic::Ordering::Release); - __SQLITE3_BUSY_HANDLER.store((*p_api).busy_handler, ::atomic::Ordering::Release); - __SQLITE3_BUSY_TIMEOUT.store((*p_api).busy_timeout, ::atomic::Ordering::Release); - __SQLITE3_CHANGES.store((*p_api).changes, ::atomic::Ordering::Release); - __SQLITE3_CLOSE.store((*p_api).close, ::atomic::Ordering::Release); - __SQLITE3_COLLATION_NEEDED - .store((*p_api).collation_needed, ::atomic::Ordering::Release); - __SQLITE3_COLLATION_NEEDED16 - .store((*p_api).collation_needed16, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_BLOB.store((*p_api).column_blob, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_BYTES.store((*p_api).column_bytes, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_BYTES16.store((*p_api).column_bytes16, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_COUNT.store((*p_api).column_count, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_DATABASE_NAME - .store((*p_api).column_database_name, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_DATABASE_NAME16 - .store((*p_api).column_database_name16, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_DECLTYPE - .store((*p_api).column_decltype, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_DECLTYPE16 - .store((*p_api).column_decltype16, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_DOUBLE.store((*p_api).column_double, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_INT.store((*p_api).column_int, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_INT64.store((*p_api).column_int64, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_NAME.store((*p_api).column_name, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_NAME16.store((*p_api).column_name16, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_ORIGIN_NAME - .store((*p_api).column_origin_name, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_ORIGIN_NAME16 - .store((*p_api).column_origin_name16, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_TABLE_NAME - .store((*p_api).column_table_name, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_TABLE_NAME16 - .store((*p_api).column_table_name16, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_TEXT.store((*p_api).column_text, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_TEXT16.store((*p_api).column_text16, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_TYPE.store((*p_api).column_type, ::atomic::Ordering::Release); - __SQLITE3_COLUMN_VALUE.store((*p_api).column_value, ::atomic::Ordering::Release); - __SQLITE3_COMMIT_HOOK.store((*p_api).commit_hook, ::atomic::Ordering::Release); - __SQLITE3_COMPLETE.store((*p_api).complete, ::atomic::Ordering::Release); - __SQLITE3_COMPLETE16.store((*p_api).complete16, ::atomic::Ordering::Release); - __SQLITE3_CREATE_COLLATION - .store((*p_api).create_collation, ::atomic::Ordering::Release); - __SQLITE3_CREATE_COLLATION16 - .store((*p_api).create_collation16, ::atomic::Ordering::Release); - __SQLITE3_CREATE_FUNCTION - .store((*p_api).create_function, ::atomic::Ordering::Release); - __SQLITE3_CREATE_FUNCTION16 - .store((*p_api).create_function16, ::atomic::Ordering::Release); - __SQLITE3_CREATE_MODULE.store((*p_api).create_module, ::atomic::Ordering::Release); - __SQLITE3_DATA_COUNT.store((*p_api).data_count, ::atomic::Ordering::Release); - __SQLITE3_DB_HANDLE.store((*p_api).db_handle, ::atomic::Ordering::Release); - __SQLITE3_DECLARE_VTAB.store((*p_api).declare_vtab, ::atomic::Ordering::Release); - __SQLITE3_ENABLE_SHARED_CACHE - .store((*p_api).enable_shared_cache, ::atomic::Ordering::Release); - __SQLITE3_ERRCODE.store((*p_api).errcode, ::atomic::Ordering::Release); - __SQLITE3_ERRMSG.store((*p_api).errmsg, ::atomic::Ordering::Release); - __SQLITE3_ERRMSG16.store((*p_api).errmsg16, ::atomic::Ordering::Release); - __SQLITE3_EXEC.store((*p_api).exec, ::atomic::Ordering::Release); - __SQLITE3_FINALIZE.store((*p_api).finalize, ::atomic::Ordering::Release); - __SQLITE3_FREE.store((*p_api).free, ::atomic::Ordering::Release); - __SQLITE3_FREE_TABLE.store((*p_api).free_table, ::atomic::Ordering::Release); - __SQLITE3_GET_AUTOCOMMIT.store((*p_api).get_autocommit, ::atomic::Ordering::Release); - __SQLITE3_GET_AUXDATA.store((*p_api).get_auxdata, ::atomic::Ordering::Release); - __SQLITE3_GET_TABLE.store((*p_api).get_table, ::atomic::Ordering::Release); - __SQLITE3_INTERRUPT.store((*p_api).interruptx, ::atomic::Ordering::Release); - __SQLITE3_LAST_INSERT_ROWID - .store((*p_api).last_insert_rowid, ::atomic::Ordering::Release); - __SQLITE3_LIBVERSION.store((*p_api).libversion, ::atomic::Ordering::Release); - __SQLITE3_LIBVERSION_NUMBER - .store((*p_api).libversion_number, ::atomic::Ordering::Release); - __SQLITE3_OPEN.store((*p_api).open, ::atomic::Ordering::Release); - __SQLITE3_OPEN16.store((*p_api).open16, ::atomic::Ordering::Release); - __SQLITE3_PREPARE.store((*p_api).prepare, ::atomic::Ordering::Release); - __SQLITE3_PREPARE16.store((*p_api).prepare16, ::atomic::Ordering::Release); - __SQLITE3_PROFILE.store((*p_api).profile, ::atomic::Ordering::Release); - __SQLITE3_PROGRESS_HANDLER - .store((*p_api).progress_handler, ::atomic::Ordering::Release); - __SQLITE3_REALLOC.store((*p_api).realloc, ::atomic::Ordering::Release); - __SQLITE3_RESET.store((*p_api).reset, ::atomic::Ordering::Release); - __SQLITE3_RESULT_BLOB.store((*p_api).result_blob, ::atomic::Ordering::Release); - __SQLITE3_RESULT_DOUBLE.store((*p_api).result_double, ::atomic::Ordering::Release); - __SQLITE3_RESULT_ERROR.store((*p_api).result_error, ::atomic::Ordering::Release); - __SQLITE3_RESULT_ERROR16.store((*p_api).result_error16, ::atomic::Ordering::Release); - __SQLITE3_RESULT_INT.store((*p_api).result_int, ::atomic::Ordering::Release); - __SQLITE3_RESULT_INT64.store((*p_api).result_int64, ::atomic::Ordering::Release); - __SQLITE3_RESULT_NULL.store((*p_api).result_null, ::atomic::Ordering::Release); - __SQLITE3_RESULT_TEXT.store((*p_api).result_text, ::atomic::Ordering::Release); - __SQLITE3_RESULT_TEXT16.store((*p_api).result_text16, ::atomic::Ordering::Release); - __SQLITE3_RESULT_TEXT16BE - .store((*p_api).result_text16be, ::atomic::Ordering::Release); - __SQLITE3_RESULT_TEXT16LE - .store((*p_api).result_text16le, ::atomic::Ordering::Release); - __SQLITE3_RESULT_VALUE.store((*p_api).result_value, ::atomic::Ordering::Release); - __SQLITE3_ROLLBACK_HOOK.store((*p_api).rollback_hook, ::atomic::Ordering::Release); - __SQLITE3_SET_AUTHORIZER.store((*p_api).set_authorizer, ::atomic::Ordering::Release); - __SQLITE3_SET_AUXDATA.store((*p_api).set_auxdata, ::atomic::Ordering::Release); - __SQLITE3_STEP.store((*p_api).step, ::atomic::Ordering::Release); - __SQLITE3_TABLE_COLUMN_METADATA - .store((*p_api).table_column_metadata, ::atomic::Ordering::Release); - __SQLITE3_TOTAL_CHANGES.store((*p_api).total_changes, ::atomic::Ordering::Release); - __SQLITE3_TRACE.store((*p_api).trace, ::atomic::Ordering::Release); - __SQLITE3_UPDATE_HOOK.store((*p_api).update_hook, ::atomic::Ordering::Release); - __SQLITE3_USER_DATA.store((*p_api).user_data, ::atomic::Ordering::Release); - __SQLITE3_VALUE_BLOB.store((*p_api).value_blob, ::atomic::Ordering::Release); - __SQLITE3_VALUE_BYTES.store((*p_api).value_bytes, ::atomic::Ordering::Release); - __SQLITE3_VALUE_BYTES16.store((*p_api).value_bytes16, ::atomic::Ordering::Release); - __SQLITE3_VALUE_DOUBLE.store((*p_api).value_double, ::atomic::Ordering::Release); - __SQLITE3_VALUE_INT.store((*p_api).value_int, ::atomic::Ordering::Release); - __SQLITE3_VALUE_INT64.store((*p_api).value_int64, ::atomic::Ordering::Release); - __SQLITE3_VALUE_NUMERIC_TYPE - .store((*p_api).value_numeric_type, ::atomic::Ordering::Release); - __SQLITE3_VALUE_TEXT.store((*p_api).value_text, ::atomic::Ordering::Release); - __SQLITE3_VALUE_TEXT16.store((*p_api).value_text16, ::atomic::Ordering::Release); - __SQLITE3_VALUE_TEXT16BE.store((*p_api).value_text16be, ::atomic::Ordering::Release); - __SQLITE3_VALUE_TEXT16LE.store((*p_api).value_text16le, ::atomic::Ordering::Release); - __SQLITE3_VALUE_TYPE.store((*p_api).value_type, ::atomic::Ordering::Release); - __SQLITE3_OVERLOAD_FUNCTION - .store((*p_api).overload_function, ::atomic::Ordering::Release); - __SQLITE3_PREPARE_V2.store((*p_api).prepare_v2, ::atomic::Ordering::Release); - __SQLITE3_PREPARE16_V2.store((*p_api).prepare16_v2, ::atomic::Ordering::Release); - __SQLITE3_CLEAR_BINDINGS.store((*p_api).clear_bindings, ::atomic::Ordering::Release); - __SQLITE3_CREATE_MODULE_V2 - .store((*p_api).create_module_v2, ::atomic::Ordering::Release); - __SQLITE3_BIND_ZEROBLOB.store((*p_api).bind_zeroblob, ::atomic::Ordering::Release); - __SQLITE3_BLOB_BYTES.store((*p_api).blob_bytes, ::atomic::Ordering::Release); - __SQLITE3_BLOB_CLOSE.store((*p_api).blob_close, ::atomic::Ordering::Release); - __SQLITE3_BLOB_OPEN.store((*p_api).blob_open, ::atomic::Ordering::Release); - __SQLITE3_BLOB_READ.store((*p_api).blob_read, ::atomic::Ordering::Release); - __SQLITE3_BLOB_WRITE.store((*p_api).blob_write, ::atomic::Ordering::Release); - __SQLITE3_CREATE_COLLATION_V2 - .store((*p_api).create_collation_v2, ::atomic::Ordering::Release); - __SQLITE3_FILE_CONTROL.store((*p_api).file_control, ::atomic::Ordering::Release); - __SQLITE3_MEMORY_HIGHWATER - .store((*p_api).memory_highwater, ::atomic::Ordering::Release); - __SQLITE3_MEMORY_USED.store((*p_api).memory_used, ::atomic::Ordering::Release); - __SQLITE3_MUTEX_ALLOC.store((*p_api).mutex_alloc, ::atomic::Ordering::Release); - __SQLITE3_MUTEX_ENTER.store((*p_api).mutex_enter, ::atomic::Ordering::Release); - __SQLITE3_MUTEX_FREE.store((*p_api).mutex_free, ::atomic::Ordering::Release); - __SQLITE3_MUTEX_LEAVE.store((*p_api).mutex_leave, ::atomic::Ordering::Release); - __SQLITE3_MUTEX_TRY.store((*p_api).mutex_try, ::atomic::Ordering::Release); - __SQLITE3_OPEN_V2.store((*p_api).open_v2, ::atomic::Ordering::Release); - __SQLITE3_RELEASE_MEMORY.store((*p_api).release_memory, ::atomic::Ordering::Release); - __SQLITE3_RESULT_ERROR_NOMEM - .store((*p_api).result_error_nomem, ::atomic::Ordering::Release); - __SQLITE3_RESULT_ERROR_TOOBIG - .store((*p_api).result_error_toobig, ::atomic::Ordering::Release); - __SQLITE3_SLEEP.store((*p_api).sleep, ::atomic::Ordering::Release); - __SQLITE3_SOFT_HEAP_LIMIT - .store((*p_api).soft_heap_limit, ::atomic::Ordering::Release); - __SQLITE3_VFS_FIND.store((*p_api).vfs_find, ::atomic::Ordering::Release); - __SQLITE3_VFS_REGISTER.store((*p_api).vfs_register, ::atomic::Ordering::Release); - __SQLITE3_VFS_UNREGISTER.store((*p_api).vfs_unregister, ::atomic::Ordering::Release); - __SQLITE3_THREADSAFE.store((*p_api).xthreadsafe, ::atomic::Ordering::Release); - __SQLITE3_RESULT_ZEROBLOB - .store((*p_api).result_zeroblob, ::atomic::Ordering::Release); - __SQLITE3_RESULT_ERROR_CODE - .store((*p_api).result_error_code, ::atomic::Ordering::Release); - __SQLITE3_RANDOMNESS.store((*p_api).randomness, ::atomic::Ordering::Release); - __SQLITE3_CONTEXT_DB_HANDLE - .store((*p_api).context_db_handle, ::atomic::Ordering::Release); - __SQLITE3_EXTENDED_RESULT_CODES - .store((*p_api).extended_result_codes, ::atomic::Ordering::Release); - __SQLITE3_LIMIT.store((*p_api).limit, ::atomic::Ordering::Release); - __SQLITE3_NEXT_STMT.store((*p_api).next_stmt, ::atomic::Ordering::Release); - __SQLITE3_SQL.store((*p_api).sql, ::atomic::Ordering::Release); - __SQLITE3_STATUS.store((*p_api).status, ::atomic::Ordering::Release); - __SQLITE3_BACKUP_FINISH.store((*p_api).backup_finish, ::atomic::Ordering::Release); - __SQLITE3_BACKUP_INIT.store((*p_api).backup_init, ::atomic::Ordering::Release); - __SQLITE3_BACKUP_PAGECOUNT - .store((*p_api).backup_pagecount, ::atomic::Ordering::Release); - __SQLITE3_BACKUP_REMAINING - .store((*p_api).backup_remaining, ::atomic::Ordering::Release); - __SQLITE3_BACKUP_STEP.store((*p_api).backup_step, ::atomic::Ordering::Release); - __SQLITE3_COMPILEOPTION_GET - .store((*p_api).compileoption_get, ::atomic::Ordering::Release); - __SQLITE3_COMPILEOPTION_USED - .store((*p_api).compileoption_used, ::atomic::Ordering::Release); - __SQLITE3_CREATE_FUNCTION_V2 - .store((*p_api).create_function_v2, ::atomic::Ordering::Release); - __SQLITE3_DB_CONFIG.store((*p_api).db_config, ::atomic::Ordering::Release); - __SQLITE3_DB_MUTEX.store((*p_api).db_mutex, ::atomic::Ordering::Release); - __SQLITE3_DB_STATUS.store((*p_api).db_status, ::atomic::Ordering::Release); - __SQLITE3_EXTENDED_ERRCODE - .store((*p_api).extended_errcode, ::atomic::Ordering::Release); - __SQLITE3_LOG.store((*p_api).log, ::atomic::Ordering::Release); - __SQLITE3_SOFT_HEAP_LIMIT64 - .store((*p_api).soft_heap_limit64, ::atomic::Ordering::Release); - __SQLITE3_SOURCEID.store((*p_api).sourceid, ::atomic::Ordering::Release); - __SQLITE3_STMT_STATUS.store((*p_api).stmt_status, ::atomic::Ordering::Release); - __SQLITE3_STRNICMP.store((*p_api).strnicmp, ::atomic::Ordering::Release); - __SQLITE3_UNLOCK_NOTIFY.store((*p_api).unlock_notify, ::atomic::Ordering::Release); - __SQLITE3_WAL_AUTOCHECKPOINT - .store((*p_api).wal_autocheckpoint, ::atomic::Ordering::Release); - __SQLITE3_WAL_CHECKPOINT.store((*p_api).wal_checkpoint, ::atomic::Ordering::Release); - __SQLITE3_WAL_HOOK.store((*p_api).wal_hook, ::atomic::Ordering::Release); - __SQLITE3_BLOB_REOPEN.store((*p_api).blob_reopen, ::atomic::Ordering::Release); - __SQLITE3_VTAB_CONFIG.store((*p_api).vtab_config, ::atomic::Ordering::Release); - __SQLITE3_VTAB_ON_CONFLICT - .store((*p_api).vtab_on_conflict, ::atomic::Ordering::Release); - __SQLITE3_CLOSE_V2.store((*p_api).close_v2, ::atomic::Ordering::Release); - __SQLITE3_DB_FILENAME.store((*p_api).db_filename, ::atomic::Ordering::Release); - __SQLITE3_DB_READONLY.store((*p_api).db_readonly, ::atomic::Ordering::Release); - __SQLITE3_DB_RELEASE_MEMORY - .store((*p_api).db_release_memory, ::atomic::Ordering::Release); - __SQLITE3_ERRSTR.store((*p_api).errstr, ::atomic::Ordering::Release); - __SQLITE3_STMT_BUSY.store((*p_api).stmt_busy, ::atomic::Ordering::Release); - __SQLITE3_STMT_READONLY.store((*p_api).stmt_readonly, ::atomic::Ordering::Release); - __SQLITE3_STRICMP.store((*p_api).stricmp, ::atomic::Ordering::Release); - __SQLITE3_URI_BOOLEAN.store((*p_api).uri_boolean, ::atomic::Ordering::Release); - __SQLITE3_URI_INT64.store((*p_api).uri_int64, ::atomic::Ordering::Release); - __SQLITE3_URI_PARAMETER.store((*p_api).uri_parameter, ::atomic::Ordering::Release); - __SQLITE3_WAL_CHECKPOINT_V2 - .store((*p_api).wal_checkpoint_v2, ::atomic::Ordering::Release); - __SQLITE3_AUTO_EXTENSION.store((*p_api).auto_extension, ::atomic::Ordering::Release); - __SQLITE3_BIND_BLOB64.store((*p_api).bind_blob64, ::atomic::Ordering::Release); - __SQLITE3_BIND_TEXT64.store((*p_api).bind_text64, ::atomic::Ordering::Release); - __SQLITE3_CANCEL_AUTO_EXTENSION - .store((*p_api).cancel_auto_extension, ::atomic::Ordering::Release); - __SQLITE3_LOAD_EXTENSION.store((*p_api).load_extension, ::atomic::Ordering::Release); - __SQLITE3_MALLOC64.store((*p_api).malloc64, ::atomic::Ordering::Release); - __SQLITE3_MSIZE.store((*p_api).msize, ::atomic::Ordering::Release); - __SQLITE3_REALLOC64.store((*p_api).realloc64, ::atomic::Ordering::Release); - __SQLITE3_RESET_AUTO_EXTENSION - .store((*p_api).reset_auto_extension, ::atomic::Ordering::Release); - __SQLITE3_RESULT_BLOB64.store((*p_api).result_blob64, ::atomic::Ordering::Release); - __SQLITE3_RESULT_TEXT64.store((*p_api).result_text64, ::atomic::Ordering::Release); - __SQLITE3_STRGLOB.store((*p_api).strglob, ::atomic::Ordering::Release); - __SQLITE3_VALUE_DUP.store((*p_api).value_dup, ::atomic::Ordering::Release); - __SQLITE3_VALUE_FREE.store((*p_api).value_free, ::atomic::Ordering::Release); - __SQLITE3_RESULT_ZEROBLOB64 - .store((*p_api).result_zeroblob64, ::atomic::Ordering::Release); - __SQLITE3_BIND_ZEROBLOB64 - .store((*p_api).bind_zeroblob64, ::atomic::Ordering::Release); - __SQLITE3_VALUE_SUBTYPE.store((*p_api).value_subtype, ::atomic::Ordering::Release); - __SQLITE3_RESULT_SUBTYPE.store((*p_api).result_subtype, ::atomic::Ordering::Release); - __SQLITE3_STATUS64.store((*p_api).status64, ::atomic::Ordering::Release); - __SQLITE3_STRLIKE.store((*p_api).strlike, ::atomic::Ordering::Release); - __SQLITE3_DB_CACHEFLUSH.store((*p_api).db_cacheflush, ::atomic::Ordering::Release); - __SQLITE3_SYSTEM_ERRNO.store((*p_api).system_errno, ::atomic::Ordering::Release); - __SQLITE3_TRACE_V2.store((*p_api).trace_v2, ::atomic::Ordering::Release); - __SQLITE3_EXPANDED_SQL.store((*p_api).expanded_sql, ::atomic::Ordering::Release); - __SQLITE3_SET_LAST_INSERT_ROWID - .store((*p_api).set_last_insert_rowid, ::atomic::Ordering::Release); - __SQLITE3_PREPARE_V3.store((*p_api).prepare_v3, ::atomic::Ordering::Release); - __SQLITE3_PREPARE16_V3.store((*p_api).prepare16_v3, ::atomic::Ordering::Release); - __SQLITE3_BIND_POINTER.store((*p_api).bind_pointer, ::atomic::Ordering::Release); - __SQLITE3_RESULT_POINTER.store((*p_api).result_pointer, ::atomic::Ordering::Release); - __SQLITE3_VALUE_POINTER.store((*p_api).value_pointer, ::atomic::Ordering::Release); - __SQLITE3_VTAB_NOCHANGE.store((*p_api).vtab_nochange, ::atomic::Ordering::Release); - __SQLITE3_VALUE_NOCHANGE.store((*p_api).value_nochange, ::atomic::Ordering::Release); - __SQLITE3_VTAB_COLLATION.store((*p_api).vtab_collation, ::atomic::Ordering::Release); - __SQLITE3_KEYWORD_COUNT.store((*p_api).keyword_count, ::atomic::Ordering::Release); - __SQLITE3_KEYWORD_NAME.store((*p_api).keyword_name, ::atomic::Ordering::Release); - __SQLITE3_KEYWORD_CHECK.store((*p_api).keyword_check, ::atomic::Ordering::Release); - __SQLITE3_STR_NEW.store((*p_api).str_new, ::atomic::Ordering::Release); - __SQLITE3_STR_FINISH.store((*p_api).str_finish, ::atomic::Ordering::Release); - __SQLITE3_STR_APPEND.store((*p_api).str_append, ::atomic::Ordering::Release); - __SQLITE3_STR_APPENDALL.store((*p_api).str_appendall, ::atomic::Ordering::Release); - __SQLITE3_STR_APPENDCHAR.store((*p_api).str_appendchar, ::atomic::Ordering::Release); - __SQLITE3_STR_RESET.store((*p_api).str_reset, ::atomic::Ordering::Release); - __SQLITE3_STR_ERRCODE.store((*p_api).str_errcode, ::atomic::Ordering::Release); - __SQLITE3_STR_LENGTH.store((*p_api).str_length, ::atomic::Ordering::Release); - __SQLITE3_STR_VALUE.store((*p_api).str_value, ::atomic::Ordering::Release); - __SQLITE3_CREATE_WINDOW_FUNCTION - .store((*p_api).create_window_function, ::atomic::Ordering::Release); - __SQLITE3_NORMALIZED_SQL.store((*p_api).normalized_sql, ::atomic::Ordering::Release); - __SQLITE3_STMT_ISEXPLAIN.store((*p_api).stmt_isexplain, ::atomic::Ordering::Release); - __SQLITE3_VALUE_FROMBIND.store((*p_api).value_frombind, ::atomic::Ordering::Release); - __SQLITE3_DROP_MODULES.store((*p_api).drop_modules, ::atomic::Ordering::Release); - __SQLITE3_HARD_HEAP_LIMIT64 - .store((*p_api).hard_heap_limit64, ::atomic::Ordering::Release); - __SQLITE3_URI_KEY.store((*p_api).uri_key, ::atomic::Ordering::Release); - __SQLITE3_FILENAME_DATABASE - .store((*p_api).filename_database, ::atomic::Ordering::Release); - __SQLITE3_FILENAME_JOURNAL - .store((*p_api).filename_journal, ::atomic::Ordering::Release); - __SQLITE3_FILENAME_WAL.store((*p_api).filename_wal, ::atomic::Ordering::Release); - __SQLITE3_CREATE_FILENAME - .store((*p_api).create_filename, ::atomic::Ordering::Release); - __SQLITE3_FREE_FILENAME.store((*p_api).free_filename, ::atomic::Ordering::Release); - __SQLITE3_DATABASE_FILE_OBJECT - .store((*p_api).database_file_object, ::atomic::Ordering::Release); - __SQLITE3_TXN_STATE.store((*p_api).txn_state, ::atomic::Ordering::Release); - __SQLITE3_CHANGES64.store((*p_api).changes64, ::atomic::Ordering::Release); - __SQLITE3_TOTAL_CHANGES64 - .store((*p_api).total_changes64, ::atomic::Ordering::Release); - __SQLITE3_AUTOVACUUM_PAGES - .store((*p_api).autovacuum_pages, ::atomic::Ordering::Release); - __SQLITE3_ERROR_OFFSET.store((*p_api).error_offset, ::atomic::Ordering::Release); - __SQLITE3_VTAB_RHS_VALUE.store((*p_api).vtab_rhs_value, ::atomic::Ordering::Release); - __SQLITE3_VTAB_DISTINCT.store((*p_api).vtab_distinct, ::atomic::Ordering::Release); - __SQLITE3_VTAB_IN.store((*p_api).vtab_in, ::atomic::Ordering::Release); - __SQLITE3_VTAB_IN_FIRST.store((*p_api).vtab_in_first, ::atomic::Ordering::Release); - __SQLITE3_VTAB_IN_NEXT.store((*p_api).vtab_in_next, ::atomic::Ordering::Release); - __SQLITE3_DESERIALIZE.store((*p_api).deserialize, ::atomic::Ordering::Release); - __SQLITE3_SERIALIZE.store((*p_api).serialize, ::atomic::Ordering::Release); - __SQLITE3_DB_NAME.store((*p_api).db_name, ::atomic::Ordering::Release); - __SQLITE3_VALUE_ENCODING.store((*p_api).value_encoding, ::atomic::Ordering::Release); - __SQLITE3_IS_INTERRUPTED.store((*p_api).is_interrupted, ::atomic::Ordering::Release); - __SQLITE3_STMT_EXPLAIN.store((*p_api).stmt_explain, ::atomic::Ordering::Release); - __SQLITE3_GET_CLIENTDATA.store((*p_api).get_clientdata, ::atomic::Ordering::Release); - __SQLITE3_SET_CLIENTDATA.store((*p_api).set_clientdata, ::atomic::Ordering::Release); + if let Some(fun) = (*p_api).aggregate_context { + __SQLITE3_AGGREGATE_CONTEXT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).bind_blob { + __SQLITE3_BIND_BLOB + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).bind_double { + __SQLITE3_BIND_DOUBLE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).bind_int { + __SQLITE3_BIND_INT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).bind_int64 { + __SQLITE3_BIND_INT64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).bind_null { + __SQLITE3_BIND_NULL + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).bind_parameter_count { + __SQLITE3_BIND_PARAMETER_COUNT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).bind_parameter_index { + __SQLITE3_BIND_PARAMETER_INDEX + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).bind_parameter_name { + __SQLITE3_BIND_PARAMETER_NAME + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).bind_text { + __SQLITE3_BIND_TEXT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).bind_text16 { + __SQLITE3_BIND_TEXT16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).bind_value { + __SQLITE3_BIND_VALUE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).busy_handler { + __SQLITE3_BUSY_HANDLER + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).busy_timeout { + __SQLITE3_BUSY_TIMEOUT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).changes { + __SQLITE3_CHANGES + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).close { + __SQLITE3_CLOSE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).collation_needed { + __SQLITE3_COLLATION_NEEDED + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).collation_needed16 { + __SQLITE3_COLLATION_NEEDED16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_blob { + __SQLITE3_COLUMN_BLOB + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_bytes { + __SQLITE3_COLUMN_BYTES + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_bytes16 { + __SQLITE3_COLUMN_BYTES16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_count { + __SQLITE3_COLUMN_COUNT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_database_name { + __SQLITE3_COLUMN_DATABASE_NAME + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_database_name16 { + __SQLITE3_COLUMN_DATABASE_NAME16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_decltype { + __SQLITE3_COLUMN_DECLTYPE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_decltype16 { + __SQLITE3_COLUMN_DECLTYPE16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_double { + __SQLITE3_COLUMN_DOUBLE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_int { + __SQLITE3_COLUMN_INT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_int64 { + __SQLITE3_COLUMN_INT64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_name { + __SQLITE3_COLUMN_NAME + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_name16 { + __SQLITE3_COLUMN_NAME16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_origin_name { + __SQLITE3_COLUMN_ORIGIN_NAME + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_origin_name16 { + __SQLITE3_COLUMN_ORIGIN_NAME16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_table_name { + __SQLITE3_COLUMN_TABLE_NAME + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_table_name16 { + __SQLITE3_COLUMN_TABLE_NAME16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_text { + __SQLITE3_COLUMN_TEXT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_text16 { + __SQLITE3_COLUMN_TEXT16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_type { + __SQLITE3_COLUMN_TYPE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).column_value { + __SQLITE3_COLUMN_VALUE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).commit_hook { + __SQLITE3_COMMIT_HOOK + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).complete { + __SQLITE3_COMPLETE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).complete16 { + __SQLITE3_COMPLETE16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).create_collation { + __SQLITE3_CREATE_COLLATION + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).create_collation16 { + __SQLITE3_CREATE_COLLATION16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).create_function { + __SQLITE3_CREATE_FUNCTION + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).create_function16 { + __SQLITE3_CREATE_FUNCTION16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).create_module { + __SQLITE3_CREATE_MODULE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).data_count { + __SQLITE3_DATA_COUNT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).db_handle { + __SQLITE3_DB_HANDLE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).declare_vtab { + __SQLITE3_DECLARE_VTAB + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).enable_shared_cache { + __SQLITE3_ENABLE_SHARED_CACHE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).errcode { + __SQLITE3_ERRCODE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).errmsg { + __SQLITE3_ERRMSG + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).errmsg16 { + __SQLITE3_ERRMSG16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).exec { + __SQLITE3_EXEC + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).finalize { + __SQLITE3_FINALIZE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).free { + __SQLITE3_FREE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).free_table { + __SQLITE3_FREE_TABLE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).get_autocommit { + __SQLITE3_GET_AUTOCOMMIT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).get_auxdata { + __SQLITE3_GET_AUXDATA + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).get_table { + __SQLITE3_GET_TABLE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).interruptx { + __SQLITE3_INTERRUPT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).last_insert_rowid { + __SQLITE3_LAST_INSERT_ROWID + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).libversion { + __SQLITE3_LIBVERSION + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).libversion_number { + __SQLITE3_LIBVERSION_NUMBER + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).open { + __SQLITE3_OPEN + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).open16 { + __SQLITE3_OPEN16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).prepare { + __SQLITE3_PREPARE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).prepare16 { + __SQLITE3_PREPARE16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).profile { + __SQLITE3_PROFILE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).progress_handler { + __SQLITE3_PROGRESS_HANDLER + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).realloc { + __SQLITE3_REALLOC + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).reset { + __SQLITE3_RESET + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_blob { + __SQLITE3_RESULT_BLOB + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_double { + __SQLITE3_RESULT_DOUBLE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_error { + __SQLITE3_RESULT_ERROR + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_error16 { + __SQLITE3_RESULT_ERROR16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_int { + __SQLITE3_RESULT_INT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_int64 { + __SQLITE3_RESULT_INT64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_null { + __SQLITE3_RESULT_NULL + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_text { + __SQLITE3_RESULT_TEXT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_text16 { + __SQLITE3_RESULT_TEXT16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_text16be { + __SQLITE3_RESULT_TEXT16BE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_text16le { + __SQLITE3_RESULT_TEXT16LE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_value { + __SQLITE3_RESULT_VALUE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).rollback_hook { + __SQLITE3_ROLLBACK_HOOK + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).set_authorizer { + __SQLITE3_SET_AUTHORIZER + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).set_auxdata { + __SQLITE3_SET_AUXDATA + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).step { + __SQLITE3_STEP + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).table_column_metadata { + __SQLITE3_TABLE_COLUMN_METADATA + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).total_changes { + __SQLITE3_TOTAL_CHANGES + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).trace { + __SQLITE3_TRACE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).update_hook { + __SQLITE3_UPDATE_HOOK + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).user_data { + __SQLITE3_USER_DATA + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_blob { + __SQLITE3_VALUE_BLOB + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_bytes { + __SQLITE3_VALUE_BYTES + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_bytes16 { + __SQLITE3_VALUE_BYTES16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_double { + __SQLITE3_VALUE_DOUBLE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_int { + __SQLITE3_VALUE_INT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_int64 { + __SQLITE3_VALUE_INT64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_numeric_type { + __SQLITE3_VALUE_NUMERIC_TYPE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_text { + __SQLITE3_VALUE_TEXT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_text16 { + __SQLITE3_VALUE_TEXT16 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_text16be { + __SQLITE3_VALUE_TEXT16BE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_text16le { + __SQLITE3_VALUE_TEXT16LE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_type { + __SQLITE3_VALUE_TYPE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).overload_function { + __SQLITE3_OVERLOAD_FUNCTION + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).prepare_v2 { + __SQLITE3_PREPARE_V2 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).prepare16_v2 { + __SQLITE3_PREPARE16_V2 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).clear_bindings { + __SQLITE3_CLEAR_BINDINGS + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).create_module_v2 { + __SQLITE3_CREATE_MODULE_V2 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).bind_zeroblob { + __SQLITE3_BIND_ZEROBLOB + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).blob_bytes { + __SQLITE3_BLOB_BYTES + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).blob_close { + __SQLITE3_BLOB_CLOSE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).blob_open { + __SQLITE3_BLOB_OPEN + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).blob_read { + __SQLITE3_BLOB_READ + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).blob_write { + __SQLITE3_BLOB_WRITE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).create_collation_v2 { + __SQLITE3_CREATE_COLLATION_V2 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).file_control { + __SQLITE3_FILE_CONTROL + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).memory_highwater { + __SQLITE3_MEMORY_HIGHWATER + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).memory_used { + __SQLITE3_MEMORY_USED + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).mutex_alloc { + __SQLITE3_MUTEX_ALLOC + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).mutex_enter { + __SQLITE3_MUTEX_ENTER + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).mutex_free { + __SQLITE3_MUTEX_FREE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).mutex_leave { + __SQLITE3_MUTEX_LEAVE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).mutex_try { + __SQLITE3_MUTEX_TRY + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).open_v2 { + __SQLITE3_OPEN_V2 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).release_memory { + __SQLITE3_RELEASE_MEMORY + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_error_nomem { + __SQLITE3_RESULT_ERROR_NOMEM + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_error_toobig { + __SQLITE3_RESULT_ERROR_TOOBIG + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).sleep { + __SQLITE3_SLEEP + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).soft_heap_limit { + __SQLITE3_SOFT_HEAP_LIMIT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).vfs_find { + __SQLITE3_VFS_FIND + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).vfs_register { + __SQLITE3_VFS_REGISTER + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).vfs_unregister { + __SQLITE3_VFS_UNREGISTER + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).xthreadsafe { + __SQLITE3_THREADSAFE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_zeroblob { + __SQLITE3_RESULT_ZEROBLOB + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_error_code { + __SQLITE3_RESULT_ERROR_CODE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).randomness { + __SQLITE3_RANDOMNESS + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).context_db_handle { + __SQLITE3_CONTEXT_DB_HANDLE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).extended_result_codes { + __SQLITE3_EXTENDED_RESULT_CODES + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).limit { + __SQLITE3_LIMIT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).next_stmt { + __SQLITE3_NEXT_STMT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).sql { + __SQLITE3_SQL + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).status { + __SQLITE3_STATUS + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).backup_finish { + __SQLITE3_BACKUP_FINISH + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).backup_init { + __SQLITE3_BACKUP_INIT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).backup_pagecount { + __SQLITE3_BACKUP_PAGECOUNT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).backup_remaining { + __SQLITE3_BACKUP_REMAINING + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).backup_step { + __SQLITE3_BACKUP_STEP + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).compileoption_get { + __SQLITE3_COMPILEOPTION_GET + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).compileoption_used { + __SQLITE3_COMPILEOPTION_USED + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).create_function_v2 { + __SQLITE3_CREATE_FUNCTION_V2 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).db_config { + __SQLITE3_DB_CONFIG + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).db_mutex { + __SQLITE3_DB_MUTEX + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).db_status { + __SQLITE3_DB_STATUS + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).extended_errcode { + __SQLITE3_EXTENDED_ERRCODE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).log { + __SQLITE3_LOG + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).soft_heap_limit64 { + __SQLITE3_SOFT_HEAP_LIMIT64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).sourceid { + __SQLITE3_SOURCEID + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).stmt_status { + __SQLITE3_STMT_STATUS + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).strnicmp { + __SQLITE3_STRNICMP + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).unlock_notify { + __SQLITE3_UNLOCK_NOTIFY + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).wal_autocheckpoint { + __SQLITE3_WAL_AUTOCHECKPOINT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).wal_checkpoint { + __SQLITE3_WAL_CHECKPOINT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).wal_hook { + __SQLITE3_WAL_HOOK + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).blob_reopen { + __SQLITE3_BLOB_REOPEN + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).vtab_config { + __SQLITE3_VTAB_CONFIG + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).vtab_on_conflict { + __SQLITE3_VTAB_ON_CONFLICT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).close_v2 { + __SQLITE3_CLOSE_V2 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).db_filename { + __SQLITE3_DB_FILENAME + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).db_readonly { + __SQLITE3_DB_READONLY + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).db_release_memory { + __SQLITE3_DB_RELEASE_MEMORY + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).errstr { + __SQLITE3_ERRSTR + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).stmt_busy { + __SQLITE3_STMT_BUSY + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).stmt_readonly { + __SQLITE3_STMT_READONLY + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).stricmp { + __SQLITE3_STRICMP + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).uri_boolean { + __SQLITE3_URI_BOOLEAN + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).uri_int64 { + __SQLITE3_URI_INT64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).uri_parameter { + __SQLITE3_URI_PARAMETER + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).wal_checkpoint_v2 { + __SQLITE3_WAL_CHECKPOINT_V2 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).auto_extension { + __SQLITE3_AUTO_EXTENSION + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).bind_blob64 { + __SQLITE3_BIND_BLOB64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).bind_text64 { + __SQLITE3_BIND_TEXT64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).cancel_auto_extension { + __SQLITE3_CANCEL_AUTO_EXTENSION + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).load_extension { + __SQLITE3_LOAD_EXTENSION + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).malloc64 { + __SQLITE3_MALLOC64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).msize { + __SQLITE3_MSIZE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).realloc64 { + __SQLITE3_REALLOC64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).reset_auto_extension { + __SQLITE3_RESET_AUTO_EXTENSION + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_blob64 { + __SQLITE3_RESULT_BLOB64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_text64 { + __SQLITE3_RESULT_TEXT64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).strglob { + __SQLITE3_STRGLOB + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_dup { + __SQLITE3_VALUE_DUP + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_free { + __SQLITE3_VALUE_FREE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_zeroblob64 { + __SQLITE3_RESULT_ZEROBLOB64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).bind_zeroblob64 { + __SQLITE3_BIND_ZEROBLOB64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_subtype { + __SQLITE3_VALUE_SUBTYPE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_subtype { + __SQLITE3_RESULT_SUBTYPE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).status64 { + __SQLITE3_STATUS64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).strlike { + __SQLITE3_STRLIKE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).db_cacheflush { + __SQLITE3_DB_CACHEFLUSH + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).system_errno { + __SQLITE3_SYSTEM_ERRNO + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).trace_v2 { + __SQLITE3_TRACE_V2 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).expanded_sql { + __SQLITE3_EXPANDED_SQL + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).set_last_insert_rowid { + __SQLITE3_SET_LAST_INSERT_ROWID + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).prepare_v3 { + __SQLITE3_PREPARE_V3 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).prepare16_v3 { + __SQLITE3_PREPARE16_V3 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).bind_pointer { + __SQLITE3_BIND_POINTER + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).result_pointer { + __SQLITE3_RESULT_POINTER + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_pointer { + __SQLITE3_VALUE_POINTER + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).vtab_nochange { + __SQLITE3_VTAB_NOCHANGE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_nochange { + __SQLITE3_VALUE_NOCHANGE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).vtab_collation { + __SQLITE3_VTAB_COLLATION + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).keyword_count { + __SQLITE3_KEYWORD_COUNT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).keyword_name { + __SQLITE3_KEYWORD_NAME + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).keyword_check { + __SQLITE3_KEYWORD_CHECK + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).str_new { + __SQLITE3_STR_NEW + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).str_finish { + __SQLITE3_STR_FINISH + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).str_append { + __SQLITE3_STR_APPEND + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).str_appendall { + __SQLITE3_STR_APPENDALL + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).str_appendchar { + __SQLITE3_STR_APPENDCHAR + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).str_reset { + __SQLITE3_STR_RESET + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).str_errcode { + __SQLITE3_STR_ERRCODE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).str_length { + __SQLITE3_STR_LENGTH + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).str_value { + __SQLITE3_STR_VALUE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).create_window_function { + __SQLITE3_CREATE_WINDOW_FUNCTION + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).normalized_sql { + __SQLITE3_NORMALIZED_SQL + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).stmt_isexplain { + __SQLITE3_STMT_ISEXPLAIN + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_frombind { + __SQLITE3_VALUE_FROMBIND + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).drop_modules { + __SQLITE3_DROP_MODULES + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).hard_heap_limit64 { + __SQLITE3_HARD_HEAP_LIMIT64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).uri_key { + __SQLITE3_URI_KEY + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).filename_database { + __SQLITE3_FILENAME_DATABASE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).filename_journal { + __SQLITE3_FILENAME_JOURNAL + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).filename_wal { + __SQLITE3_FILENAME_WAL + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).create_filename { + __SQLITE3_CREATE_FILENAME + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).free_filename { + __SQLITE3_FREE_FILENAME + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).database_file_object { + __SQLITE3_DATABASE_FILE_OBJECT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).txn_state { + __SQLITE3_TXN_STATE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).changes64 { + __SQLITE3_CHANGES64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).total_changes64 { + __SQLITE3_TOTAL_CHANGES64 + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).autovacuum_pages { + __SQLITE3_AUTOVACUUM_PAGES + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).error_offset { + __SQLITE3_ERROR_OFFSET + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).vtab_rhs_value { + __SQLITE3_VTAB_RHS_VALUE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).vtab_distinct { + __SQLITE3_VTAB_DISTINCT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).vtab_in { + __SQLITE3_VTAB_IN + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).vtab_in_first { + __SQLITE3_VTAB_IN_FIRST + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).vtab_in_next { + __SQLITE3_VTAB_IN_NEXT + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).deserialize { + __SQLITE3_DESERIALIZE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).serialize { + __SQLITE3_SERIALIZE + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).db_name { + __SQLITE3_DB_NAME + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).value_encoding { + __SQLITE3_VALUE_ENCODING + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).is_interrupted { + __SQLITE3_IS_INTERRUPTED + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).stmt_explain { + __SQLITE3_STMT_EXPLAIN + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).get_clientdata { + __SQLITE3_GET_CLIENTDATA + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } + if let Some(fun) = (*p_api).set_clientdata { + __SQLITE3_SET_CLIENTDATA + .store(fun as usize as *mut (), ::std::sync::atomic::Ordering::Release); + } Ok(()) } diff --git a/libsqlite3-sys/upgrade.sh b/libsqlite3-sys/upgrade.sh index 5a9da28..6c50da6 100755 --- a/libsqlite3-sys/upgrade.sh +++ b/libsqlite3-sys/upgrade.sh @@ -28,12 +28,13 @@ find "$TARGET_DIR" -type f -name bindgen.rs -exec mv {} "$SQLITE3_LIB_DIR/bindge # Regenerate bindgen file for sqlite3ext.h # some sqlite3_api_routines fields are function pointers with va_list arg but currently stable Rust doesn't support this type. # FIXME how to generate portable bindings without : -sed -i'' -e 's/va_list/void*/' "$SQLITE3_LIB_DIR/sqlite3ext.h" +sed -i.bk -e 's/va_list/void*/' "$SQLITE3_LIB_DIR/sqlite3ext.h" rm -f "$SQLITE3_LIB_DIR/bindgen_bundled_version_ext.rs" find "$TARGET_DIR" -type f -name bindgen.rs -exec rm {} \; env LIBSQLITE3_SYS_BUNDLING=1 cargo build --features "buildtime_bindgen loadable_extension" --no-default-features find "$TARGET_DIR" -type f -name bindgen.rs -exec mv {} "$SQLITE3_LIB_DIR/bindgen_bundled_version_ext.rs" \; git checkout "$SQLITE3_LIB_DIR/sqlite3ext.h" +rm -f "$SQLITE3_LIB_DIR/sqlite3ext.h.bk" # Sanity checks cd "$SCRIPT_DIR/.." || { echo "fatal error" >&2; exit 1; } From 0b1224620ce824e823bc4261320152fa80e7d289 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sun, 12 Nov 2023 13:00:23 +0100 Subject: [PATCH 42/63] Bump sqlite3-parser version --- rusqlite-macros/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rusqlite-macros/Cargo.toml b/rusqlite-macros/Cargo.toml index 2fad35b..ab3ea51 100644 --- a/rusqlite-macros/Cargo.toml +++ b/rusqlite-macros/Cargo.toml @@ -12,5 +12,5 @@ categories = ["database"] proc-macro = true [dependencies] -sqlite3-parser = { version = "0.11", default-features = false, features = ["YYNOERRORRECOVERY"] } +sqlite3-parser = { version = "0.12", default-features = false, features = ["YYNOERRORRECOVERY"] } fallible-iterator = "0.3" From be9741f18e058ea66fa0fcad2d0e58bf09566045 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sun, 12 Nov 2023 13:23:16 +0100 Subject: [PATCH 43/63] Prepare next release --- Cargo.toml | 4 ++-- README.md | 8 ++++---- libsqlite3-sys/Cargo.toml | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1e8f6ed..f8d915e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rusqlite" # Note: Update version in README.md when you change this. -version = "0.29.0" +version = "0.30.0" authors = ["The rusqlite developers"] edition = "2021" description = "Ergonomic wrapper for SQLite" @@ -140,7 +140,7 @@ bencher = "0.1" [dependencies.libsqlite3-sys] path = "libsqlite3-sys" -version = "0.26.0" +version = "0.27.0" [[test]] name = "config_log" diff --git a/README.md b/README.md index dfed8dc..13db5ff 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ In your Cargo.toml: # That said, it's not ideal for all scenarios and in particular, generic # libraries built around `rusqlite` should probably not enable it, which # is why it is not a default feature -- it could become hard to disable. -rusqlite = { version = "0.29.0", features = ["bundled"] } +rusqlite = { version = "0.30.0", features = ["bundled"] } ``` Simple example usage: @@ -149,11 +149,11 @@ You can adjust this behavior in a number of ways: * If you use the `bundled`, `bundled-sqlcipher`, or `bundled-sqlcipher-vendored-openssl` features, `libsqlite3-sys` will use the [cc](https://crates.io/crates/cc) crate to compile SQLite or SQLCipher from source and link against that. This source is embedded in the `libsqlite3-sys` crate and - is currently SQLite 3.41.2 (as of `rusqlite` 0.29.0 / `libsqlite3-sys` - 0.26.0). This is probably the simplest solution to any build problems. You can enable this by adding the following in your `Cargo.toml` file: + is currently SQLite 3.44.0 (as of `rusqlite` 0.30.0 / `libsqlite3-sys` + 0.27.0). This is probably the simplest solution to any build problems. You can enable this by adding the following in your `Cargo.toml` file: ```toml [dependencies.rusqlite] - version = "0.29.0" + version = "0.30.0" features = ["bundled"] ``` * When using any of the `bundled` features, the build script will honor `SQLITE_MAX_VARIABLE_NUMBER` and `SQLITE_MAX_EXPR_DEPTH` variables. It will also honor a `LIBSQLITE3_FLAGS` variable, which can have a format like `"-USQLITE_ALPHA -DSQLITE_BETA SQLITE_GAMMA ..."`. That would disable the `SQLITE_ALPHA` flag, and set the `SQLITE_BETA` and `SQLITE_GAMMA` flags. (The initial `-D` can be omitted, as on the last one.) diff --git a/libsqlite3-sys/Cargo.toml b/libsqlite3-sys/Cargo.toml index 15ec486..248c69c 100644 --- a/libsqlite3-sys/Cargo.toml +++ b/libsqlite3-sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libsqlite3-sys" -version = "0.26.0" +version = "0.27.0" authors = ["The rusqlite developers"] edition = "2021" repository = "https://github.com/rusqlite/rusqlite" From 7dfbc4b8d12986f6a23b38c6d81b66b25f9ef882 Mon Sep 17 00:00:00 2001 From: gwenn Date: Wed, 22 Nov 2023 20:31:47 +0100 Subject: [PATCH 44/63] Show pathological cases --- src/row.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/row.rs b/src/row.rs index 2d25900..d9022b2 100644 --- a/src/row.rs +++ b/src/row.rs @@ -585,4 +585,24 @@ mod tests { // We don't test one bigger because it's unimplemented Ok(()) } + + #[test] + #[cfg(feature = "bundled")] + fn pathological_case() -> Result<()> { + let conn = Connection::open_in_memory()?; + conn.execute_batch( + "CREATE TABLE foo(x); + CREATE TRIGGER oops BEFORE INSERT ON foo BEGIN SELECT RAISE(FAIL, 'Boom'); END;", + )?; + let mut stmt = conn.prepare("INSERT INTO foo VALUES (0) RETURNING rowid;")?; + { + let n = stmt.query_map([], |_| Ok(()))?.count(); + assert_eq!(1, n); // should be 0 + } + { + let last = stmt.query_map([], |_| Ok(()))?.last(); + assert!(last.is_some()); // should be none + } + Ok(()) + } } From 50dca916988e20f6fb0462a65729b4564fb70607 Mon Sep 17 00:00:00 2001 From: gwenn Date: Fri, 24 Nov 2023 20:09:45 +0100 Subject: [PATCH 45/63] Standard iterator vs Fallible iterator --- src/row.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/row.rs b/src/row.rs index d9022b2..64873d1 100644 --- a/src/row.rs +++ b/src/row.rs @@ -596,12 +596,18 @@ mod tests { )?; let mut stmt = conn.prepare("INSERT INTO foo VALUES (0) RETURNING rowid;")?; { - let n = stmt.query_map([], |_| Ok(()))?.count(); - assert_eq!(1, n); // should be 0 + let iterator_count = stmt.query_map([], |_| Ok(()))?.count(); + assert_eq!(1, iterator_count); // should be 0 + use fallible_streaming_iterator::FallibleStreamingIterator; + let fallible_iterator_count = stmt.query([])?.count().unwrap_or(0); + assert_eq!(0, fallible_iterator_count); } { - let last = stmt.query_map([], |_| Ok(()))?.last(); - assert!(last.is_some()); // should be none + let iterator_last = stmt.query_map([], |_| Ok(()))?.last(); + assert!(iterator_last.is_some()); // should be none + use fallible_iterator::FallibleIterator; + let fallible_iterator_last = stmt.query([])?.map(|_| Ok(())).last(); + assert!(fallible_iterator_last.is_err()); } Ok(()) } From 87d81cd46bee11ed6a82e4b87ddff94c9a3e09f1 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 25 Nov 2023 10:13:55 +0100 Subject: [PATCH 46/63] Check sqlite3_reset result https://sqlite.org/c3ref/reset.html > Therefore, it is important that applications check the return code from sqlite3_reset(S) even if no prior call to sqlite3_step(S) indicated a problem. --- src/row.rs | 13 ++++++++----- src/statement.rs | 16 +++++++++++----- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/row.rs b/src/row.rs index 2d25900..e206f9e 100644 --- a/src/row.rs +++ b/src/row.rs @@ -14,9 +14,11 @@ pub struct Rows<'stmt> { impl<'stmt> Rows<'stmt> { #[inline] - fn reset(&mut self) { + fn reset(&mut self) -> Result<()> { if let Some(stmt) = self.stmt.take() { - stmt.reset(); + stmt.reset() + } else { + Ok(()) } } @@ -105,6 +107,7 @@ impl<'stmt> Rows<'stmt> { } impl Drop for Rows<'_> { + #[allow(unused_must_use)] #[inline] fn drop(&mut self) { self.reset(); @@ -217,12 +220,12 @@ impl<'stmt> FallibleStreamingIterator for Rows<'stmt> { Ok(()) } Ok(false) => { - self.reset(); + let r = self.reset(); self.row = None; - Ok(()) + r } Err(e) => { - self.reset(); + let _ = self.reset(); // prevents infinite loop on error self.row = None; Err(e) } diff --git a/src/statement.rs b/src/statement.rs index d39cc1f..edc1870 100644 --- a/src/statement.rs +++ b/src/statement.rs @@ -650,9 +650,12 @@ impl Statement<'_> { fn execute_with_bound_parameters(&mut self) -> Result { self.check_update()?; let r = self.stmt.step(); - self.stmt.reset(); + let rr = self.stmt.reset(); match r { - ffi::SQLITE_DONE => Ok(self.conn.changes() as usize), + ffi::SQLITE_DONE => match rr { + ffi::SQLITE_OK => Ok(self.conn.changes() as usize), + _ => Err(self.conn.decode_result(rr).unwrap_err()), + }, ffi::SQLITE_ROW => Err(Error::ExecuteReturnedResults), _ => Err(self.conn.decode_result(r).unwrap_err()), } @@ -847,8 +850,11 @@ impl Statement<'_> { } #[inline] - pub(super) fn reset(&self) -> c_int { - self.stmt.reset() + pub(super) fn reset(&self) -> Result<()> { + match self.stmt.reset() { + ffi::SQLITE_OK => Ok(()), + code => Err(self.conn.decode_result(code).unwrap_err()), + } } } @@ -1274,7 +1280,7 @@ mod test { assert_eq!(0, stmt.column_count()); stmt.parameter_index("test").unwrap(); stmt.step().unwrap_err(); - stmt.reset(); + stmt.reset().unwrap(); // SQLITE_OMIT_AUTORESET = false stmt.execute([]).unwrap_err(); Ok(()) } From 8675e453f319c4be472380291e552dee9f4fec8f Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 25 Nov 2023 10:36:07 +0100 Subject: [PATCH 47/63] Add unrelated test just to keep code coverage the same --- src/lib.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index cb4b14b..cebe4f7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1494,7 +1494,7 @@ mod test { #[test] #[cfg(feature = "extra_check")] - fn test_execute_select() { + fn test_execute_select_with_no_row() { let db = checked_memory_handle(); let err = db.execute("SELECT 1 WHERE 1 < ?1", [1i32]).unwrap_err(); assert_eq!( @@ -1504,6 +1504,17 @@ mod test { ); } + #[test] + fn test_execute_select_with_row() { + let db = checked_memory_handle(); + let err = db.execute("SELECT 1", []).unwrap_err(); + assert_eq!( + err, + Error::ExecuteReturnedResults, + "Unexpected error: {err}" + ); + } + #[test] #[cfg(feature = "extra_check")] fn test_execute_multiple() { From 9ebca71317a7f665f4a2ef7e49ca70f754662aa5 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 25 Nov 2023 10:47:38 +0100 Subject: [PATCH 48/63] Misc --- src/lib.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index cebe4f7..2e1aeb5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1508,11 +1508,7 @@ mod test { fn test_execute_select_with_row() { let db = checked_memory_handle(); let err = db.execute("SELECT 1", []).unwrap_err(); - assert_eq!( - err, - Error::ExecuteReturnedResults, - "Unexpected error: {err}" - ); + assert_eq!(err, Error::ExecuteReturnedResults); } #[test] From 675a9981cf464c865c6a5c888e922db3bd1a98aa Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 16 Dec 2023 10:01:53 +0100 Subject: [PATCH 49/63] Apply patch https://salsa.debian.org/rust-team/debcargo-conf/-/blob/529c3c84306436a723ea0f1595465fa61017b988/src/rusqlite/debian/patches/fix-tests-unsigned-char.patch --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 2e1aeb5..1448707 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1881,7 +1881,7 @@ mod test { #[test] fn test_from_handle_owned() -> Result<()> { let mut handle: *mut ffi::sqlite3 = std::ptr::null_mut(); - let r = unsafe { ffi::sqlite3_open(":memory:\0".as_ptr() as *const i8, &mut handle) }; + let r = unsafe { ffi::sqlite3_open(":memory:\0".as_ptr() as *const c_char, &mut handle) }; assert_eq!(r, ffi::SQLITE_OK); let db = unsafe { Connection::from_handle_owned(handle) }?; db.execute_batch("PRAGMA VACUUM")?; From e42e8f0ec390899cc2c50c1b5c5f8860bb8d542e Mon Sep 17 00:00:00 2001 From: gwenn Date: Wed, 20 Dec 2023 18:51:58 +0100 Subject: [PATCH 50/63] Fix features required by loadable_extension example --- Cargo.toml | 4 ++-- examples/loadable_extension.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f8d915e..94cc830 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -163,11 +163,11 @@ harness = false [[example]] name = "loadable_extension" crate-type = ["cdylib"] -required-features = ["loadable_extension", "modern_sqlite", "functions", "vtab", "trace"] +required-features = ["loadable_extension", "functions", "trace"] [[example]] name = "load_extension" -required-features = ["load_extension", "bundled", "functions", "vtab", "trace"] +required-features = ["load_extension", "bundled", "functions", "trace"] [package.metadata.docs.rs] features = ["modern-full", "rusqlite-macros"] diff --git a/examples/loadable_extension.rs b/examples/loadable_extension.rs index e913240..5a197d3 100644 --- a/examples/loadable_extension.rs +++ b/examples/loadable_extension.rs @@ -8,7 +8,7 @@ use rusqlite::{to_sqlite_error, Connection, Result}; /// # build /// ```sh -/// cargo build --example loadable_extension --features "loadable_extension modern_sqlite functions vtab trace" +/// cargo build --example loadable_extension --features "loadable_extension functions trace" /// ``` /// # test /// ```sh From 1e73859eb3ff3724797dda859811deb4fe673124 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 23 Dec 2023 11:42:38 +0100 Subject: [PATCH 51/63] Handle the case when there is no placeholder --- rusqlite-macros/src/lib.rs | 2 +- rusqlite-macros/tests/test.rs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/rusqlite-macros/src/lib.rs b/rusqlite-macros/src/lib.rs index 8dda22c..308d5fd 100644 --- a/rusqlite-macros/src/lib.rs +++ b/rusqlite-macros/src/lib.rs @@ -48,7 +48,7 @@ fn try_bind(input: TokenStream) -> Result { return Err(err.to_string()); } if info.count == 0 { - return Ok(input); + return Ok(TokenStream::new()); } if info.count as usize != info.names.len() { return Err("Mixing named and numbered parameters is not supported.".to_string()); diff --git a/rusqlite-macros/tests/test.rs b/rusqlite-macros/tests/test.rs index 785ca9b..f9e9782 100644 --- a/rusqlite-macros/tests/test.rs +++ b/rusqlite-macros/tests/test.rs @@ -20,6 +20,13 @@ fn test_literal() -> Result { Ok(()) } +#[test] +fn test_no_placeholder() -> Result { + let _stmt = Stmt; + __bind!(_stmt "SELECT 1"); + Ok(()) +} + /* FIXME #[test] fn test_raw_string() { From 33b5ea3c4398e6c87725cbdadeb3786b1261f83f Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 23 Dec 2023 12:10:36 +0100 Subject: [PATCH 52/63] Handle raw string literal --- rusqlite-macros/Cargo.toml | 1 + rusqlite-macros/src/lib.rs | 38 +++++++---------------------------- rusqlite-macros/tests/test.rs | 16 +++++++-------- 3 files changed, 16 insertions(+), 39 deletions(-) diff --git a/rusqlite-macros/Cargo.toml b/rusqlite-macros/Cargo.toml index ab3ea51..67f2d20 100644 --- a/rusqlite-macros/Cargo.toml +++ b/rusqlite-macros/Cargo.toml @@ -14,3 +14,4 @@ proc-macro = true [dependencies] sqlite3-parser = { version = "0.12", default-features = false, features = ["YYNOERRORRECOVERY"] } fallible-iterator = "0.3" +litrs = { version = "0.4", default-features = false } diff --git a/rusqlite-macros/src/lib.rs b/rusqlite-macros/src/lib.rs index 308d5fd..15a7681 100644 --- a/rusqlite-macros/src/lib.rs +++ b/rusqlite-macros/src/lib.rs @@ -1,6 +1,7 @@ //! Private implementation details of `rusqlite`. -use proc_macro::{Delimiter, Group, Literal, Span, TokenStream, TokenTree}; +use litrs::StringLit; +use proc_macro::{Group, Span, TokenStream, TokenTree}; use fallible_iterator::FallibleIterator; use sqlite3_parser::ast::{ParameterInfo, ToTokens}; @@ -25,15 +26,12 @@ fn try_bind(input: TokenStream) -> Result { (stmt, literal) }; - let literal = match into_literal(&literal) { - Some(it) => it, - None => return Err("expected a plain string literal".to_string()), + let call_site = literal.span(); + let string_lit = match StringLit::try_from(literal) { + Ok(string_lit) => string_lit, + Err(e) => return Ok(e.to_compile_error()), }; - let sql = literal.to_string(); - if !sql.starts_with('"') { - return Err("expected a plain string literal".to_string()); - } - let sql = strip_matches(&sql, "\""); + let sql = string_lit.value(); let mut parser = Parser::new(sql.as_bytes()); let ast = match parser.next() { @@ -54,7 +52,6 @@ fn try_bind(input: TokenStream) -> Result { return Err("Mixing named and numbered parameters is not supported.".to_string()); } - let call_site = literal.span(); let mut res = TokenStream::new(); for (i, name) in info.names.iter().enumerate() { res.extend(Some(stmt.clone())); @@ -71,27 +68,6 @@ fn try_bind(input: TokenStream) -> Result { Ok(res) } -fn into_literal(ts: &TokenTree) -> Option { - match ts { - TokenTree::Literal(l) => Some(l.clone()), - TokenTree::Group(g) => match g.delimiter() { - Delimiter::None => match g.stream().into_iter().collect::>().as_slice() { - [TokenTree::Literal(l)] => Some(l.clone()), - _ => None, - }, - Delimiter::Parenthesis | Delimiter::Brace | Delimiter::Bracket => None, - }, - _ => None, - } -} - -fn strip_matches<'a>(s: &'a str, pattern: &str) -> &'a str { - s.strip_prefix(pattern) - .unwrap_or(s) - .strip_suffix(pattern) - .unwrap_or(s) -} - fn respan(ts: TokenStream, span: Span) -> TokenStream { let mut res = TokenStream::new(); for tt in ts { diff --git a/rusqlite-macros/tests/test.rs b/rusqlite-macros/tests/test.rs index f9e9782..3a47718 100644 --- a/rusqlite-macros/tests/test.rs +++ b/rusqlite-macros/tests/test.rs @@ -21,19 +21,19 @@ fn test_literal() -> Result { } #[test] -fn test_no_placeholder() -> Result { +fn test_no_placeholder() { let _stmt = Stmt; __bind!(_stmt "SELECT 1"); - Ok(()) +} + +#[test] +fn test_raw_string() { + let _stmt = Stmt; + __bind!(_stmt r"SELECT 1"); + __bind!(_stmt r#"SELECT 1"#); } /* FIXME -#[test] -fn test_raw_string() { - let stmt = (); - __bind!(stmt r#"SELECT 1"#); -} - #[test] fn test_const() { const SQL: &str = "SELECT 1"; From 3c3d7daeb445ba382d35d83e71a00fed4712ec5e Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 23 Dec 2023 14:21:23 +0100 Subject: [PATCH 53/63] Fix uninlined_format_args cargo clippy --all --all-targets --fix -- -Wclippy::uninlined_format_args --- examples/persons/main.rs | 2 +- libsqlite3-sys/build.rs | 5 +---- rusqlite-macros/src/lib.rs | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/examples/persons/main.rs b/examples/persons/main.rs index a1a94ae..a4c5a7c 100644 --- a/examples/persons/main.rs +++ b/examples/persons/main.rs @@ -34,7 +34,7 @@ fn main() -> Result<()> { for person in rows { match person { Ok(p) => println!("ID: {}, Name: {}", p.id, p.name), - Err(e) => eprintln!("Error: {:?}", e), + Err(e) => eprintln!("Error: {e:?}"), } } diff --git a/libsqlite3-sys/build.rs b/libsqlite3-sys/build.rs index e6099fc..79721e6 100644 --- a/libsqlite3-sys/build.rs +++ b/libsqlite3-sys/build.rs @@ -350,10 +350,7 @@ impl From for String { HeaderLocation::FromEnvironment => { let prefix = env_prefix(); let mut header = env::var(format!("{prefix}_INCLUDE_DIR")).unwrap_or_else(|_| { - panic!( - "{}_INCLUDE_DIR must be set if {}_LIB_DIR is set", - prefix, prefix - ) + panic!("{prefix}_INCLUDE_DIR must be set if {prefix}_LIB_DIR is set") }); header.push_str(if cfg!(feature = "loadable_extension") { "/sqlite3ext.h" diff --git a/rusqlite-macros/src/lib.rs b/rusqlite-macros/src/lib.rs index 15a7681..d98dee1 100644 --- a/rusqlite-macros/src/lib.rs +++ b/rusqlite-macros/src/lib.rs @@ -12,7 +12,7 @@ use sqlite3_parser::lexer::sql::Parser; #[doc(hidden)] #[proc_macro] pub fn __bind(input: TokenStream) -> TokenStream { - try_bind(input).unwrap_or_else(|msg| parse_ts(&format!("compile_error!({:?})", msg))) + try_bind(input).unwrap_or_else(|msg| parse_ts(&format!("compile_error!({msg:?})"))) } type Result = std::result::Result; From 6332de5302119eefb9cd3efecf97d880c655cf28 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Sat, 23 Dec 2023 23:22:32 -0500 Subject: [PATCH 54/63] Remove modern_sqlite and vtab from CI in loadable ext This matches the recent changes in the example docs --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3895470..1948f88 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -67,8 +67,8 @@ jobs: - name: loadable extension run: | - cargo build --example loadable_extension --features "loadable_extension modern_sqlite functions vtab trace" - cargo run --example load_extension --features "load_extension bundled functions vtab trace" + cargo build --example loadable_extension --features "loadable_extension functions trace" + cargo run --example load_extension --features "load_extension bundled functions trace" # TODO: move into own action for better caching - name: Static build From 68c3083e34ef848b6d59166b3079ee5c6497175c Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Sun, 24 Dec 2023 02:54:48 -0500 Subject: [PATCH 55/63] Add `#[derive(Clone, Copy...` on some bitflags / enum (#1396) This will make it easier to use them, e.g. I won't need to re-create `FunctionFlags` for registering multiple similar functions. --- src/config.rs | 1 + src/functions.rs | 1 + src/limits.rs | 1 + src/types/mod.rs | 2 +- src/vtab/mod.rs | 1 + 5 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index 194ee59..1c2220c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -9,6 +9,7 @@ use crate::{Connection, Result}; /// Database Connection Configuration Options /// See [Database Connection Configuration Options](https://sqlite.org/c3ref/c_dbconfig_enable_fkey.html) for details. #[repr(i32)] +#[derive(Copy, Clone, Debug)] #[allow(non_snake_case, non_camel_case_types)] #[non_exhaustive] #[allow(clippy::upper_case_acronyms)] diff --git a/src/functions.rs b/src/functions.rs index 522f116..576d1b0 100644 --- a/src/functions.rs +++ b/src/functions.rs @@ -311,6 +311,7 @@ bitflags::bitflags! { /// Function Flags. /// See [sqlite3_create_function](https://sqlite.org/c3ref/create_function.html) /// and [Function Flags](https://sqlite.org/c3ref/c_deterministic.html) for details. + #[derive(Clone, Copy, Debug)] #[repr(C)] pub struct FunctionFlags: ::std::os::raw::c_int { /// Specifies UTF-8 as the text encoding this SQL function prefers for its parameters. diff --git a/src/limits.rs b/src/limits.rs index d0694e3..f61b2b8 100644 --- a/src/limits.rs +++ b/src/limits.rs @@ -9,6 +9,7 @@ use std::os::raw::c_int; /// See the official documentation for more information: /// - /// - +#[derive(Copy, Clone, Debug)] #[repr(i32)] #[non_exhaustive] #[allow(clippy::upper_case_acronyms, non_camel_case_types)] diff --git a/src/types/mod.rs b/src/types/mod.rs index 4dbc19d..97059a3 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -111,7 +111,7 @@ pub struct Null; /// SQLite data types. /// See [Fundamental Datatypes](https://sqlite.org/c3ref/c_blob.html). -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum Type { /// NULL Null, diff --git a/src/vtab/mod.rs b/src/vtab/mod.rs index 7e2f5f5..4ee1693 100644 --- a/src/vtab/mod.rs +++ b/src/vtab/mod.rs @@ -373,6 +373,7 @@ bitflags::bitflags! { /// Virtual table scan flags /// See [Function Flags](https://sqlite.org/c3ref/c_index_scan_unique.html) for details. #[repr(C)] + #[derive(Copy, Clone, Debug)] pub struct IndexFlags: ::std::os::raw::c_int { /// Default const NONE = 0; From 05991e67557f2fed4f16da94c0de858c0e41f9c8 Mon Sep 17 00:00:00 2001 From: gwenn Date: Mon, 1 Jan 2024 13:12:33 +0100 Subject: [PATCH 56/63] Use DLL_PREFIX / DLL_SUFFIX --- examples/load_extension.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/examples/load_extension.rs b/examples/load_extension.rs index 9e52bb2..01e7727 100644 --- a/examples/load_extension.rs +++ b/examples/load_extension.rs @@ -1,16 +1,20 @@ //! Ensure loadable_extension.rs works. use rusqlite::{Connection, Result}; +use std::env::consts::{DLL_PREFIX, DLL_SUFFIX}; fn main() -> Result<()> { let db = Connection::open_in_memory()?; unsafe { db.load_extension_enable()?; - #[cfg(not(windows))] - db.load_extension("target/debug/examples/libloadable_extension", None)?; - #[cfg(windows)] - db.load_extension("target/debug/examples/loadable_extension", None)?; + db.load_extension( + format!( + "target/debug/examples/{}loadable_extension{}", + DLL_PREFIX, DLL_SUFFIX + ), + None, + )?; db.load_extension_disable()?; } From 7f56e9d877499ce0be0d2eca23d7f2c33679bc25 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 6 Jan 2024 14:05:07 +0100 Subject: [PATCH 57/63] Partial revert 33b5ea3c4398e6c87725cbdadeb3786b1261f83f --- .github/workflows/main.yml | 5 +++++ rusqlite-macros/src/lib.rs | 20 +++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1948f88..f74fd55 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -70,6 +70,11 @@ jobs: cargo build --example loadable_extension --features "loadable_extension functions trace" cargo run --example load_extension --features "load_extension bundled functions trace" + - name: macros + run: | + cargo test --package rusqlite-macros + cargo test --features 'bundled rusqlite-macros' + # TODO: move into own action for better caching - name: Static build # Do we expect this to work / should we test with gnu toolchain? diff --git a/rusqlite-macros/src/lib.rs b/rusqlite-macros/src/lib.rs index d98dee1..211af9d 100644 --- a/rusqlite-macros/src/lib.rs +++ b/rusqlite-macros/src/lib.rs @@ -1,7 +1,7 @@ //! Private implementation details of `rusqlite`. use litrs::StringLit; -use proc_macro::{Group, Span, TokenStream, TokenTree}; +use proc_macro::{Delimiter, Group, Literal, Span, TokenStream, TokenTree}; use fallible_iterator::FallibleIterator; use sqlite3_parser::ast::{ParameterInfo, ToTokens}; @@ -26,6 +26,10 @@ fn try_bind(input: TokenStream) -> Result { (stmt, literal) }; + let literal = match into_literal(&literal) { + Some(it) => it, + None => return Err("expected a plain string literal".to_string()), + }; let call_site = literal.span(); let string_lit = match StringLit::try_from(literal) { Ok(string_lit) => string_lit, @@ -68,6 +72,20 @@ fn try_bind(input: TokenStream) -> Result { Ok(res) } +fn into_literal(ts: &TokenTree) -> Option { + match ts { + TokenTree::Literal(l) => Some(l.clone()), + TokenTree::Group(g) => match g.delimiter() { + Delimiter::None => match g.stream().into_iter().collect::>().as_slice() { + [TokenTree::Literal(l)] => Some(l.clone()), + _ => None, + }, + Delimiter::Parenthesis | Delimiter::Brace | Delimiter::Bracket => None, + }, + _ => None, + } +} + fn respan(ts: TokenStream, span: Span) -> TokenStream { let mut res = TokenStream::new(); for tt in ts { From 01a2cc51a50920e8ca1ce1632ead0c18082248df Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 6 Jan 2024 16:35:18 +0100 Subject: [PATCH 58/63] Drop winsqlite3 feature --- .github/workflows/main.yml | 12 ------------ Cargo.toml | 2 -- README.md | 1 - libsqlite3-sys/Cargo.toml | 7 ------- libsqlite3-sys/build.rs | 38 -------------------------------------- libsqlite3-sys/src/lib.rs | 3 --- libsqlite3-sys/wrapper.h | 4 ---- 7 files changed, 67 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f74fd55..b251ebf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -122,18 +122,6 @@ jobs: - run: cargo test --features 'bundled-full session buildtime_bindgen' --all-targets --workspace --verbose - run: cargo test --features 'bundled-full session buildtime_bindgen' --doc --workspace --verbose - winsqlite3: - name: Test with winsqlite3 - runs-on: windows-latest - steps: - - uses: actions/checkout@v3 - - uses: hecrj/setup-rust-action@v1 - - uses: Swatinem/rust-cache@v2 - # TODO: Should this test GNU toolchain? What about +crt-static? - # TODO: Is it worth testing other features? - - run: cargo build --features winsqlite3 --workspace --all-targets --verbose - - run: cargo test --features winsqlite3 --workspace --all-targets --verbose - sqlcipher: name: Test with sqlcipher runs-on: ubuntu-latest diff --git a/Cargo.toml b/Cargo.toml index 94cc830..6cf3e02 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -76,8 +76,6 @@ bundled-windows = ["libsqlite3-sys/bundled-windows"] with-asan = ["libsqlite3-sys/with-asan"] column_decltype = [] wasm32-wasi-vfs = ["libsqlite3-sys/wasm32-wasi-vfs"] -# Note: doesn't support 32-bit. -winsqlite3 = ["libsqlite3-sys/winsqlite3"] # 3.23.0 serialize = ["modern_sqlite"] diff --git a/README.md b/README.md index 13db5ff..3e2bcc4 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,6 @@ features](https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-s * `extra_check` fail when a query passed to execute is readonly or has a column count > 0. * `column_decltype` provides `columns()` method for Statements and Rows; omit if linking to a version of SQLite/SQLCipher compiled with `-DSQLITE_OMIT_DECLTYPE`. * `collation` exposes [`sqlite3_create_collation_v2`](https://sqlite.org/c3ref/create_collation.html). -* `winsqlite3` allows linking against the SQLite present in newer versions of Windows ## Notes on building rusqlite and libsqlite3-sys diff --git a/libsqlite3-sys/Cargo.toml b/libsqlite3-sys/Cargo.toml index 248c69c..d16a050 100644 --- a/libsqlite3-sys/Cargo.toml +++ b/libsqlite3-sys/Cargo.toml @@ -34,13 +34,6 @@ in_gecko = [] with-asan = [] wasm32-wasi-vfs = [] -# lowest version shipped with Windows 10.0.10586 was 3.8.8.3 -# -# Note that because `winsqlite3.dll` exports SQLite functions using a atypical -# ABI on 32-bit systems, this is currently unsupported on these. This may change -# in the future. -winsqlite3 = [] - [dependencies] openssl-sys = { version = "0.9", optional = true } diff --git a/libsqlite3-sys/build.rs b/libsqlite3-sys/build.rs index 79721e6..ca5a21c 100644 --- a/libsqlite3-sys/build.rs +++ b/libsqlite3-sys/build.rs @@ -331,8 +331,6 @@ fn env_prefix() -> &'static str { fn lib_name() -> &'static str { if cfg!(any(feature = "sqlcipher", feature = "bundled-sqlcipher")) { "sqlcipher" - } else if cfg!(all(windows, feature = "winsqlite3")) { - "winsqlite3" } else { "sqlite3" } @@ -433,12 +431,6 @@ mod build_linked { #[cfg(not(feature = "loadable_extension"))] println!("cargo:link-target={link_lib}"); - if win_target() && cfg!(feature = "winsqlite3") { - #[cfg(not(feature = "loadable_extension"))] - println!("cargo:rustc-link-lib=dylib={link_lib}"); - return HeaderLocation::Wrapper; - } - // Allow users to specify where to find SQLite. if let Ok(dir) = env::var(format!("{}_LIB_DIR", env_prefix())) { // Try to use pkg-config to determine link commands @@ -599,36 +591,6 @@ mod bindings { if cfg!(feature = "session") { bindings = bindings.clang_arg("-DSQLITE_ENABLE_SESSION"); } - if win_target() && cfg!(feature = "winsqlite3") { - bindings = bindings - .clang_arg("-DBINDGEN_USE_WINSQLITE3") - .blocklist_item("NTDDI_.+") - .blocklist_item("WINAPI_FAMILY.*") - .blocklist_item("_WIN32_.+") - .blocklist_item("_VCRT_COMPILER_PREPROCESSOR") - .blocklist_item("_SAL_VERSION") - .blocklist_item("__SAL_H_VERSION") - .blocklist_item("_USE_DECLSPECS_FOR_SAL") - .blocklist_item("_USE_ATTRIBUTES_FOR_SAL") - .blocklist_item("_CRT_PACKING") - .blocklist_item("_HAS_EXCEPTIONS") - .blocklist_item("_STL_LANG") - .blocklist_item("_HAS_CXX17") - .blocklist_item("_HAS_CXX20") - .blocklist_item("_HAS_NODISCARD") - .blocklist_item("WDK_NTDDI_VERSION") - .blocklist_item("OSVERSION_MASK") - .blocklist_item("SPVERSION_MASK") - .blocklist_item("SUBVERSION_MASK") - .blocklist_item("WINVER") - .blocklist_item("__security_cookie") - .blocklist_type("size_t") - .blocklist_type("__vcrt_bool") - .blocklist_type("wchar_t") - .blocklist_function("__security_init_cookie") - .blocklist_function("__report_gsfailure") - .blocklist_function("__va_start"); - } // When cross compiling unless effort is taken to fix the issue, bindgen // will find the wrong headers. There's only one header included by the diff --git a/libsqlite3-sys/src/lib.rs b/libsqlite3-sys/src/lib.rs index 49ec1d5..4e5e948 100644 --- a/libsqlite3-sys/src/lib.rs +++ b/libsqlite3-sys/src/lib.rs @@ -5,9 +5,6 @@ #[cfg(feature = "bundled-sqlcipher-vendored-openssl")] extern crate openssl_sys; -#[cfg(all(windows, feature = "winsqlite3", target_pointer_width = "32"))] -compile_error!("The `libsqlite3-sys/winsqlite3` feature is not supported on 32 bit targets."); - pub use self::error::*; use std::default::Default; diff --git a/libsqlite3-sys/wrapper.h b/libsqlite3-sys/wrapper.h index ecbcc44..b5e2c60 100644 --- a/libsqlite3-sys/wrapper.h +++ b/libsqlite3-sys/wrapper.h @@ -1,5 +1 @@ -#ifdef BINDGEN_USE_WINSQLITE3 -#include -#else #include "sqlite3.h" -#endif From 8a5e2e6f630f22b8e308c54274c08ec887ece702 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 6 Jan 2024 16:46:29 +0100 Subject: [PATCH 59/63] Fix clippy warning --- libsqlite3-sys/build.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/libsqlite3-sys/build.rs b/libsqlite3-sys/build.rs index ca5a21c..d6da79b 100644 --- a/libsqlite3-sys/build.rs +++ b/libsqlite3-sys/build.rs @@ -506,9 +506,6 @@ mod bindings { use bindgen::callbacks::{IntKind, ParseCallbacks}; use std::path::Path; - - use super::win_target; - #[derive(Debug)] struct SqliteTypeChooser; From 1db556eb2d0bb882e0d26d26472bd70914d984b5 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 6 Jan 2024 19:04:31 +0100 Subject: [PATCH 60/63] Add missing doc for new features --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 13db5ff..a505056 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,7 @@ features](https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-s * [`load_extension`](https://docs.rs/rusqlite/~0/rusqlite/struct.LoadExtensionGuard.html) allows loading dynamic library-based SQLite extensions. +* `loadable_extension` to program [loadable extension](https://sqlite.org/loadext.html) in Rust. * [`backup`](https://docs.rs/rusqlite/~0/rusqlite/backup/index.html) allows use of SQLite's online backup API. Note: This feature requires SQLite 3.6.11 or later. * [`functions`](https://docs.rs/rusqlite/~0/rusqlite/functions/index.html) @@ -137,6 +138,7 @@ features](https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-s * `column_decltype` provides `columns()` method for Statements and Rows; omit if linking to a version of SQLite/SQLCipher compiled with `-DSQLITE_OMIT_DECLTYPE`. * `collation` exposes [`sqlite3_create_collation_v2`](https://sqlite.org/c3ref/create_collation.html). * `winsqlite3` allows linking against the SQLite present in newer versions of Windows +* `serialize` exposes [`sqlite3_serialize`](http://sqlite.org/c3ref/serialize.html) (3.23.0). ## Notes on building rusqlite and libsqlite3-sys From 950b88d69d49f64e18cde5641bca67dd36c0ec0a Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 9 Jan 2024 15:56:55 -0800 Subject: [PATCH 61/63] Upgrade to hashlink 0.9 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 94cc830..b0e104d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -116,7 +116,7 @@ bundled-full = ["modern-full", "bundled"] [dependencies] time = { version = "0.3.0", features = ["formatting", "macros", "parsing"], optional = true } bitflags = "2.0" -hashlink = "0.8" +hashlink = "0.9" chrono = { version = "0.4", optional = true, default-features = false, features = ["clock"] } serde_json = { version = "1.0", optional = true } csv = { version = "1.1", optional = true } From ef067b5eff16605312f05587e1e8d5812998ec93 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 9 Jan 2024 15:57:41 -0800 Subject: [PATCH 62/63] Resolve FIXME to derive Debug for StatementCache --- src/cache.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cache.rs b/src/cache.rs index 05ddb87..4e6b945 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -57,7 +57,7 @@ impl Connection { } /// Prepared statements LRU cache. -// #[derive(Debug)] // FIXME: https://github.com/kyren/hashlink/pull/4 +#[derive(Debug)] pub struct StatementCache(RefCell, RawStatement>>); #[allow(clippy::non_send_fields_in_send_ty)] From 2db482f22403d5d6bfbcb4af2b799e89f0439466 Mon Sep 17 00:00:00 2001 From: gwenn Date: Tue, 16 Jan 2024 19:55:26 +0000 Subject: [PATCH 63/63] Bump bundled SQLite version to 3.45.0 --- .../sqlite3/bindgen_bundled_version.rs | 28 +- .../sqlite3/bindgen_bundled_version_ext.rs | 28 +- libsqlite3-sys/sqlite3/sqlite3.c | 8191 +++++++++++------ libsqlite3-sys/sqlite3/sqlite3.h | 152 +- libsqlite3-sys/upgrade.sh | 4 +- 5 files changed, 5783 insertions(+), 2620 deletions(-) diff --git a/libsqlite3-sys/sqlite3/bindgen_bundled_version.rs b/libsqlite3-sys/sqlite3/bindgen_bundled_version.rs index ef59419..3edb6f9 100644 --- a/libsqlite3-sys/sqlite3/bindgen_bundled_version.rs +++ b/libsqlite3-sys/sqlite3/bindgen_bundled_version.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.69.1 */ +/* automatically generated by rust-bindgen 0.69.2 */ extern "C" { pub fn sqlite3_auto_extension( @@ -23,10 +23,10 @@ extern "C" { ) -> ::std::os::raw::c_int; } -pub const SQLITE_VERSION: &[u8; 7] = b"3.44.0\0"; -pub const SQLITE_VERSION_NUMBER: i32 = 3044000; +pub const SQLITE_VERSION: &[u8; 7] = b"3.45.0\0"; +pub const SQLITE_VERSION_NUMBER: i32 = 3045000; pub const SQLITE_SOURCE_ID: &[u8; 85] = - b"2023-11-01 11:23:50 17129ba1ff7f0daf37100ee82d507aef7827cf38de1866e2633096ae6ad81301\0"; + b"2024-01-15 17:01:13 1066602b2b1976fe58b5150777cced894af17c803e068f5918390d6915b46e1d\0"; pub const SQLITE_OK: i32 = 0; pub const SQLITE_ERROR: i32 = 1; pub const SQLITE_INTERNAL: i32 = 2; @@ -353,6 +353,7 @@ pub const SQLITE_DETERMINISTIC: i32 = 2048; pub const SQLITE_DIRECTONLY: i32 = 524288; pub const SQLITE_SUBTYPE: i32 = 1048576; pub const SQLITE_INNOCUOUS: i32 = 2097152; +pub const SQLITE_RESULT_SUBTYPE: i32 = 16777216; pub const SQLITE_WIN32_DATA_DIRECTORY_TYPE: i32 = 1; pub const SQLITE_WIN32_TEMP_DIRECTORY_TYPE: i32 = 2; pub const SQLITE_TXN_NONE: i32 = 0; @@ -405,6 +406,7 @@ pub const SQLITE_TESTCTRL_PENDING_BYTE: i32 = 11; pub const SQLITE_TESTCTRL_ASSERT: i32 = 12; pub const SQLITE_TESTCTRL_ALWAYS: i32 = 13; pub const SQLITE_TESTCTRL_RESERVE: i32 = 14; +pub const SQLITE_TESTCTRL_JSON_SELFCHECK: i32 = 14; pub const SQLITE_TESTCTRL_OPTIMIZATIONS: i32 = 15; pub const SQLITE_TESTCTRL_ISKEYWORD: i32 = 16; pub const SQLITE_TESTCTRL_SCRATCHMALLOC: i32 = 17; @@ -3590,6 +3592,24 @@ pub struct Fts5ExtensionApi { piCol: *mut ::std::os::raw::c_int, ), >, + pub xQueryToken: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + iPhrase: ::std::os::raw::c_int, + iToken: ::std::os::raw::c_int, + ppToken: *mut *const ::std::os::raw::c_char, + pnToken: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xInstToken: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + iIdx: ::std::os::raw::c_int, + iToken: ::std::os::raw::c_int, + arg2: *mut *const ::std::os::raw::c_char, + arg3: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, } #[repr(C)] #[derive(Debug, Copy, Clone)] diff --git a/libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs b/libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs index fdd6d5e..fd078cd 100644 --- a/libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs +++ b/libsqlite3-sys/sqlite3/bindgen_bundled_version_ext.rs @@ -1,9 +1,9 @@ -/* automatically generated by rust-bindgen 0.69.1 */ +/* automatically generated by rust-bindgen 0.69.2 */ -pub const SQLITE_VERSION: &[u8; 7] = b"3.44.0\0"; -pub const SQLITE_VERSION_NUMBER: i32 = 3044000; +pub const SQLITE_VERSION: &[u8; 7] = b"3.45.0\0"; +pub const SQLITE_VERSION_NUMBER: i32 = 3045000; pub const SQLITE_SOURCE_ID: &[u8; 85] = - b"2023-11-01 11:23:50 17129ba1ff7f0daf37100ee82d507aef7827cf38de1866e2633096ae6ad81301\0"; + b"2024-01-15 17:01:13 1066602b2b1976fe58b5150777cced894af17c803e068f5918390d6915b46e1d\0"; pub const SQLITE_OK: i32 = 0; pub const SQLITE_ERROR: i32 = 1; pub const SQLITE_INTERNAL: i32 = 2; @@ -330,6 +330,7 @@ pub const SQLITE_DETERMINISTIC: i32 = 2048; pub const SQLITE_DIRECTONLY: i32 = 524288; pub const SQLITE_SUBTYPE: i32 = 1048576; pub const SQLITE_INNOCUOUS: i32 = 2097152; +pub const SQLITE_RESULT_SUBTYPE: i32 = 16777216; pub const SQLITE_WIN32_DATA_DIRECTORY_TYPE: i32 = 1; pub const SQLITE_WIN32_TEMP_DIRECTORY_TYPE: i32 = 2; pub const SQLITE_TXN_NONE: i32 = 0; @@ -382,6 +383,7 @@ pub const SQLITE_TESTCTRL_PENDING_BYTE: i32 = 11; pub const SQLITE_TESTCTRL_ASSERT: i32 = 12; pub const SQLITE_TESTCTRL_ALWAYS: i32 = 13; pub const SQLITE_TESTCTRL_RESERVE: i32 = 14; +pub const SQLITE_TESTCTRL_JSON_SELFCHECK: i32 = 14; pub const SQLITE_TESTCTRL_OPTIMIZATIONS: i32 = 15; pub const SQLITE_TESTCTRL_ISKEYWORD: i32 = 16; pub const SQLITE_TESTCTRL_SCRATCHMALLOC: i32 = 17; @@ -1312,6 +1314,24 @@ pub struct Fts5ExtensionApi { piCol: *mut ::std::os::raw::c_int, ), >, + pub xQueryToken: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + iPhrase: ::std::os::raw::c_int, + iToken: ::std::os::raw::c_int, + ppToken: *mut *const ::std::os::raw::c_char, + pnToken: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, + pub xInstToken: ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut Fts5Context, + iIdx: ::std::os::raw::c_int, + iToken: ::std::os::raw::c_int, + arg2: *mut *const ::std::os::raw::c_char, + arg3: *mut ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int, + >, } #[repr(C)] #[derive(Debug, Copy, Clone)] diff --git a/libsqlite3-sys/sqlite3/sqlite3.c b/libsqlite3-sys/sqlite3/sqlite3.c index 8f9309a..6e6dc8a 100644 --- a/libsqlite3-sys/sqlite3/sqlite3.c +++ b/libsqlite3-sys/sqlite3/sqlite3.c @@ -1,6 +1,6 @@ /****************************************************************************** ** This file is an amalgamation of many separate C source files from SQLite -** version 3.44.0. By combining all the individual C code files into this +** version 3.45.0. By combining all the individual C code files into this ** single large file, the entire code can be compiled as a single translation ** unit. This allows many compilers to do optimizations that would not be ** possible if the files were compiled separately. Performance improvements @@ -18,7 +18,7 @@ ** separate file. This file contains only code for the core SQLite library. ** ** The content in this amalgamation comes from Fossil check-in -** 17129ba1ff7f0daf37100ee82d507aef7827. +** 1066602b2b1976fe58b5150777cced894af1. */ #define SQLITE_CORE 1 #define SQLITE_AMALGAMATION 1 @@ -459,9 +459,9 @@ extern "C" { ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ -#define SQLITE_VERSION "3.44.0" -#define SQLITE_VERSION_NUMBER 3044000 -#define SQLITE_SOURCE_ID "2023-11-01 11:23:50 17129ba1ff7f0daf37100ee82d507aef7827cf38de1866e2633096ae6ad81301" +#define SQLITE_VERSION "3.45.0" +#define SQLITE_VERSION_NUMBER 3045000 +#define SQLITE_SOURCE_ID "2024-01-15 17:01:13 1066602b2b1976fe58b5150777cced894af17c803e068f5918390d6915b46e1d" /* ** CAPI3REF: Run-Time Library Version Numbers @@ -4267,15 +4267,17 @@ SQLITE_API void sqlite3_free_filename(sqlite3_filename); **
        ** ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language -** text that describes the error, as either UTF-8 or UTF-16 respectively. +** text that describes the error, as either UTF-8 or UTF-16 respectively, +** or NULL if no error message is available. ** (See how SQLite handles [invalid UTF] for exceptions to this rule.) ** ^(Memory to hold the error message string is managed internally. ** The application does not need to worry about freeing the result. ** However, the error string might be overwritten or deallocated by ** subsequent calls to other SQLite interface functions.)^ ** -** ^The sqlite3_errstr() interface returns the English-language text -** that describes the [result code], as UTF-8. +** ^The sqlite3_errstr(E) interface returns the English-language text +** that describes the [result code] E, as UTF-8, or NULL if E is not an +** result code for which a text error message is available. ** ^(Memory to hold the error message string is managed internally ** and must not be freed by the application)^. ** @@ -5886,13 +5888,27 @@ SQLITE_API int sqlite3_create_window_function( **
        ** ** [[SQLITE_SUBTYPE]]
        SQLITE_SUBTYPE
        -** The SQLITE_SUBTYPE flag indicates to SQLite that a function may call +** The SQLITE_SUBTYPE flag indicates to SQLite that a function might call ** [sqlite3_value_subtype()] to inspect the sub-types of its arguments. -** Specifying this flag makes no difference for scalar or aggregate user -** functions. However, if it is not specified for a user-defined window -** function, then any sub-types belonging to arguments passed to the window -** function may be discarded before the window function is called (i.e. -** sqlite3_value_subtype() will always return 0). +** This flag instructs SQLite to omit some corner-case optimizations that +** might disrupt the operation of the [sqlite3_value_subtype()] function, +** causing it to return zero rather than the correct subtype(). +** SQL functions that invokes [sqlite3_value_subtype()] should have this +** property. If the SQLITE_SUBTYPE property is omitted, then the return +** value from [sqlite3_value_subtype()] might sometimes be zero even though +** a non-zero subtype was specified by the function argument expression. +** +** [[SQLITE_RESULT_SUBTYPE]]
        SQLITE_RESULT_SUBTYPE
        +** The SQLITE_RESULT_SUBTYPE flag indicates to SQLite that a function might call +** [sqlite3_result_subtype()] to cause a sub-type to be associated with its +** result. +** Every function that invokes [sqlite3_result_subtype()] should have this +** property. If it does not, then the call to [sqlite3_result_subtype()] +** might become a no-op if the function is used as term in an +** [expression index]. On the other hand, SQL functions that never invoke +** [sqlite3_result_subtype()] should avoid setting this property, as the +** purpose of this property is to disable certain optimizations that are +** incompatible with subtypes. **
        ** */ @@ -5900,6 +5916,7 @@ SQLITE_API int sqlite3_create_window_function( #define SQLITE_DIRECTONLY 0x000080000 #define SQLITE_SUBTYPE 0x000100000 #define SQLITE_INNOCUOUS 0x000200000 +#define SQLITE_RESULT_SUBTYPE 0x001000000 /* ** CAPI3REF: Deprecated Functions @@ -6096,6 +6113,12 @@ SQLITE_API int sqlite3_value_encoding(sqlite3_value*); ** information can be used to pass a limited amount of context from ** one SQL function to another. Use the [sqlite3_result_subtype()] ** routine to set the subtype for the return value of an SQL function. +** +** Every [application-defined SQL function] that invoke this interface +** should include the [SQLITE_SUBTYPE] property in the text +** encoding argument when the function is [sqlite3_create_function|registered]. +** If the [SQLITE_SUBTYPE] property is omitted, then sqlite3_value_subtype() +** might return zero instead of the upstream subtype in some corner cases. */ SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value*); @@ -6226,14 +6249,22 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*); **
      • ^(when sqlite3_set_auxdata() is invoked again on the same ** parameter)^, or **
      • ^(during the original sqlite3_set_auxdata() call when a memory -** allocation error occurs.)^
      +** allocation error occurs.)^ +**
    6. ^(during the original sqlite3_set_auxdata() call if the function +** is evaluated during query planning instead of during query execution, +** as sometimes happens with [SQLITE_ENABLE_STAT4].)^ ** -** Note the last bullet in particular. The destructor X in +** Note the last two bullets in particular. The destructor X in ** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the ** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata() ** should be called near the end of the function implementation and the ** function implementation should not make any use of P after -** sqlite3_set_auxdata() has been called. +** sqlite3_set_auxdata() has been called. Furthermore, a call to +** sqlite3_get_auxdata() that occurs immediately after a corresponding call +** to sqlite3_set_auxdata() might still return NULL if an out-of-memory +** condition occurred during the sqlite3_set_auxdata() call or if the +** function is being evaluated during query planning rather than during +** query execution. ** ** ^(In practice, auxiliary data is preserved between function calls for ** function parameters that are compile-time constants, including literal @@ -6507,6 +6538,20 @@ SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n); ** higher order bits are discarded. ** The number of subtype bytes preserved by SQLite might increase ** in future releases of SQLite. +** +** Every [application-defined SQL function] that invokes this interface +** should include the [SQLITE_RESULT_SUBTYPE] property in its +** text encoding argument when the SQL function is +** [sqlite3_create_function|registered]. If the [SQLITE_RESULT_SUBTYPE] +** property is omitted from the function that invokes sqlite3_result_subtype(), +** then in some cases the sqlite3_result_subtype() might fail to set +** the result subtype. +** +** If SQLite is compiled with -DSQLITE_STRICT_SUBTYPE=1, then any +** SQL function that invokes the sqlite3_result_subtype() interface +** and that does not have the SQLITE_RESULT_SUBTYPE property will raise +** an error. Future versions of SQLite might enable -DSQLITE_STRICT_SUBTYPE=1 +** by default. */ SQLITE_API void sqlite3_result_subtype(sqlite3_context*,unsigned int); @@ -8307,9 +8352,11 @@ SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*); ** ** ^(Some systems (for example, Windows 95) do not support the operation ** implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try() -** will always return SQLITE_BUSY. The SQLite core only ever uses -** sqlite3_mutex_try() as an optimization so this is acceptable -** behavior.)^ +** will always return SQLITE_BUSY. In most cases the SQLite core only uses +** sqlite3_mutex_try() as an optimization, so this is acceptable +** behavior. The exceptions are unix builds that set the +** SQLITE_ENABLE_SETLK_TIMEOUT build option. In that case a working +** sqlite3_mutex_try() is required.)^ ** ** ^The sqlite3_mutex_leave() routine exits a mutex that was ** previously entered by the same thread. The behavior @@ -8568,6 +8615,7 @@ SQLITE_API int sqlite3_test_control(int op, ...); #define SQLITE_TESTCTRL_ASSERT 12 #define SQLITE_TESTCTRL_ALWAYS 13 #define SQLITE_TESTCTRL_RESERVE 14 /* NOT USED */ +#define SQLITE_TESTCTRL_JSON_SELFCHECK 14 #define SQLITE_TESTCTRL_OPTIMIZATIONS 15 #define SQLITE_TESTCTRL_ISKEYWORD 16 /* NOT USED */ #define SQLITE_TESTCTRL_SCRATCHMALLOC 17 /* NOT USED */ @@ -13081,8 +13129,11 @@ struct Fts5PhraseIter { ** created with the "columnsize=0" option. ** ** xColumnText: -** This function attempts to retrieve the text of column iCol of the -** current document. If successful, (*pz) is set to point to a buffer +** If parameter iCol is less than zero, or greater than or equal to the +** number of columns in the table, SQLITE_RANGE is returned. +** +** Otherwise, this function attempts to retrieve the text of column iCol of +** the current document. If successful, (*pz) is set to point to a buffer ** containing the text in utf-8 encoding, (*pn) is set to the size in bytes ** (not characters) of the buffer and SQLITE_OK is returned. Otherwise, ** if an error occurs, an SQLite error code is returned and the final values @@ -13092,8 +13143,10 @@ struct Fts5PhraseIter { ** Returns the number of phrases in the current query expression. ** ** xPhraseSize: -** Returns the number of tokens in phrase iPhrase of the query. Phrases -** are numbered starting from zero. +** If parameter iCol is less than zero, or greater than or equal to the +** number of phrases in the current query, as returned by xPhraseCount, +** 0 is returned. Otherwise, this function returns the number of tokens in +** phrase iPhrase of the query. Phrases are numbered starting from zero. ** ** xInstCount: ** Set *pnInst to the total number of occurrences of all phrases within @@ -13109,12 +13162,13 @@ struct Fts5PhraseIter { ** Query for the details of phrase match iIdx within the current row. ** Phrase matches are numbered starting from zero, so the iIdx argument ** should be greater than or equal to zero and smaller than the value -** output by xInstCount(). +** output by xInstCount(). If iIdx is less than zero or greater than +** or equal to the value returned by xInstCount(), SQLITE_RANGE is returned. ** -** Usually, output parameter *piPhrase is set to the phrase number, *piCol +** Otherwise, output parameter *piPhrase is set to the phrase number, *piCol ** to the column in which it occurs and *piOff the token offset of the -** first token of the phrase. Returns SQLITE_OK if successful, or an error -** code (i.e. SQLITE_NOMEM) if an error occurs. +** first token of the phrase. SQLITE_OK is returned if successful, or an +** error code (i.e. SQLITE_NOMEM) if an error occurs. ** ** This API can be quite slow if used with an FTS5 table created with the ** "detail=none" or "detail=column" option. @@ -13140,6 +13194,10 @@ struct Fts5PhraseIter { ** Invoking Api.xUserData() returns a copy of the pointer passed as ** the third argument to pUserData. ** +** If parameter iPhrase is less than zero, or greater than or equal to +** the number of phrases in the query, as returned by xPhraseCount(), +** this function returns SQLITE_RANGE. +** ** If the callback function returns any value other than SQLITE_OK, the ** query is abandoned and the xQueryPhrase function returns immediately. ** If the returned value is SQLITE_DONE, xQueryPhrase returns SQLITE_OK. @@ -13254,9 +13312,42 @@ struct Fts5PhraseIter { ** ** xPhraseNextColumn() ** See xPhraseFirstColumn above. +** +** xQueryToken(pFts5, iPhrase, iToken, ppToken, pnToken) +** This is used to access token iToken of phrase iPhrase of the current +** query. Before returning, output parameter *ppToken is set to point +** to a buffer containing the requested token, and *pnToken to the +** size of this buffer in bytes. +** +** If iPhrase or iToken are less than zero, or if iPhrase is greater than +** or equal to the number of phrases in the query as reported by +** xPhraseCount(), or if iToken is equal to or greater than the number of +** tokens in the phrase, SQLITE_RANGE is returned and *ppToken and *pnToken + are both zeroed. +** +** The output text is not a copy of the query text that specified the +** token. It is the output of the tokenizer module. For tokendata=1 +** tables, this includes any embedded 0x00 and trailing data. +** +** xInstToken(pFts5, iIdx, iToken, ppToken, pnToken) +** This is used to access token iToken of phrase hit iIdx within the +** current row. If iIdx is less than zero or greater than or equal to the +** value returned by xInstCount(), SQLITE_RANGE is returned. Otherwise, +** output variable (*ppToken) is set to point to a buffer containing the +** matching document token, and (*pnToken) to the size of that buffer in +** bytes. This API is not available if the specified token matches a +** prefix query term. In that case both output variables are always set +** to 0. +** +** The output text is not a copy of the document text that was tokenized. +** It is the output of the tokenizer module. For tokendata=1 tables, this +** includes any embedded 0x00 and trailing data. +** +** This API can be quite slow if used with an FTS5 table created with the +** "detail=none" or "detail=column" option. */ struct Fts5ExtensionApi { - int iVersion; /* Currently always set to 2 */ + int iVersion; /* Currently always set to 3 */ void *(*xUserData)(Fts5Context*); @@ -13291,6 +13382,13 @@ struct Fts5ExtensionApi { int (*xPhraseFirstColumn)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*); void (*xPhraseNextColumn)(Fts5Context*, Fts5PhraseIter*, int *piCol); + + /* Below this point are iVersion>=3 only */ + int (*xQueryToken)(Fts5Context*, + int iPhrase, int iToken, + const char **ppToken, int *pnToken + ); + int (*xInstToken)(Fts5Context*, int iIdx, int iToken, const char**, int*); }; /* @@ -13777,7 +13875,7 @@ struct fts5_api { ** max_page_count macro. */ #ifndef SQLITE_MAX_PAGE_COUNT -# define SQLITE_MAX_PAGE_COUNT 1073741823 +# define SQLITE_MAX_PAGE_COUNT 0xfffffffe /* 4294967294 */ #endif /* @@ -13916,6 +14014,19 @@ struct fts5_api { # undef SQLITE_USE_SEH #endif +/* +** Enable SQLITE_DIRECT_OVERFLOW_READ, unless the build explicitly +** disables it using -DSQLITE_DIRECT_OVERFLOW_READ=0 +*/ +#if defined(SQLITE_DIRECT_OVERFLOW_READ) && SQLITE_DIRECT_OVERFLOW_READ+1==1 + /* Disable if -DSQLITE_DIRECT_OVERFLOW_READ=0 */ +# undef SQLITE_DIRECT_OVERFLOW_READ +#else + /* In all other cases, enable */ +# define SQLITE_DIRECT_OVERFLOW_READ 1 +#endif + + /* ** The SQLITE_THREADSAFE macro must be defined as 0, 1, or 2. ** 0 means mutexes are permanently disable and the library is never @@ -15798,7 +15909,7 @@ SQLITE_PRIVATE sqlite3_file *sqlite3PagerJrnlFile(Pager*); SQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager*); SQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager*); SQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager*); -SQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *, int, int, int *); +SQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *, int, int, u64*); SQLITE_PRIVATE void sqlite3PagerClearCache(Pager*); SQLITE_PRIVATE int sqlite3SectorSize(sqlite3_file *); @@ -16385,6 +16496,7 @@ typedef struct VdbeOpList VdbeOpList; #define P4_INT64 (-13) /* P4 is a 64-bit signed integer */ #define P4_INTARRAY (-14) /* P4 is a vector of 32-bit integers */ #define P4_FUNCCTX (-15) /* P4 is a pointer to an sqlite3_context object */ +#define P4_TABLEREF (-16) /* Like P4_TABLE, but reference counted */ /* Error message codes for OP_Halt */ #define P5_ConstraintNotNull 1 @@ -16607,13 +16719,15 @@ typedef struct VdbeOpList VdbeOpList; #define OP_Pagecount 178 #define OP_MaxPgcnt 179 #define OP_ClrSubtype 180 /* synopsis: r[P1].subtype = 0 */ -#define OP_FilterAdd 181 /* synopsis: filter(P1) += key(P3@P4) */ -#define OP_Trace 182 -#define OP_CursorHint 183 -#define OP_ReleaseReg 184 /* synopsis: release r[P1@P2] mask P3 */ -#define OP_Noop 185 -#define OP_Explain 186 -#define OP_Abortable 187 +#define OP_GetSubtype 181 /* synopsis: r[P2] = r[P1].subtype */ +#define OP_SetSubtype 182 /* synopsis: r[P2].subtype = r[P1] */ +#define OP_FilterAdd 183 /* synopsis: filter(P1) += key(P3@P4) */ +#define OP_Trace 184 +#define OP_CursorHint 185 +#define OP_ReleaseReg 186 /* synopsis: release r[P1@P2] mask P3 */ +#define OP_Noop 187 +#define OP_Explain 188 +#define OP_Abortable 189 /* Properties such as "out2" or "jump" that are specified in ** comments following the "case" for each opcode in the vdbe.c @@ -16649,8 +16763,8 @@ typedef struct VdbeOpList VdbeOpList; /* 152 */ 0x00, 0x10, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04,\ /* 160 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ /* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x10, 0x50,\ -/* 176 */ 0x40, 0x00, 0x10, 0x10, 0x02, 0x00, 0x00, 0x00,\ -/* 184 */ 0x00, 0x00, 0x00, 0x00,} +/* 176 */ 0x40, 0x00, 0x10, 0x10, 0x02, 0x12, 0x12, 0x00,\ +/* 184 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,} /* The resolve3P2Values() routine is able to run faster if it knows ** the value of the largest JUMP opcode. The smaller the maximum @@ -17811,14 +17925,15 @@ struct FuncDestructor { #define SQLITE_FUNC_SLOCHNG 0x2000 /* "Slow Change". Value constant during a ** single query - might change over time */ #define SQLITE_FUNC_TEST 0x4000 /* Built-in testing functions */ -/* 0x8000 -- available for reuse */ +#define SQLITE_FUNC_RUNONLY 0x8000 /* Cannot be used by valueFromFunction */ #define SQLITE_FUNC_WINDOW 0x00010000 /* Built-in window-only function */ #define SQLITE_FUNC_INTERNAL 0x00040000 /* For use by NestedParse() only */ #define SQLITE_FUNC_DIRECT 0x00080000 /* Not for use in TRIGGERs or VIEWs */ -#define SQLITE_FUNC_SUBTYPE 0x00100000 /* Result likely to have sub-type */ +/* SQLITE_SUBTYPE 0x00100000 // Consumer of subtypes */ #define SQLITE_FUNC_UNSAFE 0x00200000 /* Function has side effects */ #define SQLITE_FUNC_INLINE 0x00400000 /* Functions implemented in-line */ #define SQLITE_FUNC_BUILTIN 0x00800000 /* This is a built-in function */ +/* SQLITE_RESULT_SUBTYPE 0x01000000 // Generator of subtypes */ #define SQLITE_FUNC_ANYORDER 0x08000000 /* count/min/max aggregate */ /* Identifier numbers for each in-line function */ @@ -17910,10 +18025,11 @@ struct FuncDestructor { #define MFUNCTION(zName, nArg, xPtr, xFunc) \ {nArg, SQLITE_FUNC_BUILTIN|SQLITE_FUNC_CONSTANT|SQLITE_UTF8, \ xPtr, 0, xFunc, 0, 0, 0, #zName, {0} } -#define JFUNCTION(zName, nArg, iArg, xFunc) \ - {nArg, SQLITE_FUNC_BUILTIN|SQLITE_DETERMINISTIC|\ - SQLITE_FUNC_CONSTANT|SQLITE_UTF8, \ - SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} } +#define JFUNCTION(zName, nArg, bUseCache, bWS, bRS, bJsonB, iArg, xFunc) \ + {nArg, SQLITE_FUNC_BUILTIN|SQLITE_DETERMINISTIC|SQLITE_FUNC_CONSTANT|\ + SQLITE_UTF8|((bUseCache)*SQLITE_FUNC_RUNONLY)|\ + ((bRS)*SQLITE_SUBTYPE)|((bWS)*SQLITE_RESULT_SUBTYPE), \ + SQLITE_INT_TO_PTR(iArg|((bJsonB)*JSON_BLOB)),0,xFunc,0, 0, 0, #zName, {0} } #define INLINE_FUNC(zName, nArg, iArg, mFlags) \ {nArg, SQLITE_FUNC_BUILTIN|\ SQLITE_UTF8|SQLITE_FUNC_INLINE|SQLITE_FUNC_CONSTANT|(mFlags), \ @@ -18548,6 +18664,7 @@ struct Index { unsigned isCovering:1; /* True if this is a covering index */ unsigned noSkipScan:1; /* Do not try to use skip-scan if true */ unsigned hasStat1:1; /* aiRowLogEst values come from sqlite_stat1 */ + unsigned bLowQual:1; /* sqlite_stat1 says this is a low-quality index */ unsigned bNoQuery:1; /* Do not use this index to optimize queries */ unsigned bAscKeyBug:1; /* True if the bba7b69f9849b5bf bug applies */ unsigned bHasVCol:1; /* Index references one or more VIRTUAL columns */ @@ -18661,6 +18778,7 @@ struct AggInfo { int iOBTab; /* Ephemeral table to implement ORDER BY */ u8 bOBPayload; /* iOBTab has payload columns separate from key */ u8 bOBUnique; /* Enforce uniqueness on iOBTab keys */ + u8 bUseSubtype; /* Transfer subtype info through sorter */ } *aFunc; int nFunc; /* Number of entries in aFunc[] */ u32 selId; /* Select to which this AggInfo belongs */ @@ -19194,6 +19312,7 @@ struct NameContext { int nRef; /* Number of names resolved by this context */ int nNcErr; /* Number of errors encountered while resolving names */ int ncFlags; /* Zero or more NC_* flags defined below */ + u32 nNestedSelect; /* Number of nested selects using this NC */ Select *pWinSelect; /* SELECT statement for any window functions */ }; @@ -19910,6 +20029,9 @@ struct sqlite3_str { ** ** 3. Make a (read-only) copy of a read-only RCStr string using ** sqlite3RCStrRef(). +** +** "String" is in the name, but an RCStr object can also be used to hold +** binary data. */ struct RCStr { u64 nRCRef; /* Number of references */ @@ -19968,6 +20090,9 @@ struct Sqlite3Config { u8 bSmallMalloc; /* Avoid large memory allocations if true */ u8 bExtraSchemaChecks; /* Verify type,name,tbl_name in schema */ u8 bUseLongDouble; /* Make use of long double */ +#ifdef SQLITE_DEBUG + u8 bJsonSelfcheck; /* Double-check JSON parsing */ +#endif int mxStrlen; /* Maximum string length */ int neverCorrupt; /* Database is always well-formed */ int szLookaside; /* Default lookaside buffer size */ @@ -20594,6 +20719,7 @@ SQLITE_PRIVATE void sqlite3ExprOrderByAggregateError(Parse*,Expr*); SQLITE_PRIVATE void sqlite3ExprFunctionUsable(Parse*,const Expr*,const FuncDef*); SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32); SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*); +SQLITE_PRIVATE void sqlite3ExprDeleteGeneric(sqlite3*,void*); SQLITE_PRIVATE void sqlite3ExprDeferredDelete(Parse*, Expr*); SQLITE_PRIVATE void sqlite3ExprUnmapAndDelete(Parse*, Expr*); SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*); @@ -20603,6 +20729,7 @@ SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList*,int,int); SQLITE_PRIVATE void sqlite3ExprListSetName(Parse*,ExprList*,const Token*,int); SQLITE_PRIVATE void sqlite3ExprListSetSpan(Parse*,ExprList*,const char*,const char*); SQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3*, ExprList*); +SQLITE_PRIVATE void sqlite3ExprListDeleteGeneric(sqlite3*,void*); SQLITE_PRIVATE u32 sqlite3ExprListFlags(const ExprList*); SQLITE_PRIVATE int sqlite3IndexHasDuplicateRootPage(Index*); SQLITE_PRIVATE int sqlite3Init(sqlite3*, char**); @@ -20693,6 +20820,7 @@ SQLITE_PRIVATE int sqlite3DbMaskAllZero(yDbMask); SQLITE_PRIVATE void sqlite3DropTable(Parse*, SrcList*, int, int); SQLITE_PRIVATE void sqlite3CodeDropTable(Parse*, Table*, int, int); SQLITE_PRIVATE void sqlite3DeleteTable(sqlite3*, Table*); +SQLITE_PRIVATE void sqlite3DeleteTableGeneric(sqlite3*, void*); SQLITE_PRIVATE void sqlite3FreeIndex(sqlite3*, Index*); #ifndef SQLITE_OMIT_AUTOINCREMENT SQLITE_PRIVATE void sqlite3AutoincrementBegin(Parse *pParse); @@ -20729,6 +20857,7 @@ SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*); SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*, Expr*,ExprList*,u32,Expr*); SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*); +SQLITE_PRIVATE void sqlite3SelectDeleteGeneric(sqlite3*,void*); SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse*, SrcList*); SQLITE_PRIVATE int sqlite3IsReadOnly(Parse*, Table*, Trigger*); SQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int); @@ -20955,6 +21084,7 @@ SQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *pData, int nChar); #endif SQLITE_PRIVATE int sqlite3Utf8CharLen(const char *pData, int nByte); SQLITE_PRIVATE u32 sqlite3Utf8Read(const u8**); +SQLITE_PRIVATE int sqlite3Utf8ReadLimited(const u8*, int, u32*); SQLITE_PRIVATE LogEst sqlite3LogEst(u64); SQLITE_PRIVATE LogEst sqlite3LogEstAdd(LogEst,LogEst); SQLITE_PRIVATE LogEst sqlite3LogEstFromDouble(double); @@ -21301,6 +21431,7 @@ SQLITE_PRIVATE Cte *sqlite3CteNew(Parse*,Token*,ExprList*,Select*,u8); SQLITE_PRIVATE void sqlite3CteDelete(sqlite3*,Cte*); SQLITE_PRIVATE With *sqlite3WithAdd(Parse*,With*,Cte*); SQLITE_PRIVATE void sqlite3WithDelete(sqlite3*,With*); +SQLITE_PRIVATE void sqlite3WithDeleteGeneric(sqlite3*,void*); SQLITE_PRIVATE With *sqlite3WithPush(Parse*, With*, u8); #else # define sqlite3CteNew(P,T,E,S) ((void*)0) @@ -22678,6 +22809,9 @@ SQLITE_PRIVATE SQLITE_WSD struct Sqlite3Config sqlite3Config = { 0, /* bSmallMalloc */ 1, /* bExtraSchemaChecks */ sizeof(LONGDOUBLE_TYPE)>8, /* bUseLongDouble */ +#ifdef SQLITE_DEBUG + 0, /* bJsonSelfcheck */ +#endif 0x7ffffffe, /* mxStrlen */ 0, /* neverCorrupt */ SQLITE_DEFAULT_LOOKASIDE, /* szLookaside, nLookaside */ @@ -23930,7 +24064,7 @@ SQLITE_API int sqlite3_db_status( case SQLITE_DBSTATUS_CACHE_MISS: case SQLITE_DBSTATUS_CACHE_WRITE:{ int i; - int nRet = 0; + u64 nRet = 0; assert( SQLITE_DBSTATUS_CACHE_MISS==SQLITE_DBSTATUS_CACHE_HIT+1 ); assert( SQLITE_DBSTATUS_CACHE_WRITE==SQLITE_DBSTATUS_CACHE_HIT+2 ); @@ -23943,7 +24077,7 @@ SQLITE_API int sqlite3_db_status( *pHighwater = 0; /* IMP: R-42420-56072 */ /* IMP: R-54100-20147 */ /* IMP: R-29431-39229 */ - *pCurrent = nRet; + *pCurrent = (int)nRet & 0x7fffffff; break; } @@ -25012,6 +25146,12 @@ static int isDate( } computeJD(p); if( p->isError || !validJulianDay(p->iJD) ) return 1; + if( argc==1 && p->validYMD && p->D>28 ){ + /* Make sure a YYYY-MM-DD is normalized. + ** Example: 2023-02-31 -> 2023-03-03 */ + assert( p->validJD ); + p->validYMD = 0; + } return 0; } @@ -29453,7 +29593,7 @@ SQLITE_PRIVATE void sqlite3MemoryBarrier(void){ SQLITE_MEMORY_BARRIER; #elif defined(__GNUC__) __sync_synchronize(); -#elif MSVC_VERSION>=1300 +#elif MSVC_VERSION>=1400 _ReadWriteBarrier(); #elif defined(MemoryBarrier) MemoryBarrier(); @@ -32040,7 +32180,7 @@ SQLITE_API void sqlite3_str_appendf(StrAccum *p, const char *zFormat, ...){ /***************************************************************************** -** Reference counted string storage +** Reference counted string/blob storage *****************************************************************************/ /* @@ -32892,7 +33032,7 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m assert( pExpr->x.pList->nExpr==2 ); pY = pExpr->x.pList->a[0].pExpr; pZ = pExpr->x.pList->a[1].pExpr; - sqlite3TreeViewLine(pView, "BETWEEN"); + sqlite3TreeViewLine(pView, "BETWEEN%s", zFlgs); sqlite3TreeViewExpr(pView, pX, 1); sqlite3TreeViewExpr(pView, pY, 1); sqlite3TreeViewExpr(pView, pZ, 0); @@ -34027,7 +34167,38 @@ SQLITE_PRIVATE u32 sqlite3Utf8Read( return c; } - +/* +** Read a single UTF8 character out of buffer z[], but reading no +** more than n characters from the buffer. z[] is not zero-terminated. +** +** Return the number of bytes used to construct the character. +** +** Invalid UTF8 might generate a strange result. No effort is made +** to detect invalid UTF8. +** +** At most 4 bytes will be read out of z[]. The return value will always +** be between 1 and 4. +*/ +SQLITE_PRIVATE int sqlite3Utf8ReadLimited( + const u8 *z, + int n, + u32 *piOut +){ + u32 c; + int i = 1; + assert( n>0 ); + c = z[0]; + if( c>=0xc0 ){ + c = sqlite3Utf8Trans1[c-0xc0]; + if( n>4 ) n = 4; + while( iiBusyTimeout; +#if SQLITE_ENABLE_SETLK_TIMEOUT==1 pFile->iBusyTimeout = *(int*)pArg; +#elif SQLITE_ENABLE_SETLK_TIMEOUT==2 + pFile->iBusyTimeout = !!(*(int*)pArg); +#else +# error "SQLITE_ENABLE_SETLK_TIMEOUT must be set to 1 or 2" +#endif *(int*)pArg = iOld; return SQLITE_OK; } @@ -42101,6 +42280,25 @@ static int unixGetpagesize(void){ ** Either unixShmNode.pShmMutex must be held or unixShmNode.nRef==0 and ** unixMutexHeld() is true when reading or writing any other field ** in this structure. +** +** aLock[SQLITE_SHM_NLOCK]: +** This array records the various locks held by clients on each of the +** SQLITE_SHM_NLOCK slots. If the aLock[] entry is set to 0, then no +** locks are held by the process on this slot. If it is set to -1, then +** some client holds an EXCLUSIVE lock on the locking slot. If the aLock[] +** value is set to a positive value, then it is the number of shared +** locks currently held on the slot. +** +** aMutex[SQLITE_SHM_NLOCK]: +** Normally, when SQLITE_ENABLE_SETLK_TIMEOUT is not defined, mutex +** pShmMutex is used to protect the aLock[] array and the right to +** call fcntl() on unixShmNode.hShm to obtain or release locks. +** +** If SQLITE_ENABLE_SETLK_TIMEOUT is defined though, we use an array +** of mutexes - one for each locking slot. To read or write locking +** slot aLock[iSlot], the caller must hold the corresponding mutex +** aMutex[iSlot]. Similarly, to call fcntl() to obtain or release a +** lock corresponding to slot iSlot, mutex aMutex[iSlot] must be held. */ struct unixShmNode { unixInodeInfo *pInode; /* unixInodeInfo that owns this SHM node */ @@ -42114,10 +42312,11 @@ struct unixShmNode { char **apRegion; /* Array of mapped shared-memory regions */ int nRef; /* Number of unixShm objects pointing to this */ unixShm *pFirst; /* All unixShm objects pointing to this */ +#ifdef SQLITE_ENABLE_SETLK_TIMEOUT + sqlite3_mutex *aMutex[SQLITE_SHM_NLOCK]; +#endif int aLock[SQLITE_SHM_NLOCK]; /* # shared locks on slot, -1==excl lock */ #ifdef SQLITE_DEBUG - u8 exclMask; /* Mask of exclusive locks held */ - u8 sharedMask; /* Mask of shared locks held */ u8 nextShmId; /* Next available unixShm.id value */ #endif }; @@ -42200,16 +42399,35 @@ static int unixShmSystemLock( struct flock f; /* The posix advisory locking structure */ int rc = SQLITE_OK; /* Result code form fcntl() */ - /* Access to the unixShmNode object is serialized by the caller */ pShmNode = pFile->pInode->pShmNode; - assert( pShmNode->nRef==0 || sqlite3_mutex_held(pShmNode->pShmMutex) ); - assert( pShmNode->nRef>0 || unixMutexHeld() ); + + /* Assert that the parameters are within expected range and that the + ** correct mutex or mutexes are held. */ + assert( pShmNode->nRef>=0 ); + assert( (ofst==UNIX_SHM_DMS && n==1) + || (ofst>=UNIX_SHM_BASE && ofst+n<=(UNIX_SHM_BASE+SQLITE_SHM_NLOCK)) + ); + if( ofst==UNIX_SHM_DMS ){ + assert( pShmNode->nRef>0 || unixMutexHeld() ); + assert( pShmNode->nRef==0 || sqlite3_mutex_held(pShmNode->pShmMutex) ); + }else{ +#ifdef SQLITE_ENABLE_SETLK_TIMEOUT + int ii; + for(ii=ofst-UNIX_SHM_BASE; iiaMutex[ii]) ); + } +#else + assert( sqlite3_mutex_held(pShmNode->pShmMutex) ); + assert( pShmNode->nRef>0 ); +#endif + } /* Shared locks never span more than one byte */ assert( n==1 || lockType!=F_RDLCK ); /* Locks are within range */ assert( n>=1 && n<=SQLITE_SHM_NLOCK ); + assert( ofst>=UNIX_SHM_BASE && ofst<=(UNIX_SHM_DMS+SQLITE_SHM_NLOCK) ); if( pShmNode->hShm>=0 ){ int res; @@ -42220,7 +42438,7 @@ static int unixShmSystemLock( f.l_len = n; res = osSetPosixAdvisoryLock(pShmNode->hShm, &f, pFile); if( res==-1 ){ -#ifdef SQLITE_ENABLE_SETLK_TIMEOUT +#if defined(SQLITE_ENABLE_SETLK_TIMEOUT) && SQLITE_ENABLE_SETLK_TIMEOUT==1 rc = (pFile->iBusyTimeout ? SQLITE_BUSY_TIMEOUT : SQLITE_BUSY); #else rc = SQLITE_BUSY; @@ -42228,39 +42446,28 @@ static int unixShmSystemLock( } } - /* Update the global lock state and do debug tracing */ + /* Do debug tracing */ #ifdef SQLITE_DEBUG - { u16 mask; OSTRACE(("SHM-LOCK ")); - mask = ofst>31 ? 0xffff : (1<<(ofst+n)) - (1<exclMask &= ~mask; - pShmNode->sharedMask &= ~mask; + OSTRACE(("unlock %d..%d ok\n", ofst, ofst+n-1)); }else if( lockType==F_RDLCK ){ - OSTRACE(("read-lock %d ok", ofst)); - pShmNode->exclMask &= ~mask; - pShmNode->sharedMask |= mask; + OSTRACE(("read-lock %d..%d ok\n", ofst, ofst+n-1)); }else{ assert( lockType==F_WRLCK ); - OSTRACE(("write-lock %d ok", ofst)); - pShmNode->exclMask |= mask; - pShmNode->sharedMask &= ~mask; + OSTRACE(("write-lock %d..%d ok\n", ofst, ofst+n-1)); } }else{ if( lockType==F_UNLCK ){ - OSTRACE(("unlock %d failed", ofst)); + OSTRACE(("unlock %d..%d failed\n", ofst, ofst+n-1)); }else if( lockType==F_RDLCK ){ - OSTRACE(("read-lock failed")); + OSTRACE(("read-lock %d..%d failed\n", ofst, ofst+n-1)); }else{ assert( lockType==F_WRLCK ); - OSTRACE(("write-lock %d failed", ofst)); + OSTRACE(("write-lock %d..%d failed\n", ofst, ofst+n-1)); } } - OSTRACE((" - afterwards %03x,%03x\n", - pShmNode->sharedMask, pShmNode->exclMask)); - } #endif return rc; @@ -42297,6 +42504,11 @@ static void unixShmPurge(unixFile *pFd){ int i; assert( p->pInode==pFd->pInode ); sqlite3_mutex_free(p->pShmMutex); +#ifdef SQLITE_ENABLE_SETLK_TIMEOUT + for(i=0; iaMutex[i]); + } +#endif for(i=0; inRegion; i+=nShmPerMap){ if( p->hShm>=0 ){ osMunmap(p->apRegion[i], p->szRegion); @@ -42356,7 +42568,20 @@ static int unixLockSharedMemory(unixFile *pDbFd, unixShmNode *pShmNode){ pShmNode->isUnlocked = 1; rc = SQLITE_READONLY_CANTINIT; }else{ +#ifdef SQLITE_ENABLE_SETLK_TIMEOUT + /* Do not use a blocking lock here. If the lock cannot be obtained + ** immediately, it means some other connection is truncating the + ** *-shm file. And after it has done so, it will not release its + ** lock, but only downgrade it to a shared lock. So no point in + ** blocking here. The call below to obtain the shared DMS lock may + ** use a blocking lock. */ + int iSaveTimeout = pDbFd->iBusyTimeout; + pDbFd->iBusyTimeout = 0; +#endif rc = unixShmSystemLock(pDbFd, F_WRLCK, UNIX_SHM_DMS, 1); +#ifdef SQLITE_ENABLE_SETLK_TIMEOUT + pDbFd->iBusyTimeout = iSaveTimeout; +#endif /* The first connection to attach must truncate the -shm file. We ** truncate to 3 bytes (an arbitrary small number, less than the ** -shm header size) rather than 0 as a system debugging aid, to @@ -42477,6 +42702,18 @@ static int unixOpenSharedMemory(unixFile *pDbFd){ rc = SQLITE_NOMEM_BKPT; goto shm_open_err; } +#ifdef SQLITE_ENABLE_SETLK_TIMEOUT + { + int ii; + for(ii=0; iiaMutex[ii] = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST); + if( pShmNode->aMutex[ii]==0 ){ + rc = SQLITE_NOMEM_BKPT; + goto shm_open_err; + } + } + } +#endif } if( pInode->bProcessLock==0 ){ @@ -42698,9 +42935,11 @@ shmpage_out: */ #ifdef SQLITE_DEBUG static int assertLockingArrayOk(unixShmNode *pShmNode){ +#ifdef SQLITE_ENABLE_SETLK_TIMEOUT + return 1; +#else unixShm *pX; int aLock[SQLITE_SHM_NLOCK]; - assert( sqlite3_mutex_held(pShmNode->pShmMutex) ); memset(aLock, 0, sizeof(aLock)); for(pX=pShmNode->pFirst; pX; pX=pX->pNext){ @@ -42718,13 +42957,14 @@ static int assertLockingArrayOk(unixShmNode *pShmNode){ assert( 0==memcmp(pShmNode->aLock, aLock, sizeof(aLock)) ); return (memcmp(pShmNode->aLock, aLock, sizeof(aLock))==0); +#endif } #endif /* ** Change the lock state for a shared-memory segment. ** -** Note that the relationship between SHAREd and EXCLUSIVE locks is a little +** Note that the relationship between SHARED and EXCLUSIVE locks is a little ** different here than in posix. In xShmLock(), one can go from unlocked ** to shared and back or from unlocked to exclusive and back. But one may ** not go from shared to exclusive or from exclusive to shared. @@ -42739,7 +42979,7 @@ static int unixShmLock( unixShm *p; /* The shared memory being locked */ unixShmNode *pShmNode; /* The underlying file iNode */ int rc = SQLITE_OK; /* Result code */ - u16 mask; /* Mask of locks to take or release */ + u16 mask = (1<<(ofst+n)) - (1<pShm; @@ -42774,88 +43014,151 @@ static int unixShmLock( ** It is not permitted to block on the RECOVER lock. */ #ifdef SQLITE_ENABLE_SETLK_TIMEOUT - assert( (flags & SQLITE_SHM_UNLOCK) || pDbFd->iBusyTimeout==0 || ( - (ofst!=2) /* not RECOVER */ - && (ofst!=1 || (p->exclMask|p->sharedMask)==0) - && (ofst!=0 || (p->exclMask|p->sharedMask)<3) - && (ofst<3 || (p->exclMask|p->sharedMask)<(1<exclMask|p->sharedMask); + assert( (flags & SQLITE_SHM_UNLOCK) || pDbFd->iBusyTimeout==0 || ( + (ofst!=2) /* not RECOVER */ + && (ofst!=1 || lockMask==0 || lockMask==2) + && (ofst!=0 || lockMask<3) + && (ofst<3 || lockMask<(1<1 || mask==(1<pShmMutex); - assert( assertLockingArrayOk(pShmNode) ); - if( flags & SQLITE_SHM_UNLOCK ){ - if( (p->exclMask|p->sharedMask) & mask ){ - int ii; - int bUnlock = 1; + /* Check if there is any work to do. There are three cases: + ** + ** a) An unlock operation where there are locks to unlock, + ** b) An shared lock where the requested lock is not already held + ** c) An exclusive lock where the requested lock is not already held + ** + ** The SQLite core never requests an exclusive lock that it already holds. + ** This is assert()ed below. + */ + assert( flags!=(SQLITE_SHM_EXCLUSIVE|SQLITE_SHM_LOCK) + || 0==(p->exclMask & mask) + ); + if( ((flags & SQLITE_SHM_UNLOCK) && ((p->exclMask|p->sharedMask) & mask)) + || (flags==(SQLITE_SHM_SHARED|SQLITE_SHM_LOCK) && 0==(p->sharedMask & mask)) + || (flags==(SQLITE_SHM_EXCLUSIVE|SQLITE_SHM_LOCK)) + ){ - for(ii=ofst; ii((p->sharedMask & (1<aMutex[iMutex]); + if( rc!=SQLITE_OK ) goto leave_shmnode_mutexes; + }else{ + sqlite3_mutex_enter(pShmNode->aMutex[iMutex]); } + } +#else + sqlite3_mutex_enter(pShmNode->pShmMutex); +#endif - if( bUnlock ){ - rc = unixShmSystemLock(pDbFd, F_UNLCK, ofst+UNIX_SHM_BASE, n); + if( ALWAYS(rc==SQLITE_OK) ){ + if( flags & SQLITE_SHM_UNLOCK ){ + /* Case (a) - unlock. */ + int bUnlock = 1; + assert( (p->exclMask & p->sharedMask)==0 ); + assert( !(flags & SQLITE_SHM_EXCLUSIVE) || (p->exclMask & mask)==mask ); + assert( !(flags & SQLITE_SHM_SHARED) || (p->sharedMask & mask)==mask ); + + /* If this is a SHARED lock being unlocked, it is possible that other + ** clients within this process are holding the same SHARED lock. In + ** this case, set bUnlock to 0 so that the posix lock is not removed + ** from the file-descriptor below. */ + if( flags & SQLITE_SHM_SHARED ){ + assert( n==1 ); + assert( aLock[ofst]>=1 ); + if( aLock[ofst]>1 ){ + bUnlock = 0; + aLock[ofst]--; + p->sharedMask &= ~mask; + } + } + + if( bUnlock ){ + rc = unixShmSystemLock(pDbFd, F_UNLCK, ofst+UNIX_SHM_BASE, n); + if( rc==SQLITE_OK ){ + memset(&aLock[ofst], 0, sizeof(int)*n); + p->sharedMask &= ~mask; + p->exclMask &= ~mask; + } + } + }else if( flags & SQLITE_SHM_SHARED ){ + /* Case (b) - a shared lock. */ + + if( aLock[ofst]<0 ){ + /* An exclusive lock is held by some other connection. BUSY. */ + rc = SQLITE_BUSY; + }else if( aLock[ofst]==0 ){ + rc = unixShmSystemLock(pDbFd, F_RDLCK, ofst+UNIX_SHM_BASE, n); + } + + /* Get the local shared locks */ if( rc==SQLITE_OK ){ - memset(&aLock[ofst], 0, sizeof(int)*n); + p->sharedMask |= mask; + aLock[ofst]++; } - }else if( ALWAYS(p->sharedMask & (1<1 ); - aLock[ofst]--; - } + }else{ + /* Case (c) - an exclusive lock. */ + int ii; - /* Undo the local locks */ - if( rc==SQLITE_OK ){ - p->exclMask &= ~mask; - p->sharedMask &= ~mask; - } - } - }else if( flags & SQLITE_SHM_SHARED ){ - assert( n==1 ); - assert( (p->exclMask & (1<sharedMask & mask)==0 ){ - if( aLock[ofst]<0 ){ - rc = SQLITE_BUSY; - }else if( aLock[ofst]==0 ){ - rc = unixShmSystemLock(pDbFd, F_RDLCK, ofst+UNIX_SHM_BASE, n); - } - - /* Get the local shared locks */ - if( rc==SQLITE_OK ){ - p->sharedMask |= mask; - aLock[ofst]++; - } - } - }else{ - /* Make sure no sibling connections hold locks that will block this - ** lock. If any do, return SQLITE_BUSY right away. */ - int ii; - for(ii=ofst; iisharedMask & mask)==0 ); - if( ALWAYS((p->exclMask & (1<sharedMask & mask)==0 ); - p->exclMask |= mask; + assert( (p->exclMask & mask)==0 ); + + /* Make sure no sibling connections hold locks that will block this + ** lock. If any do, return SQLITE_BUSY right away. */ for(ii=ofst; iiexclMask |= mask; + for(ii=ofst; ii=ofst; iMutex--){ + sqlite3_mutex_leave(pShmNode->aMutex[iMutex]); + } +#else + sqlite3_mutex_leave(pShmNode->pShmMutex); +#endif } - assert( assertLockingArrayOk(pShmNode) ); - sqlite3_mutex_leave(pShmNode->pShmMutex); + OSTRACE(("SHM-LOCK shmid-%d, pid-%d got %03x,%03x\n", p->id, osGetpid(0), p->sharedMask, p->exclMask)); return rc; @@ -57073,7 +57376,7 @@ struct Pager { char *zJournal; /* Name of the journal file */ int (*xBusyHandler)(void*); /* Function to call when busy */ void *pBusyHandlerArg; /* Context argument for xBusyHandler */ - int aStat[4]; /* Total cache hits, misses, writes, spills */ + u32 aStat[4]; /* Total cache hits, misses, writes, spills */ #ifdef SQLITE_TEST int nRead; /* Database pages read */ #endif @@ -57203,9 +57506,8 @@ SQLITE_PRIVATE int sqlite3PagerDirectReadOk(Pager *pPager, Pgno pgno){ #ifndef SQLITE_OMIT_WAL if( pPager->pWal ){ u32 iRead = 0; - int rc; - rc = sqlite3WalFindFrame(pPager->pWal, pgno, &iRead); - return (rc==SQLITE_OK && iRead==0); + (void)sqlite3WalFindFrame(pPager->pWal, pgno, &iRead); + return iRead==0; } #endif return 1; @@ -61447,10 +61749,13 @@ act_like_temp_file: */ SQLITE_API sqlite3_file *sqlite3_database_file_object(const char *zName){ Pager *pPager; + const char *p; while( zName[-1]!=0 || zName[-2]!=0 || zName[-3]!=0 || zName[-4]!=0 ){ zName--; } - pPager = *(Pager**)(zName - 4 - sizeof(Pager*)); + p = zName - 4 - sizeof(Pager*); + assert( EIGHT_BYTE_ALIGNMENT(p) ); + pPager = *(Pager**)p; return pPager->fd; } @@ -63214,11 +63519,11 @@ SQLITE_PRIVATE int *sqlite3PagerStats(Pager *pPager){ a[3] = pPager->eState==PAGER_OPEN ? -1 : (int) pPager->dbSize; a[4] = pPager->eState; a[5] = pPager->errCode; - a[6] = pPager->aStat[PAGER_STAT_HIT]; - a[7] = pPager->aStat[PAGER_STAT_MISS]; + a[6] = (int)pPager->aStat[PAGER_STAT_HIT] & 0x7fffffff; + a[7] = (int)pPager->aStat[PAGER_STAT_MISS] & 0x7fffffff; a[8] = 0; /* Used to be pPager->nOvfl */ a[9] = pPager->nRead; - a[10] = pPager->aStat[PAGER_STAT_WRITE]; + a[10] = (int)pPager->aStat[PAGER_STAT_WRITE] & 0x7fffffff; return a; } #endif @@ -63234,7 +63539,7 @@ SQLITE_PRIVATE int *sqlite3PagerStats(Pager *pPager){ ** reset parameter is non-zero, the cache hit or miss count is zeroed before ** returning. */ -SQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *pPager, int eStat, int reset, int *pnVal){ +SQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *pPager, int eStat, int reset, u64 *pnVal){ assert( eStat==SQLITE_DBSTATUS_CACHE_HIT || eStat==SQLITE_DBSTATUS_CACHE_MISS @@ -64174,7 +64479,7 @@ SQLITE_PRIVATE int sqlite3PagerWalFramesize(Pager *pPager){ } #endif -#ifdef SQLITE_USE_SEH +#if defined(SQLITE_USE_SEH) && !defined(SQLITE_OMIT_WAL) SQLITE_PRIVATE int sqlite3PagerWalSystemErrno(Pager *pPager){ return sqlite3WalSystemErrno(pPager->pWal); } @@ -66190,6 +66495,19 @@ static int walIteratorInit(Wal *pWal, u32 nBackfill, WalIterator **pp){ } #ifdef SQLITE_ENABLE_SETLK_TIMEOUT + + +/* +** Attempt to enable blocking locks that block for nMs ms. Return 1 if +** blocking locks are successfully enabled, or 0 otherwise. +*/ +static int walEnableBlockingMs(Wal *pWal, int nMs){ + int rc = sqlite3OsFileControl( + pWal->pDbFd, SQLITE_FCNTL_LOCK_TIMEOUT, (void*)&nMs + ); + return (rc==SQLITE_OK); +} + /* ** Attempt to enable blocking locks. Blocking locks are enabled only if (a) ** they are supported by the VFS, and (b) the database handle is configured @@ -66201,11 +66519,7 @@ static int walEnableBlocking(Wal *pWal){ if( pWal->db ){ int tmout = pWal->db->busyTimeout; if( tmout ){ - int rc; - rc = sqlite3OsFileControl( - pWal->pDbFd, SQLITE_FCNTL_LOCK_TIMEOUT, (void*)&tmout - ); - res = (rc==SQLITE_OK); + res = walEnableBlockingMs(pWal, tmout); } } return res; @@ -66254,20 +66568,10 @@ SQLITE_PRIVATE void sqlite3WalDb(Wal *pWal, sqlite3 *db){ pWal->db = db; } -/* -** Take an exclusive WRITE lock. Blocking if so configured. -*/ -static int walLockWriter(Wal *pWal){ - int rc; - walEnableBlocking(pWal); - rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1); - walDisableBlocking(pWal); - return rc; -} #else # define walEnableBlocking(x) 0 # define walDisableBlocking(x) -# define walLockWriter(pWal) walLockExclusive((pWal), WAL_WRITE_LOCK, 1) +# define walEnableBlockingMs(pWal, ms) 0 # define sqlite3WalDb(pWal, db) #endif /* ifdef SQLITE_ENABLE_SETLK_TIMEOUT */ @@ -66868,7 +67172,9 @@ static int walIndexReadHdr(Wal *pWal, int *pChanged){ } }else{ int bWriteLock = pWal->writeLock; - if( bWriteLock || SQLITE_OK==(rc = walLockWriter(pWal)) ){ + if( bWriteLock + || SQLITE_OK==(rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1)) + ){ pWal->writeLock = 1; if( SQLITE_OK==(rc = walIndexPage(pWal, 0, &page0)) ){ badHdr = walIndexTryHdr(pWal, pChanged); @@ -66876,7 +67182,8 @@ static int walIndexReadHdr(Wal *pWal, int *pChanged){ /* If the wal-index header is still malformed even while holding ** a WRITE lock, it can only mean that the header is corrupted and ** needs to be reconstructed. So run recovery to do exactly that. - */ + ** Disable blocking locks first. */ + walDisableBlocking(pWal); rc = walIndexRecover(pWal); *pChanged = 1; } @@ -67086,6 +67393,37 @@ static int walBeginShmUnreliable(Wal *pWal, int *pChanged){ return rc; } +/* +** The final argument passed to walTryBeginRead() is of type (int*). The +** caller should invoke walTryBeginRead as follows: +** +** int cnt = 0; +** do { +** rc = walTryBeginRead(..., &cnt); +** }while( rc==WAL_RETRY ); +** +** The final value of "cnt" is of no use to the caller. It is used by +** the implementation of walTryBeginRead() as follows: +** +** + Each time walTryBeginRead() is called, it is incremented. Once +** it reaches WAL_RETRY_PROTOCOL_LIMIT - indicating that walTryBeginRead() +** has many times been invoked and failed with WAL_RETRY - walTryBeginRead() +** returns SQLITE_PROTOCOL. +** +** + If SQLITE_ENABLE_SETLK_TIMEOUT is defined and walTryBeginRead() failed +** because a blocking lock timed out (SQLITE_BUSY_TIMEOUT from the OS +** layer), the WAL_RETRY_BLOCKED_MASK bit is set in "cnt". In this case +** the next invocation of walTryBeginRead() may omit an expected call to +** sqlite3OsSleep(). There has already been a delay when the previous call +** waited on a lock. +*/ +#define WAL_RETRY_PROTOCOL_LIMIT 100 +#ifdef SQLITE_ENABLE_SETLK_TIMEOUT +# define WAL_RETRY_BLOCKED_MASK 0x10000000 +#else +# define WAL_RETRY_BLOCKED_MASK 0 +#endif + /* ** Attempt to start a read transaction. This might fail due to a race or ** other transient condition. When that happens, it returns WAL_RETRY to @@ -67136,13 +67474,16 @@ static int walBeginShmUnreliable(Wal *pWal, int *pChanged){ ** so it takes care to hold an exclusive lock on the corresponding ** WAL_READ_LOCK() while changing values. */ -static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){ +static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int *pCnt){ volatile WalCkptInfo *pInfo; /* Checkpoint information in wal-index */ u32 mxReadMark; /* Largest aReadMark[] value */ int mxI; /* Index of largest aReadMark[] value */ int i; /* Loop counter */ int rc = SQLITE_OK; /* Return code */ u32 mxFrame; /* Wal frame to lock to */ +#ifdef SQLITE_ENABLE_SETLK_TIMEOUT + int nBlockTmout = 0; +#endif assert( pWal->readLock<0 ); /* Not currently locked */ @@ -67166,14 +67507,34 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){ ** so that on the 100th (and last) RETRY we delay for 323 milliseconds. ** The total delay time before giving up is less than 10 seconds. */ - if( cnt>5 ){ + (*pCnt)++; + if( *pCnt>5 ){ int nDelay = 1; /* Pause time in microseconds */ - if( cnt>100 ){ + int cnt = (*pCnt & ~WAL_RETRY_BLOCKED_MASK); + if( cnt>WAL_RETRY_PROTOCOL_LIMIT ){ VVA_ONLY( pWal->lockError = 1; ) return SQLITE_PROTOCOL; } - if( cnt>=10 ) nDelay = (cnt-9)*(cnt-9)*39; + if( *pCnt>=10 ) nDelay = (cnt-9)*(cnt-9)*39; +#ifdef SQLITE_ENABLE_SETLK_TIMEOUT + /* In SQLITE_ENABLE_SETLK_TIMEOUT builds, configure the file-descriptor + ** to block for locks for approximately nDelay us. This affects three + ** locks: (a) the shared lock taken on the DMS slot in os_unix.c (if + ** using os_unix.c), (b) the WRITER lock taken in walIndexReadHdr() if the + ** first attempted read fails, and (c) the shared lock taken on the + ** read-mark. + ** + ** If the previous call failed due to an SQLITE_BUSY_TIMEOUT error, + ** then sleep for the minimum of 1us. The previous call already provided + ** an extra delay while it was blocking on the lock. + */ + nBlockTmout = (nDelay+998) / 1000; + if( !useWal && walEnableBlockingMs(pWal, nBlockTmout) ){ + if( *pCnt & WAL_RETRY_BLOCKED_MASK ) nDelay = 1; + } +#endif sqlite3OsSleep(pWal->pVfs, nDelay); + *pCnt &= ~WAL_RETRY_BLOCKED_MASK; } if( !useWal ){ @@ -67181,6 +67542,13 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){ if( pWal->bShmUnreliable==0 ){ rc = walIndexReadHdr(pWal, pChanged); } +#ifdef SQLITE_ENABLE_SETLK_TIMEOUT + walDisableBlocking(pWal); + if( rc==SQLITE_BUSY_TIMEOUT ){ + rc = SQLITE_BUSY; + *pCnt |= WAL_RETRY_BLOCKED_MASK; + } +#endif if( rc==SQLITE_BUSY ){ /* If there is not a recovery running in another thread or process ** then convert BUSY errors to WAL_RETRY. If recovery is known to @@ -67295,9 +67663,19 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){ return rc==SQLITE_BUSY ? WAL_RETRY : SQLITE_READONLY_CANTINIT; } + (void)walEnableBlockingMs(pWal, nBlockTmout); rc = walLockShared(pWal, WAL_READ_LOCK(mxI)); + walDisableBlocking(pWal); if( rc ){ - return rc==SQLITE_BUSY ? WAL_RETRY : rc; +#ifdef SQLITE_ENABLE_SETLK_TIMEOUT + if( rc==SQLITE_BUSY_TIMEOUT ){ + *pCnt |= WAL_RETRY_BLOCKED_MASK; + } +#else + assert( rc!=SQLITE_BUSY_TIMEOUT ); +#endif + assert( (rc&0xFF)!=SQLITE_BUSY||rc==SQLITE_BUSY||rc==SQLITE_BUSY_TIMEOUT ); + return (rc&0xFF)==SQLITE_BUSY ? WAL_RETRY : rc; } /* Now that the read-lock has been obtained, check that neither the ** value in the aReadMark[] array or the contents of the wal-index @@ -67485,7 +67863,7 @@ static int walBeginReadTransaction(Wal *pWal, int *pChanged){ #endif do{ - rc = walTryBeginRead(pWal, pChanged, 0, ++cnt); + rc = walTryBeginRead(pWal, pChanged, 0, &cnt); }while( rc==WAL_RETRY ); testcase( (rc&0xff)==SQLITE_BUSY ); testcase( (rc&0xff)==SQLITE_IOERR ); @@ -67666,6 +68044,7 @@ static int walFindFrame( iRead = iFrame; } if( (nCollide--)==0 ){ + *piRead = 0; return SQLITE_CORRUPT_BKPT; } iKey = walNextHash(iKey); @@ -67969,7 +68348,7 @@ static int walRestartLog(Wal *pWal){ cnt = 0; do{ int notUsed; - rc = walTryBeginRead(pWal, ¬Used, 1, ++cnt); + rc = walTryBeginRead(pWal, ¬Used, 1, &cnt); }while( rc==WAL_RETRY ); assert( (rc&0xff)!=SQLITE_BUSY ); /* BUSY not possible when useWal==1 */ testcase( (rc&0xff)==SQLITE_IOERR ); @@ -68390,10 +68769,9 @@ SQLITE_PRIVATE int sqlite3WalCheckpoint( if( pWal->readOnly ) return SQLITE_READONLY; WALTRACE(("WAL%p: checkpoint begins\n", pWal)); - /* Enable blocking locks, if possible. If blocking locks are successfully - ** enabled, set xBusy2=0 so that the busy-handler is never invoked. */ + /* Enable blocking locks, if possible. */ sqlite3WalDb(pWal, db); - (void)walEnableBlocking(pWal); + if( xBusy2 ) (void)walEnableBlocking(pWal); /* IMPLEMENTATION-OF: R-62028-47212 All calls obtain an exclusive ** "checkpoint" lock on the database file. @@ -68434,9 +68812,14 @@ SQLITE_PRIVATE int sqlite3WalCheckpoint( /* Read the wal-index header. */ SEH_TRY { if( rc==SQLITE_OK ){ + /* For a passive checkpoint, do not re-enable blocking locks after + ** reading the wal-index header. A passive checkpoint should not block + ** or invoke the busy handler. The only lock such a checkpoint may + ** attempt to obtain is a lock on a read-slot, and it should give up + ** immediately and do a partial checkpoint if it cannot obtain it. */ walDisableBlocking(pWal); rc = walIndexReadHdr(pWal, &isChanged); - (void)walEnableBlocking(pWal); + if( eMode2!=SQLITE_CHECKPOINT_PASSIVE ) (void)walEnableBlocking(pWal); if( isChanged && pWal->pDbFd->pMethods->iVersion>=3 ){ sqlite3OsUnfetch(pWal->pDbFd, 0, 0); } @@ -68773,7 +69156,7 @@ SQLITE_PRIVATE sqlite3_file *sqlite3WalFile(Wal *pWal){ ** 22 1 Min embedded payload fraction (must be 32) ** 23 1 Min leaf payload fraction (must be 32) ** 24 4 File change counter -** 28 4 Reserved for future use +** 28 4 The size of the database in pages ** 32 4 First freelist page ** 36 4 Number of freelist pages in the file ** 40 60 15 4-byte meta values passed to higher layers @@ -74900,7 +75283,6 @@ static int accessPayload( assert( aWrite>=pBufStart ); /* due to (6) */ memcpy(aSave, aWrite, 4); rc = sqlite3OsRead(fd, aWrite, a+4, (i64)pBt->pageSize*(nextPage-1)); - if( rc && nextPage>pBt->nPage ) rc = SQLITE_CORRUPT_BKPT; nextPage = get4byte(aWrite); memcpy(aWrite, aSave, 4); }else @@ -83411,7 +83793,7 @@ static int valueFromFunction( #endif assert( pFunc ); if( (pFunc->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG))==0 - || (pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL) + || (pFunc->funcFlags & (SQLITE_FUNC_NEEDCOLL|SQLITE_FUNC_RUNONLY))!=0 ){ return SQLITE_OK; } @@ -84135,10 +84517,11 @@ static int growOpArray(Vdbe *v, int nOp){ ** sqlite3CantopenError(lineno) */ static void test_addop_breakpoint(int pc, Op *pOp){ - static int n = 0; + static u64 n = 0; (void)pc; (void)pOp; n++; + if( n==LARGEST_UINT64 ) abort(); /* so that n is used, preventing a warning */ } #endif @@ -85323,6 +85706,10 @@ static void freeP4(sqlite3 *db, int p4type, void *p4){ if( db->pnBytesFreed==0 ) sqlite3VtabUnlock((VTable *)p4); break; } + case P4_TABLEREF: { + if( db->pnBytesFreed==0 ) sqlite3DeleteTable(db, (Table*)p4); + break; + } } } @@ -85450,7 +85837,7 @@ static void SQLITE_NOINLINE vdbeChangeP4Full( int n ){ if( pOp->p4type ){ - freeP4(p->db, pOp->p4type, pOp->p4.p); + assert( pOp->p4type > P4_FREE_IF_LE ); pOp->p4type = 0; pOp->p4.p = 0; } @@ -89573,7 +89960,15 @@ SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt *pStmt){ int rc = SQLITE_OK; Vdbe *p = (Vdbe*)pStmt; #if SQLITE_THREADSAFE - sqlite3_mutex *mutex = ((Vdbe*)pStmt)->db->mutex; + sqlite3_mutex *mutex; +#endif +#ifdef SQLITE_ENABLE_API_ARMOR + if( pStmt==0 ){ + return SQLITE_MISUSE_BKPT; + } +#endif +#if SQLITE_THREADSAFE + mutex = p->db->mutex; #endif sqlite3_mutex_enter(mutex); for(i=0; inVar; i++){ @@ -89952,6 +90347,18 @@ SQLITE_API void sqlite3_result_subtype(sqlite3_context *pCtx, unsigned int eSubt #ifdef SQLITE_ENABLE_API_ARMOR if( pCtx==0 ) return; #endif +#if defined(SQLITE_STRICT_SUBTYPE) && SQLITE_STRICT_SUBTYPE+0!=0 + if( pCtx->pFunc!=0 + && (pCtx->pFunc->funcFlags & SQLITE_RESULT_SUBTYPE)==0 + ){ + char zErr[200]; + sqlite3_snprintf(sizeof(zErr), zErr, + "misuse of sqlite3_result_subtype() by %s()", + pCtx->pFunc->zName); + sqlite3_result_error(pCtx, zErr, -1); + return; + } +#endif /* SQLITE_STRICT_SUBTYPE */ pOut = pCtx->pOut; assert( sqlite3_mutex_held(pOut->db->mutex) ); pOut->eSubtype = eSubtype & 0xff; @@ -90351,9 +90758,8 @@ SQLITE_API int sqlite3_step(sqlite3_stmt *pStmt){ SQLITE_API void *sqlite3_user_data(sqlite3_context *p){ #ifdef SQLITE_ENABLE_API_ARMOR if( p==0 ) return 0; -#else - assert( p && p->pFunc ); #endif + assert( p && p->pFunc ); return p->pFunc->pUserData; } @@ -92270,11 +92676,12 @@ SQLITE_API int sqlite3_found_count = 0; ** sqlite3CantopenError(lineno) */ static void test_trace_breakpoint(int pc, Op *pOp, Vdbe *v){ - static int n = 0; + static u64 n = 0; (void)pc; (void)pOp; (void)v; n++; + if( n==LARGEST_UINT64 ) abort(); /* So that n is used, preventing a warning */ } #endif @@ -94171,7 +94578,7 @@ case OP_AddImm: { /* in1 */ pIn1 = &aMem[pOp->p1]; memAboutToChange(p, pIn1); sqlite3VdbeMemIntegerify(pIn1); - pIn1->u.i += pOp->p2; + *(u64*)&pIn1->u.i += (u64)pOp->p2; break; } @@ -100317,24 +100724,23 @@ case OP_VCheck: { /* out2 */ pOut = &aMem[pOp->p2]; sqlite3VdbeMemSetNull(pOut); /* Innocent until proven guilty */ - assert( pOp->p4type==P4_TABLE ); + assert( pOp->p4type==P4_TABLEREF ); pTab = pOp->p4.pTab; assert( pTab!=0 ); + assert( pTab->nTabRef>0 ); assert( IsVirtual(pTab) ); - assert( pTab->u.vtab.p!=0 ); + if( pTab->u.vtab.p==0 ) break; pVtab = pTab->u.vtab.p->pVtab; assert( pVtab!=0 ); pModule = pVtab->pModule; assert( pModule!=0 ); assert( pModule->iVersion>=4 ); assert( pModule->xIntegrity!=0 ); - pTab->nTabRef++; sqlite3VtabLock(pTab->u.vtab.p); assert( pOp->p1>=0 && pOp->p1nDb ); rc = pModule->xIntegrity(pVtab, db->aDb[pOp->p1].zDbSName, pTab->zName, pOp->p3, &zErr); sqlite3VtabUnlock(pTab->u.vtab.p); - sqlite3DeleteTable(db, pTab); if( rc ){ sqlite3_free(zErr); goto abort_due_to_error; @@ -100459,6 +100865,7 @@ case OP_VColumn: { /* ncycle */ const sqlite3_module *pModule; Mem *pDest; sqlite3_context sContext; + FuncDef nullFunc; VdbeCursor *pCur = p->apCsr[pOp->p1]; assert( pCur!=0 ); @@ -100476,6 +100883,9 @@ case OP_VColumn: { /* ncycle */ memset(&sContext, 0, sizeof(sContext)); sContext.pOut = pDest; sContext.enc = encoding; + nullFunc.pUserData = 0; + nullFunc.funcFlags = SQLITE_RESULT_SUBTYPE; + sContext.pFunc = &nullFunc; assert( pOp->p5==OPFLAG_NOCHNG || pOp->p5==0 ); if( pOp->p5 & OPFLAG_NOCHNG ){ sqlite3VdbeMemSetNull(pDest); @@ -100808,6 +101218,42 @@ case OP_ClrSubtype: { /* in1 */ break; } +/* Opcode: GetSubtype P1 P2 * * * +** Synopsis: r[P2] = r[P1].subtype +** +** Extract the subtype value from register P1 and write that subtype +** into register P2. If P1 has no subtype, then P1 gets a NULL. +*/ +case OP_GetSubtype: { /* in1 out2 */ + pIn1 = &aMem[pOp->p1]; + pOut = &aMem[pOp->p2]; + if( pIn1->flags & MEM_Subtype ){ + sqlite3VdbeMemSetInt64(pOut, pIn1->eSubtype); + }else{ + sqlite3VdbeMemSetNull(pOut); + } + break; +} + +/* Opcode: SetSubtype P1 P2 * * * +** Synopsis: r[P2].subtype = r[P1] +** +** Set the subtype value of register P2 to the integer from register P1. +** If P1 is NULL, clear the subtype from p2. +*/ +case OP_SetSubtype: { /* in1 out2 */ + pIn1 = &aMem[pOp->p1]; + pOut = &aMem[pOp->p2]; + if( pIn1->flags & MEM_Null ){ + pOut->flags &= ~MEM_Subtype; + }else{ + assert( pIn1->flags & MEM_Int ); + pOut->flags |= MEM_Subtype; + pOut->eSubtype = (u8)(pIn1->u.i & 0xff); + } + break; +} + /* Opcode: FilterAdd P1 * P3 P4 * ** Synopsis: filter(P1) += key(P3@P4) ** @@ -105856,6 +106302,7 @@ SQLITE_PRIVATE Bitmask sqlite3ExprColUsed(Expr *pExpr){ assert( ExprUseYTab(pExpr) ); pExTab = pExpr->y.pTab; assert( pExTab!=0 ); + assert( n < pExTab->nCol ); if( (pExTab->tabFlags & TF_HasGenerated)!=0 && (pExTab->aCol[n].colFlags & COLFLAG_GENERATED)!=0 ){ @@ -106432,6 +106879,7 @@ static int lookupName( sqlite3RecordErrorOffsetOfExpr(pParse->db, pExpr); pParse->checkSchema = 1; pTopNC->nNcErr++; + eNewExprOp = TK_NULL; } assert( pFJMatch==0 ); @@ -106458,7 +106906,7 @@ static int lookupName( ** If a generated column is referenced, set bits for every column ** of the table. */ - if( pExpr->iColumn>=0 && pMatch!=0 ){ + if( pExpr->iColumn>=0 && cnt==1 && pMatch!=0 ){ pMatch->colUsed |= sqlite3ExprColUsed(pExpr); } @@ -106923,11 +107371,12 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ while( pNC2 && sqlite3ReferencesSrcList(pParse, pExpr, pNC2->pSrcList)==0 ){ - pExpr->op2++; + pExpr->op2 += (1 + pNC2->nNestedSelect); pNC2 = pNC2->pNext; } assert( pDef!=0 || IN_RENAME_OBJECT ); if( pNC2 && pDef ){ + pExpr->op2 += pNC2->nNestedSelect; assert( SQLITE_FUNC_MINMAX==NC_MinMaxAgg ); assert( SQLITE_FUNC_ANYORDER==NC_OrderAgg ); testcase( (pDef->funcFlags & SQLITE_FUNC_MINMAX)!=0 ); @@ -107486,6 +107935,7 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ /* Recursively resolve names in all subqueries in the FROM clause */ + if( pOuterNC ) pOuterNC->nNestedSelect++; for(i=0; ipSrc->nSrc; i++){ SrcItem *pItem = &p->pSrc->a[i]; if( pItem->pSelect && (pItem->pSelect->selFlags & SF_Resolved)==0 ){ @@ -107510,6 +107960,9 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ } } } + if( pOuterNC && ALWAYS(pOuterNC->nNestedSelect>0) ){ + pOuterNC->nNestedSelect--; + } /* Set up the local name-context to pass to sqlite3ResolveExprNames() to ** resolve the result-set expression list. @@ -109097,9 +109550,7 @@ SQLITE_PRIVATE void sqlite3ExprAddFunctionOrderBy( assert( ExprUseXList(pExpr) ); if( pExpr->x.pList==0 || NEVER(pExpr->x.pList->nExpr==0) ){ /* Ignore ORDER BY on zero-argument aggregates */ - sqlite3ParserAddCleanup(pParse, - (void(*)(sqlite3*,void*))sqlite3ExprListDelete, - pOrderBy); + sqlite3ParserAddCleanup(pParse, sqlite3ExprListDeleteGeneric, pOrderBy); return; } if( IsWindowFunc(pExpr) ){ @@ -109280,6 +109731,9 @@ static SQLITE_NOINLINE void sqlite3ExprDeleteNN(sqlite3 *db, Expr *p){ SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3 *db, Expr *p){ if( p ) sqlite3ExprDeleteNN(db, p); } +SQLITE_PRIVATE void sqlite3ExprDeleteGeneric(sqlite3 *db, void *p){ + if( ALWAYS(p) ) sqlite3ExprDeleteNN(db, (Expr*)p); +} /* ** Clear both elements of an OnOrUsing object @@ -109305,9 +109759,7 @@ SQLITE_PRIVATE void sqlite3ClearOnOrUsing(sqlite3 *db, OnOrUsing *p){ ** pExpr to the pParse->pConstExpr list with a register number of 0. */ SQLITE_PRIVATE void sqlite3ExprDeferredDelete(Parse *pParse, Expr *pExpr){ - sqlite3ParserAddCleanup(pParse, - (void(*)(sqlite3*,void*))sqlite3ExprDelete, - pExpr); + sqlite3ParserAddCleanup(pParse, sqlite3ExprDeleteGeneric, pExpr); } /* Invoke sqlite3RenameExprUnmap() and sqlite3ExprDelete() on the @@ -110113,6 +110565,9 @@ static SQLITE_NOINLINE void exprListDeleteNN(sqlite3 *db, ExprList *pList){ SQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3 *db, ExprList *pList){ if( pList ) exprListDeleteNN(db, pList); } +SQLITE_PRIVATE void sqlite3ExprListDeleteGeneric(sqlite3 *db, void *pList){ + if( ALWAYS(pList) ) exprListDeleteNN(db, (ExprList*)pList); +} /* ** Return the bitwise-OR of all Expr.flags fields in the given @@ -110612,9 +111067,10 @@ SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr *p){ case TK_COLUMN: assert( ExprUseYTab(p) ); return ExprHasProperty(p, EP_CanBeNull) || - p->y.pTab==0 || /* Reference to column of index on expression */ + NEVER(p->y.pTab==0) || /* Reference to column of index on expr */ (p->iColumn>=0 && p->y.pTab->aCol!=0 /* Possible due to prior error */ + && ALWAYS(p->iColumny.pTab->nCol) && p->y.pTab->aCol[p->iColumn].notNull==0); default: return 1; @@ -113196,8 +113652,10 @@ SQLITE_PRIVATE void sqlite3ExprCode(Parse *pParse, Expr *pExpr, int target){ inReg = sqlite3ExprCodeTarget(pParse, pExpr, target); if( inReg!=target ){ u8 op; - if( ALWAYS(pExpr) - && (ExprHasProperty(pExpr,EP_Subquery) || pExpr->op==TK_REGISTER) + Expr *pX = sqlite3ExprSkipCollateAndLikely(pExpr); + testcase( pX!=pExpr ); + if( ALWAYS(pX) + && (ExprHasProperty(pX,EP_Subquery) || pX->op==TK_REGISTER) ){ op = OP_Copy; }else{ @@ -113917,8 +114375,8 @@ SQLITE_PRIVATE int sqlite3ExprListCompare(const ExprList *pA, const ExprList *pB */ SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr *pA,Expr *pB, int iTab){ return sqlite3ExprCompare(0, - sqlite3ExprSkipCollateAndLikely(pA), - sqlite3ExprSkipCollateAndLikely(pB), + sqlite3ExprSkipCollate(pA), + sqlite3ExprSkipCollate(pB), iTab); } @@ -114643,13 +115101,14 @@ static int analyzeAggregate(Walker *pWalker, Expr *pExpr){ case TK_AGG_FUNCTION: { if( (pNC->ncFlags & NC_InAggFunc)==0 && pWalker->walkerDepth==pExpr->op2 + && pExpr->pAggInfo==0 ){ /* Check to see if pExpr is a duplicate of another aggregate ** function that is already in the pAggInfo structure */ struct AggInfo_func *pItem = pAggInfo->aFunc; for(i=0; inFunc; i++, pItem++){ - if( pItem->pFExpr==pExpr ) break; + if( NEVER(pItem->pFExpr==pExpr) ) break; if( sqlite3ExprCompare(0, pItem->pFExpr, pExpr, -1)==0 ){ break; } @@ -114692,6 +115151,8 @@ static int analyzeAggregate(Walker *pWalker, Expr *pExpr){ }else{ pItem->bOBPayload = 1; } + pItem->bUseSubtype = + (pItem->pFunc->funcFlags & SQLITE_SUBTYPE)!=0; }else{ pItem->iOBTab = -1; } @@ -117458,9 +117919,9 @@ static void openStatTable( typedef struct StatAccum StatAccum; typedef struct StatSample StatSample; struct StatSample { - tRowcnt *anEq; /* sqlite_stat4.nEq */ tRowcnt *anDLt; /* sqlite_stat4.nDLt */ #ifdef SQLITE_ENABLE_STAT4 + tRowcnt *anEq; /* sqlite_stat4.nEq */ tRowcnt *anLt; /* sqlite_stat4.nLt */ union { i64 iRowid; /* Rowid in main table of the key */ @@ -117618,9 +118079,9 @@ static void statInit( /* Allocate the space required for the StatAccum object */ n = sizeof(*p) - + sizeof(tRowcnt)*nColUp /* StatAccum.anEq */ - + sizeof(tRowcnt)*nColUp; /* StatAccum.anDLt */ + + sizeof(tRowcnt)*nColUp; /* StatAccum.anDLt */ #ifdef SQLITE_ENABLE_STAT4 + n += sizeof(tRowcnt)*nColUp; /* StatAccum.anEq */ if( mxSample ){ n += sizeof(tRowcnt)*nColUp /* StatAccum.anLt */ + sizeof(StatSample)*(nCol+mxSample) /* StatAccum.aBest[], a[] */ @@ -117641,9 +118102,9 @@ static void statInit( p->nKeyCol = nKeyCol; p->nSkipAhead = 0; p->current.anDLt = (tRowcnt*)&p[1]; - p->current.anEq = &p->current.anDLt[nColUp]; #ifdef SQLITE_ENABLE_STAT4 + p->current.anEq = &p->current.anDLt[nColUp]; p->mxSample = p->nLimit==0 ? mxSample : 0; if( mxSample ){ u8 *pSpace; /* Allocated space not yet assigned */ @@ -117910,7 +118371,9 @@ static void statPush( if( p->nRow==0 ){ /* This is the first call to this function. Do initialization. */ +#ifdef SQLITE_ENABLE_STAT4 for(i=0; inCol; i++) p->current.anEq[i] = 1; +#endif }else{ /* Second and subsequent calls get processed here */ #ifdef SQLITE_ENABLE_STAT4 @@ -117919,15 +118382,17 @@ static void statPush( /* Update anDLt[], anLt[] and anEq[] to reflect the values that apply ** to the current row of the index. */ +#ifdef SQLITE_ENABLE_STAT4 for(i=0; icurrent.anEq[i]++; } +#endif for(i=iChng; inCol; i++){ p->current.anDLt[i]++; #ifdef SQLITE_ENABLE_STAT4 if( p->mxSample ) p->current.anLt[i] += p->current.anEq[i]; -#endif p->current.anEq[i] = 1; +#endif } } @@ -118061,7 +118526,9 @@ static void statGet( u64 iVal = (p->nRow + nDistinct - 1) / nDistinct; if( iVal==2 && p->nRow*10 <= nDistinct*11 ) iVal = 1; sqlite3_str_appendf(&sStat, " %llu", iVal); +#ifdef SQLITE_ENABLE_STAT4 assert( p->current.anEq[i] ); +#endif } sqlite3ResultStrAccum(context, &sStat); } @@ -118750,6 +119217,16 @@ static void decodeIntArray( while( z[0]!=0 && z[0]!=' ' ) z++; while( z[0]==' ' ) z++; } + + /* Set the bLowQual flag if the peak number of rows obtained + ** from a full equality match is so large that a full table scan + ** seems likely to be faster than using the index. + */ + if( aLog[0] > 66 /* Index has more than 100 rows */ + && aLog[0] <= aLog[nOut-1] /* And only a single value seen */ + ){ + pIndex->bLowQual = 1; + } } } @@ -120796,7 +121273,7 @@ SQLITE_PRIVATE void sqlite3ColumnSetExpr( */ SQLITE_PRIVATE Expr *sqlite3ColumnExpr(Table *pTab, Column *pCol){ if( pCol->iDflt==0 ) return 0; - if( NEVER(!IsOrdinaryTable(pTab)) ) return 0; + if( !IsOrdinaryTable(pTab) ) return 0; if( NEVER(pTab->u.tab.pDfltList==0) ) return 0; if( NEVER(pTab->u.tab.pDfltList->nExpriDflt) ) return 0; return pTab->u.tab.pDfltList->a[pCol->iDflt-1].pExpr; @@ -120949,6 +121426,9 @@ SQLITE_PRIVATE void sqlite3DeleteTable(sqlite3 *db, Table *pTable){ if( db->pnBytesFreed==0 && (--pTable->nTabRef)>0 ) return; deleteTable(db, pTable); } +SQLITE_PRIVATE void sqlite3DeleteTableGeneric(sqlite3 *db, void *pTable){ + sqlite3DeleteTable(db, (Table*)pTable); +} /* @@ -121486,7 +121966,8 @@ SQLITE_PRIVATE void sqlite3ColumnPropertiesFromName(Table *pTab, Column *pCol){ /* ** Clean up the data structures associated with the RETURNING clause. */ -static void sqlite3DeleteReturning(sqlite3 *db, Returning *pRet){ +static void sqlite3DeleteReturning(sqlite3 *db, void *pArg){ + Returning *pRet = (Returning*)pArg; Hash *pHash; pHash = &(db->aDb[1].pSchema->trigHash); sqlite3HashInsert(pHash, pRet->zName, 0); @@ -121528,8 +122009,7 @@ SQLITE_PRIVATE void sqlite3AddReturning(Parse *pParse, ExprList *pList){ pParse->u1.pReturning = pRet; pRet->pParse = pParse; pRet->pReturnEL = pList; - sqlite3ParserAddCleanup(pParse, - (void(*)(sqlite3*,void*))sqlite3DeleteReturning, pRet); + sqlite3ParserAddCleanup(pParse, sqlite3DeleteReturning, pRet); testcase( pParse->earlyCleanup ); if( db->mallocFailed ) return; sqlite3_snprintf(sizeof(pRet->zName), pRet->zName, @@ -121728,7 +122208,8 @@ SQLITE_PRIVATE char sqlite3AffinityType(const char *zIn, Column *pCol){ assert( zIn!=0 ); while( zIn[0] ){ - h = (h<<8) + sqlite3UpperToLower[(*zIn)&0xff]; + u8 x = *(u8*)zIn; + h = (h<<8) + sqlite3UpperToLower[x]; zIn++; if( h==(('c'<<24)+('h'<<16)+('a'<<8)+'r') ){ /* CHAR */ aff = SQLITE_AFF_TEXT; @@ -125593,7 +126074,7 @@ SQLITE_PRIVATE void sqlite3Reindex(Parse *pParse, Token *pName1, Token *pName2){ if( iDb<0 ) return; z = sqlite3NameFromToken(db, pObjName); if( z==0 ) return; - zDb = db->aDb[iDb].zDbSName; + zDb = pName2->n ? db->aDb[iDb].zDbSName : 0; pTab = sqlite3FindTable(db, z, zDb); if( pTab ){ reindexTable(pParse, pTab, 0); @@ -125603,6 +126084,7 @@ SQLITE_PRIVATE void sqlite3Reindex(Parse *pParse, Token *pName1, Token *pName2){ pIndex = sqlite3FindIndex(db, z, zDb); sqlite3DbFree(db, z); if( pIndex ){ + iDb = sqlite3SchemaToIndex(db, pIndex->pTable->pSchema); sqlite3BeginWriteOperation(pParse, 0, iDb); sqlite3RefillIndex(pParse, pIndex, -1); return; @@ -125768,6 +126250,9 @@ SQLITE_PRIVATE void sqlite3WithDelete(sqlite3 *db, With *pWith){ sqlite3DbFree(db, pWith); } } +SQLITE_PRIVATE void sqlite3WithDeleteGeneric(sqlite3 *db, void *pWith){ + sqlite3WithDelete(db, (With*)pWith); +} #endif /* !defined(SQLITE_OMIT_CTE) */ /************** End of build.c ***********************************************/ @@ -138993,7 +139478,8 @@ SQLITE_PRIVATE void sqlite3Pragma( if( pVTab->pModule->iVersion<4 ) continue; if( pVTab->pModule->xIntegrity==0 ) continue; sqlite3VdbeAddOp3(v, OP_VCheck, i, 3, isQuick); - sqlite3VdbeAppendP4(v, pTab, P4_TABLE); + pTab->nTabRef++; + sqlite3VdbeAppendP4(v, pTab, P4_TABLEREF); a1 = sqlite3VdbeAddOp1(v, OP_IsNull, 3); VdbeCoverage(v); integrityCheckResultRow(v); sqlite3VdbeJumpHere(v, a1); @@ -141020,6 +141506,7 @@ static int sqlite3LockAndPrepare( assert( (rc&db->errMask)==rc ); db->busyHandler.nBusy = 0; sqlite3_mutex_leave(db->mutex); + assert( rc==SQLITE_OK || (*ppStmt)==0 ); return rc; } @@ -141417,6 +141904,9 @@ SQLITE_PRIVATE Select *sqlite3SelectNew( SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3 *db, Select *p){ if( OK_IF_ALWAYS_TRUE(p) ) clearSelect(db, p, 1); } +SQLITE_PRIVATE void sqlite3SelectDeleteGeneric(sqlite3 *db, void *p){ + if( ALWAYS(p) ) clearSelect(db, (Select*)p, 1); +} /* ** Return a pointer to the right-most SELECT statement in a compound. @@ -143552,7 +144042,8 @@ SQLITE_PRIVATE void sqlite3SubqueryColumnTypes( NameContext sNC; assert( pSelect!=0 ); - assert( (pSelect->selFlags & SF_Resolved)!=0 ); + testcase( (pSelect->selFlags & SF_Resolved)==0 ); + assert( (pSelect->selFlags & SF_Resolved)!=0 || IN_RENAME_OBJECT ); assert( pTab->nCol==pSelect->pEList->nExpr || pParse->nErr>0 ); assert( aff==SQLITE_AFF_NONE || aff==SQLITE_AFF_BLOB ); if( db->mallocFailed || IN_RENAME_OBJECT ) return; @@ -144436,9 +144927,7 @@ multi_select_end: pDest->iSdst = dest.iSdst; pDest->nSdst = dest.nSdst; if( pDelete ){ - sqlite3ParserAddCleanup(pParse, - (void(*)(sqlite3*,void*))sqlite3SelectDelete, - pDelete); + sqlite3ParserAddCleanup(pParse, sqlite3SelectDeleteGeneric, pDelete); } return rc; } @@ -144989,8 +145478,7 @@ static int multiSelectOrderBy( /* Make arrangements to free the 2nd and subsequent arms of the compound ** after the parse has finished */ if( pSplit->pPrior ){ - sqlite3ParserAddCleanup(pParse, - (void(*)(sqlite3*,void*))sqlite3SelectDelete, pSplit->pPrior); + sqlite3ParserAddCleanup(pParse, sqlite3SelectDeleteGeneric, pSplit->pPrior); } pSplit->pPrior = pPrior; pPrior->pNext = pSplit; @@ -145811,9 +146299,7 @@ static int flattenSubquery( Table *pTabToDel = pSubitem->pTab; if( pTabToDel->nTabRef==1 ){ Parse *pToplevel = sqlite3ParseToplevel(pParse); - sqlite3ParserAddCleanup(pToplevel, - (void(*)(sqlite3*,void*))sqlite3DeleteTable, - pTabToDel); + sqlite3ParserAddCleanup(pToplevel, sqlite3DeleteTableGeneric, pTabToDel); testcase( pToplevel->earlyCleanup ); }else{ pTabToDel->nTabRef--; @@ -146860,8 +147346,7 @@ static struct Cte *searchWith( SQLITE_PRIVATE With *sqlite3WithPush(Parse *pParse, With *pWith, u8 bFree){ if( pWith ){ if( bFree ){ - pWith = (With*)sqlite3ParserAddCleanup(pParse, - (void(*)(sqlite3*,void*))sqlite3WithDelete, + pWith = (With*)sqlite3ParserAddCleanup(pParse, sqlite3WithDeleteGeneric, pWith); if( pWith==0 ) return 0; } @@ -147605,10 +148090,11 @@ static void selectAddSubqueryTypeInfo(Walker *pWalker, Select *p){ SrcList *pTabList; SrcItem *pFrom; - assert( p->selFlags & SF_Resolved ); if( p->selFlags & SF_HasTypeInfo ) return; p->selFlags |= SF_HasTypeInfo; pParse = pWalker->pParse; + testcase( (p->selFlags & SF_Resolved)==0 ); + assert( (p->selFlags & SF_Resolved) || IN_RENAME_OBJECT ); pTabList = p->pSrc; for(i=0, pFrom=pTabList->a; inSrc; i++, pFrom++){ Table *pTab = pFrom->pTab; @@ -147893,6 +148379,7 @@ static void resetAccumulator(Parse *pParse, AggInfo *pAggInfo){ assert( pFunc->pFExpr->pLeft!=0 ); assert( pFunc->pFExpr->pLeft->op==TK_ORDER ); assert( ExprUseXList(pFunc->pFExpr->pLeft) ); + assert( pFunc->pFunc!=0 ); pOBList = pFunc->pFExpr->pLeft->x.pList; if( !pFunc->bOBUnique ){ nExtra++; /* One extra column for the OP_Sequence */ @@ -147902,6 +148389,9 @@ static void resetAccumulator(Parse *pParse, AggInfo *pAggInfo){ assert( ExprUseXList(pFunc->pFExpr) ); nExtra += pFunc->pFExpr->x.pList->nExpr; } + if( pFunc->bUseSubtype ){ + nExtra += pFunc->pFExpr->x.pList->nExpr; + } pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pOBList, 0, nExtra); if( !pFunc->bOBUnique && pParse->nErr==0 ){ pKeyInfo->nKeyField++; @@ -147928,9 +148418,9 @@ static void finalizeAggFunctions(Parse *pParse, AggInfo *pAggInfo){ assert( ExprUseXList(pF->pFExpr) ); pList = pF->pFExpr->x.pList; if( pF->iOBTab>=0 ){ - /* For an ORDER BY aggregate, calls to OP_AggStep where deferred and - ** all content was stored in emphermal table pF->iOBTab. Extract that - ** content now (in ORDER BY order) and make all calls to OP_AggStep + /* For an ORDER BY aggregate, calls to OP_AggStep were deferred. Inputs + ** were stored in emphermal table pF->iOBTab. Here, we extract those + ** inputs (in ORDER BY order) and make all calls to OP_AggStep ** before doing the OP_AggFinal call. */ int iTop; /* Start of loop for extracting columns */ int nArg; /* Number of columns to extract */ @@ -147938,6 +148428,7 @@ static void finalizeAggFunctions(Parse *pParse, AggInfo *pAggInfo){ int regAgg; /* Extract into this array */ int j; /* Loop counter */ + assert( pF->pFunc!=0 ); nArg = pList->nExpr; regAgg = sqlite3GetTempRange(pParse, nArg); @@ -147954,6 +148445,15 @@ static void finalizeAggFunctions(Parse *pParse, AggInfo *pAggInfo){ for(j=nArg-1; j>=0; j--){ sqlite3VdbeAddOp3(v, OP_Column, pF->iOBTab, nKey+j, regAgg+j); } + if( pF->bUseSubtype ){ + int regSubtype = sqlite3GetTempReg(pParse); + int iBaseCol = nKey + nArg + (pF->bOBPayload==0 && pF->bOBUnique==0); + for(j=nArg-1; j>=0; j--){ + sqlite3VdbeAddOp3(v, OP_Column, pF->iOBTab, iBaseCol+j, regSubtype); + sqlite3VdbeAddOp2(v, OP_SetSubtype, regSubtype, regAgg+j); + } + sqlite3ReleaseTempReg(pParse, regSubtype); + } sqlite3VdbeAddOp3(v, OP_AggStep, 0, regAgg, AggInfoFuncReg(pAggInfo,i)); sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF); sqlite3VdbeChangeP5(v, (u8)nArg); @@ -148008,6 +148508,7 @@ static void updateAccumulator( ExprList *pList; assert( ExprUseXList(pF->pFExpr) ); assert( !IsWindowFunc(pF->pFExpr) ); + assert( pF->pFunc!=0 ); pList = pF->pFExpr->x.pList; if( ExprHasProperty(pF->pFExpr, EP_WinFunc) ){ Expr *pFilter = pF->pFExpr->y.pWin->pFilter; @@ -148052,6 +148553,9 @@ static void updateAccumulator( if( pF->bOBPayload ){ regAggSz += nArg; } + if( pF->bUseSubtype ){ + regAggSz += nArg; + } regAggSz++; /* One extra register to hold result of MakeRecord */ regAgg = sqlite3GetTempRange(pParse, regAggSz); regDistinct = regAgg; @@ -148064,6 +148568,14 @@ static void updateAccumulator( if( pF->bOBPayload ){ regDistinct = regAgg+jj; sqlite3ExprCodeExprList(pParse, pList, regDistinct, 0, SQLITE_ECEL_DUP); + jj += nArg; + } + if( pF->bUseSubtype ){ + int kk; + int regBase = pF->bOBPayload ? regDistinct : regAgg; + for(kk=0; kknExpr; @@ -148268,7 +148780,8 @@ static SrcItem *isSelfJoinView( /* ** Deallocate a single AggInfo object */ -static void agginfoFree(sqlite3 *db, AggInfo *p){ +static void agginfoFree(sqlite3 *db, void *pArg){ + AggInfo *p = (AggInfo*)pArg; sqlite3DbFree(db, p->aCol); sqlite3DbFree(db, p->aFunc); sqlite3DbFreeNN(db, p); @@ -148342,7 +148855,7 @@ static int countOfViewOptimization(Parse *pParse, Select *p){ pSub->selFlags |= SF_Aggregate; pSub->selFlags &= ~SF_Compound; pSub->nSelectRow = 0; - sqlite3ExprListDelete(db, pSub->pEList); + sqlite3ParserAddCleanup(pParse, sqlite3ExprListDeleteGeneric, pSub->pEList); pTerm = pPrior ? sqlite3ExprDup(db, pCount, 0) : pCount; pSub->pEList = sqlite3ExprListAppend(pParse, 0, pTerm); pTerm = sqlite3PExpr(pParse, TK_SELECT, 0, 0); @@ -148522,9 +149035,8 @@ SQLITE_PRIVATE int sqlite3Select( sqlite3TreeViewExprList(0, p->pOrderBy, 0, "ORDERBY"); } #endif - sqlite3ParserAddCleanup(pParse, - (void(*)(sqlite3*,void*))sqlite3ExprListDelete, - p->pOrderBy); + sqlite3ParserAddCleanup(pParse, sqlite3ExprListDeleteGeneric, + p->pOrderBy); testcase( pParse->earlyCleanup ); p->pOrderBy = 0; } @@ -148630,6 +149142,7 @@ SQLITE_PRIVATE int sqlite3Select( TREETRACE(0x1000,pParse,p, ("LEFT-JOIN simplifies to JOIN on term %d\n",i)); pItem->fg.jointype &= ~(JT_LEFT|JT_OUTER); + unsetJoinExpr(p->pWhere, pItem->iCursor, 0); } } if( pItem->fg.jointype & JT_LTORJ ){ @@ -148644,17 +149157,15 @@ SQLITE_PRIVATE int sqlite3Select( TREETRACE(0x1000,pParse,p, ("RIGHT-JOIN simplifies to JOIN on term %d\n",j)); pI2->fg.jointype &= ~(JT_RIGHT|JT_OUTER); + unsetJoinExpr(p->pWhere, pI2->iCursor, 1); } } } - for(j=pTabList->nSrc-1; j>=i; j--){ + for(j=pTabList->nSrc-1; j>=0; j--){ pTabList->a[j].fg.jointype &= ~JT_LTORJ; if( pTabList->a[j].fg.jointype & JT_RIGHT ) break; } } - assert( pItem->iCursor>=0 ); - unsetJoinExpr(p->pWhere, pItem->iCursor, - pTabList->a[0].fg.jointype & JT_LTORJ); } /* No further action if this term of the FROM clause is not a subquery */ @@ -148717,9 +149228,8 @@ SQLITE_PRIVATE int sqlite3Select( ){ TREETRACE(0x800,pParse,p, ("omit superfluous ORDER BY on %r FROM-clause subquery\n",i+1)); - sqlite3ParserAddCleanup(pParse, - (void(*)(sqlite3*,void*))sqlite3ExprListDelete, - pSub->pOrderBy); + sqlite3ParserAddCleanup(pParse, sqlite3ExprListDeleteGeneric, + pSub->pOrderBy); pSub->pOrderBy = 0; } @@ -149248,8 +149758,7 @@ SQLITE_PRIVATE int sqlite3Select( */ pAggInfo = sqlite3DbMallocZero(db, sizeof(*pAggInfo) ); if( pAggInfo ){ - sqlite3ParserAddCleanup(pParse, - (void(*)(sqlite3*,void*))agginfoFree, pAggInfo); + sqlite3ParserAddCleanup(pParse, agginfoFree, pAggInfo); testcase( pParse->earlyCleanup ); } if( db->mallocFailed ){ @@ -153898,7 +154407,6 @@ SQLITE_PRIVATE void sqlite3VtabUnlockList(sqlite3 *db){ if( p ){ db->pDisconnect = 0; - sqlite3ExpirePreparedStatements(db, 0); do { VTable *pNext = p->pNext; sqlite3VtabUnlock(p); @@ -155464,7 +155972,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereGetMask(WhereMaskSet*,int); #ifdef WHERETRACE_ENABLED SQLITE_PRIVATE void sqlite3WhereClausePrint(WhereClause *pWC); SQLITE_PRIVATE void sqlite3WhereTermPrint(WhereTerm *pTerm, int iTerm); -SQLITE_PRIVATE void sqlite3WhereLoopPrint(WhereLoop *p, WhereClause *pWC); +SQLITE_PRIVATE void sqlite3WhereLoopPrint(const WhereLoop *p, const WhereClause *pWC); #endif SQLITE_PRIVATE WhereTerm *sqlite3WhereFindTerm( WhereClause *pWC, /* The WHERE clause to be searched */ @@ -160926,12 +161434,22 @@ static void translateColumnToCopy( for(; iStartp1!=iTabCur ) continue; if( pOp->opcode==OP_Column ){ +#ifdef SQLITE_DEBUG + if( pParse->db->flags & SQLITE_VdbeAddopTrace ){ + printf("TRANSLATE OP_Column to OP_Copy at %d\n", iStart); + } +#endif pOp->opcode = OP_Copy; pOp->p1 = pOp->p2 + iRegister; pOp->p2 = pOp->p3; pOp->p3 = 0; pOp->p5 = 2; /* Cause the MEM_Subtype flag to be cleared */ }else if( pOp->opcode==OP_Rowid ){ +#ifdef SQLITE_DEBUG + if( pParse->db->flags & SQLITE_VdbeAddopTrace ){ + printf("TRANSLATE OP_Rowid to OP_Sequence at %d\n", iStart); + } +#endif pOp->opcode = OP_Sequence; pOp->p1 = iAutoidxCur; #ifdef SQLITE_ALLOW_ROWID_IN_VIEW @@ -162258,7 +162776,8 @@ static int whereRangeScanEst( ** sample, then assume they are 4x more selective. This brings ** the estimated selectivity more in line with what it would be ** if estimated without the use of STAT4 tables. */ - if( iLwrIdx==iUprIdx ) nNew -= 20; assert( 20==sqlite3LogEst(4) ); + if( iLwrIdx==iUprIdx ){ nNew -= 20; } + assert( 20==sqlite3LogEst(4) ); }else{ nNew = 10; assert( 10==sqlite3LogEst(2) ); } @@ -162482,17 +163001,34 @@ SQLITE_PRIVATE void sqlite3WhereClausePrint(WhereClause *pWC){ #ifdef WHERETRACE_ENABLED /* ** Print a WhereLoop object for debugging purposes +** +** Format example: +** +** .--- Position in WHERE clause rSetup, rRun, nOut ---. +** | | +** | .--- selfMask nTerm ------. | +** | | | | +** | | .-- prereq Idx wsFlags----. | | +** | | | Name | | | +** | | | __|__ nEq ---. ___|__ | __|__ +** | / \ / \ / \ | / \ / \ / \ +** 1.002.001 t2.t2xy 2 f 010241 N 2 cost 0,56,31 */ -SQLITE_PRIVATE void sqlite3WhereLoopPrint(WhereLoop *p, WhereClause *pWC){ - WhereInfo *pWInfo = pWC->pWInfo; - int nb = 1+(pWInfo->pTabList->nSrc+3)/4; - SrcItem *pItem = pWInfo->pTabList->a + p->iTab; - Table *pTab = pItem->pTab; - Bitmask mAll = (((Bitmask)1)<<(nb*4)) - 1; - sqlite3DebugPrintf("%c%2d.%0*llx.%0*llx", p->cId, - p->iTab, nb, p->maskSelf, nb, p->prereq & mAll); - sqlite3DebugPrintf(" %12s", - pItem->zAlias ? pItem->zAlias : pTab->zName); +SQLITE_PRIVATE void sqlite3WhereLoopPrint(const WhereLoop *p, const WhereClause *pWC){ + if( pWC ){ + WhereInfo *pWInfo = pWC->pWInfo; + int nb = 1+(pWInfo->pTabList->nSrc+3)/4; + SrcItem *pItem = pWInfo->pTabList->a + p->iTab; + Table *pTab = pItem->pTab; + Bitmask mAll = (((Bitmask)1)<<(nb*4)) - 1; + sqlite3DebugPrintf("%c%2d.%0*llx.%0*llx", p->cId, + p->iTab, nb, p->maskSelf, nb, p->prereq & mAll); + sqlite3DebugPrintf(" %12s", + pItem->zAlias ? pItem->zAlias : pTab->zName); + }else{ + sqlite3DebugPrintf("%c%2d.%03llx.%03llx %c%d", + p->cId, p->iTab, p->maskSelf, p->prereq & 0xfff, p->cId, p->iTab); + } if( (p->wsFlags & WHERE_VIRTUALTABLE)==0 ){ const char *zName; if( p->u.btree.pIndex && (zName = p->u.btree.pIndex->zName)!=0 ){ @@ -162529,6 +163065,15 @@ SQLITE_PRIVATE void sqlite3WhereLoopPrint(WhereLoop *p, WhereClause *pWC){ } } } +SQLITE_PRIVATE void sqlite3ShowWhereLoop(const WhereLoop *p){ + if( p ) sqlite3WhereLoopPrint(p, 0); +} +SQLITE_PRIVATE void sqlite3ShowWhereLoopList(const WhereLoop *p){ + while( p ){ + sqlite3ShowWhereLoop(p); + p = p->pNextLoop; + } +} #endif /* @@ -162641,46 +163186,60 @@ static void whereInfoFree(sqlite3 *db, WhereInfo *pWInfo){ } /* -** Return TRUE if all of the following are true: +** Return TRUE if X is a proper subset of Y but is of equal or less cost. +** In other words, return true if all constraints of X are also part of Y +** and Y has additional constraints that might speed the search that X lacks +** but the cost of running X is not more than the cost of running Y. ** -** (1) X has the same or lower cost, or returns the same or fewer rows, -** than Y. -** (2) X uses fewer WHERE clause terms than Y -** (3) Every WHERE clause term used by X is also used by Y -** (4) X skips at least as many columns as Y -** (5) If X is a covering index, than Y is too +** In other words, return true if the cost relationwship between X and Y +** is inverted and needs to be adjusted. ** -** Conditions (2) and (3) mean that X is a "proper subset" of Y. -** If X is a proper subset of Y then Y is a better choice and ought -** to have a lower cost. This routine returns TRUE when that cost -** relationship is inverted and needs to be adjusted. Constraint (4) -** was added because if X uses skip-scan less than Y it still might -** deserve a lower cost even if it is a proper subset of Y. Constraint (5) -** was added because a covering index probably deserves to have a lower cost -** than a non-covering index even if it is a proper subset. +** Case 1: +** +** (1a) X and Y use the same index. +** (1b) X has fewer == terms than Y +** (1c) Neither X nor Y use skip-scan +** (1d) X does not have a a greater cost than Y +** +** Case 2: +** +** (2a) X has the same or lower cost, or returns the same or fewer rows, +** than Y. +** (2b) X uses fewer WHERE clause terms than Y +** (2c) Every WHERE clause term used by X is also used by Y +** (2d) X skips at least as many columns as Y +** (2e) If X is a covering index, than Y is too */ static int whereLoopCheaperProperSubset( const WhereLoop *pX, /* First WhereLoop to compare */ const WhereLoop *pY /* Compare against this WhereLoop */ ){ int i, j; - if( pX->nLTerm-pX->nSkip >= pY->nLTerm-pY->nSkip ){ - return 0; /* X is not a subset of Y */ + if( pX->rRun>pY->rRun && pX->nOut>pY->nOut ) return 0; /* (1d) and (2a) */ + assert( (pX->wsFlags & WHERE_VIRTUALTABLE)==0 ); + assert( (pY->wsFlags & WHERE_VIRTUALTABLE)==0 ); + if( pX->u.btree.nEq < pY->u.btree.nEq /* (1b) */ + && pX->u.btree.pIndex==pY->u.btree.pIndex /* (1a) */ + && pX->nSkip==0 && pY->nSkip==0 /* (1c) */ + ){ + return 1; /* Case 1 is true */ } - if( pX->rRun>pY->rRun && pX->nOut>pY->nOut ) return 0; - if( pY->nSkip > pX->nSkip ) return 0; + if( pX->nLTerm-pX->nSkip >= pY->nLTerm-pY->nSkip ){ + return 0; /* (2b) */ + } + if( pY->nSkip > pX->nSkip ) return 0; /* (2d) */ for(i=pX->nLTerm-1; i>=0; i--){ if( pX->aLTerm[i]==0 ) continue; for(j=pY->nLTerm-1; j>=0; j--){ if( pY->aLTerm[j]==pX->aLTerm[i] ) break; } - if( j<0 ) return 0; /* X not a subset of Y since term X[i] not used by Y */ + if( j<0 ) return 0; /* (2c) */ } if( (pX->wsFlags&WHERE_IDX_ONLY)!=0 && (pY->wsFlags&WHERE_IDX_ONLY)==0 ){ - return 0; /* Constraint (5) */ + return 0; /* (2e) */ } - return 1; /* All conditions meet */ + return 1; /* Case 2 is true */ } /* @@ -163170,7 +163729,10 @@ static int whereLoopAddBtreeIndex( assert( pNew->u.btree.nBtm==0 ); opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE|WO_ISNULL|WO_IS; } - if( pProbe->bUnordered ) opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE); + if( pProbe->bUnordered || pProbe->bLowQual ){ + if( pProbe->bUnordered ) opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE); + if( pProbe->bLowQual ) opMask &= ~(WO_EQ|WO_IN|WO_IS); + } assert( pNew->u.btree.nEqnColumn ); assert( pNew->u.btree.nEqnKeyCol @@ -166058,6 +166620,20 @@ static SQLITE_NOINLINE void whereAddIndexedExpr( continue; } if( sqlite3ExprIsConstant(pExpr) ) continue; + if( pExpr->op==TK_FUNCTION ){ + /* Functions that might set a subtype should not be replaced by the + ** value taken from an expression index since the index omits the + ** subtype. https://sqlite.org/forum/forumpost/68d284c86b082c3e */ + int n; + FuncDef *pDef; + sqlite3 *db = pParse->db; + assert( ExprUseXList(pExpr) ); + n = pExpr->x.pList ? pExpr->x.pList->nExpr : 0; + pDef = sqlite3FindFunction(db, pExpr->u.zToken, n, ENC(db), 0); + if( pDef==0 || (pDef->funcFlags & SQLITE_RESULT_SUBTYPE)!=0 ){ + continue; + } + } p = sqlite3DbMallocRaw(pParse->db, sizeof(IndexedExpr)); if( p==0 ) break; p->pIENext = pParse->pIdxEpr; @@ -166261,7 +166837,10 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin( ** field (type Bitmask) it must be aligned on an 8-byte boundary on ** some architectures. Hence the ROUND8() below. */ - nByteWInfo = ROUND8P(sizeof(WhereInfo)+(nTabList-1)*sizeof(WhereLevel)); + nByteWInfo = ROUND8P(sizeof(WhereInfo)); + if( nTabList>1 ){ + nByteWInfo = ROUND8P(nByteWInfo + (nTabList-1)*sizeof(WhereLevel)); + } pWInfo = sqlite3DbMallocRawNN(db, nByteWInfo + sizeof(WhereLoop)); if( db->mallocFailed ){ sqlite3DbFree(db, pWInfo); @@ -166823,6 +167402,11 @@ whereBeginError: pParse->nQueryLoop = pWInfo->savedNQueryLoop; whereInfoFree(db, pWInfo); } +#ifdef WHERETRACE_ENABLED + /* Prevent harmless compiler warnings about debugging routines + ** being declared but never used */ + sqlite3ShowWhereLoopList(0); +#endif /* WHERETRACE_ENABLED */ return 0; } @@ -168240,7 +168824,7 @@ SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){ assert( ExprUseXList(pWin->pOwner) ); assert( pWin->pWFunc!=0 ); pArgs = pWin->pOwner->x.pList; - if( pWin->pWFunc->funcFlags & SQLITE_FUNC_SUBTYPE ){ + if( pWin->pWFunc->funcFlags & SQLITE_SUBTYPE ){ selectWindowRewriteEList(pParse, pMWin, pSrc, pArgs, pTab, &pSublist); pWin->iArgCol = (pSublist ? pSublist->nExpr : 0); pWin->bExprArgs = 1; @@ -179414,7 +179998,7 @@ SQLITE_PRIVATE int sqlite3CreateFunc( assert( SQLITE_FUNC_CONSTANT==SQLITE_DETERMINISTIC ); assert( SQLITE_FUNC_DIRECT==SQLITE_DIRECTONLY ); extraFlags = enc & (SQLITE_DETERMINISTIC|SQLITE_DIRECTONLY| - SQLITE_SUBTYPE|SQLITE_INNOCUOUS); + SQLITE_SUBTYPE|SQLITE_INNOCUOUS|SQLITE_RESULT_SUBTYPE); enc &= (SQLITE_FUNC_ENCMASK|SQLITE_ANY); /* The SQLITE_INNOCUOUS flag is the same bit as SQLITE_FUNC_UNSAFE. But @@ -182159,6 +182743,28 @@ SQLITE_API int sqlite3_test_control(int op, ...){ break; } #endif + + /* sqlite3_test_control(SQLITE_TESTCTRL_JSON_SELFCHECK, &onOff); + ** + ** Activate or deactivate validation of JSONB that is generated from + ** text. Off by default, as the validation is slow. Validation is + ** only available if compiled using SQLITE_DEBUG. + ** + ** If onOff is initially 1, then turn it on. If onOff is initially + ** off, turn it off. If onOff is initially -1, then change onOff + ** to be the current setting. + */ + case SQLITE_TESTCTRL_JSON_SELFCHECK: { +#if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_WSD) + int *pOnOff = va_arg(ap, int*); + if( *pOnOff<0 ){ + *pOnOff = sqlite3Config.bJsonSelfcheck; + }else{ + sqlite3Config.bJsonSelfcheck = (u8)((*pOnOff)&0xff); + } +#endif + break; + } } va_end(ap); #endif /* SQLITE_UNTESTABLE */ @@ -202573,24 +203179,145 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeFold(int c, int eRemoveDiacritic){ ** ****************************************************************************** ** -** This SQLite JSON functions. +** SQLite JSON functions. ** ** This file began as an extension in ext/misc/json1.c in 2015. That ** extension proved so useful that it has now been moved into the core. ** -** For the time being, all JSON is stored as pure text. (We might add -** a JSONB type in the future which stores a binary encoding of JSON in -** a BLOB, but there is no support for JSONB in the current implementation. -** This implementation parses JSON text at 250 MB/s, so it is hard to see -** how JSONB might improve on that.) +** The original design stored all JSON as pure text, canonical RFC-8259. +** Support for JSON-5 extensions was added with version 3.42.0 (2023-05-16). +** All generated JSON text still conforms strictly to RFC-8259, but text +** with JSON-5 extensions is accepted as input. +** +** Beginning with version 3.45.0 (circa 2024-01-01), these routines also +** accept BLOB values that have JSON encoded using a binary representation +** called "JSONB". The name JSONB comes from PostgreSQL, however the on-disk +** format SQLite JSONB is completely different and incompatible with +** PostgreSQL JSONB. +** +** Decoding and interpreting JSONB is still O(N) where N is the size of +** the input, the same as text JSON. However, the constant of proportionality +** for JSONB is much smaller due to faster parsing. The size of each +** element in JSONB is encoded in its header, so there is no need to search +** for delimiters using persnickety syntax rules. JSONB seems to be about +** 3x faster than text JSON as a result. JSONB is also tends to be slightly +** smaller than text JSON, by 5% or 10%, but there are corner cases where +** JSONB can be slightly larger. So you are not far mistaken to say that +** a JSONB blob is the same size as the equivalent RFC-8259 text. +** +** +** THE JSONB ENCODING: +** +** Every JSON element is encoded in JSONB as a header and a payload. +** The header is between 1 and 9 bytes in size. The payload is zero +** or more bytes. +** +** The lower 4 bits of the first byte of the header determines the +** element type: +** +** 0: NULL +** 1: TRUE +** 2: FALSE +** 3: INT -- RFC-8259 integer literal +** 4: INT5 -- JSON5 integer literal +** 5: FLOAT -- RFC-8259 floating point literal +** 6: FLOAT5 -- JSON5 floating point literal +** 7: TEXT -- Text literal acceptable to both SQL and JSON +** 8: TEXTJ -- Text containing RFC-8259 escapes +** 9: TEXT5 -- Text containing JSON5 and/or RFC-8259 escapes +** 10: TEXTRAW -- Text containing unescaped syntax characters +** 11: ARRAY +** 12: OBJECT +** +** The other three possible values (13-15) are reserved for future +** enhancements. +** +** The upper 4 bits of the first byte determine the size of the header +** and sometimes also the size of the payload. If X is the first byte +** of the element and if X>>4 is between 0 and 11, then the payload +** will be that many bytes in size and the header is exactly one byte +** in size. Other four values for X>>4 (12-15) indicate that the header +** is more than one byte in size and that the payload size is determined +** by the remainder of the header, interpreted as a unsigned big-endian +** integer. +** +** Value of X>>4 Size integer Total header size +** ------------- -------------------- ----------------- +** 12 1 byte (0-255) 2 +** 13 2 byte (0-65535) 3 +** 14 4 byte (0-4294967295) 5 +** 15 8 byte (0-1.8e19) 9 +** +** The payload size need not be expressed in its minimal form. For example, +** if the payload size is 10, the size can be expressed in any of 5 different +** ways: (1) (X>>4)==10, (2) (X>>4)==12 following by on 0x0a byte, +** (3) (X>>4)==13 followed by 0x00 and 0x0a, (4) (X>>4)==14 followed by +** 0x00 0x00 0x00 0x0a, or (5) (X>>4)==15 followed by 7 bytes of 0x00 and +** a single byte of 0x0a. The shorter forms are preferred, of course, but +** sometimes when generating JSONB, the payload size is not known in advance +** and it is convenient to reserve sufficient header space to cover the +** largest possible payload size and then come back later and patch up +** the size when it becomes known, resulting in a non-minimal encoding. +** +** The value (X>>4)==15 is not actually used in the current implementation +** (as SQLite is currently unable handle BLOBs larger than about 2GB) +** but is included in the design to allow for future enhancements. +** +** The payload follows the header. NULL, TRUE, and FALSE have no payload and +** their payload size must always be zero. The payload for INT, INT5, +** FLOAT, FLOAT5, TEXT, TEXTJ, TEXT5, and TEXTROW is text. Note that the +** "..." or '...' delimiters are omitted from the various text encodings. +** The payload for ARRAY and OBJECT is a list of additional elements that +** are the content for the array or object. The payload for an OBJECT +** must be an even number of elements. The first element of each pair is +** the label and must be of type TEXT, TEXTJ, TEXT5, or TEXTRAW. +** +** A valid JSONB blob consists of a single element, as described above. +** Usually this will be an ARRAY or OBJECT element which has many more +** elements as its content. But the overall blob is just a single element. +** +** Input validation for JSONB blobs simply checks that the element type +** code is between 0 and 12 and that the total size of the element +** (header plus payload) is the same as the size of the BLOB. If those +** checks are true, the BLOB is assumed to be JSONB and processing continues. +** Errors are only raised if some other miscoding is discovered during +** processing. +** +** Additional information can be found in the doc/jsonb.md file of the +** canonical SQLite source tree. */ #ifndef SQLITE_OMIT_JSON /* #include "sqliteInt.h" */ +/* JSONB element types +*/ +#define JSONB_NULL 0 /* "null" */ +#define JSONB_TRUE 1 /* "true" */ +#define JSONB_FALSE 2 /* "false" */ +#define JSONB_INT 3 /* integer acceptable to JSON and SQL */ +#define JSONB_INT5 4 /* integer in 0x000 notation */ +#define JSONB_FLOAT 5 /* float acceptable to JSON and SQL */ +#define JSONB_FLOAT5 6 /* float with JSON5 extensions */ +#define JSONB_TEXT 7 /* Text compatible with both JSON and SQL */ +#define JSONB_TEXTJ 8 /* Text with JSON escapes */ +#define JSONB_TEXT5 9 /* Text with JSON-5 escape */ +#define JSONB_TEXTRAW 10 /* SQL text that needs escaping for JSON */ +#define JSONB_ARRAY 11 /* An array */ +#define JSONB_OBJECT 12 /* An object */ + +/* Human-readable names for the JSONB values. The index for each +** string must correspond to the JSONB_* integer above. +*/ +static const char * const jsonbType[] = { + "null", "true", "false", "integer", "integer", + "real", "real", "text", "text", "text", + "text", "array", "object", "", "", "", "" +}; + /* ** Growing our own isspace() routine this way is twice as fast as ** the library isspace() function, resulting in a 7% overall performance -** increase for the parser. (Ubuntu14.10 gcc 4.8.4 x64 with -Os). +** increase for the text-JSON parser. (Ubuntu14.10 gcc 4.8.4 x64 with -Os). */ static const char jsonIsSpace[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, @@ -202611,11 +203338,19 @@ static const char jsonIsSpace[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; -#define fast_isspace(x) (jsonIsSpace[(unsigned char)x]) +#define jsonIsspace(x) (jsonIsSpace[(unsigned char)x]) /* -** Characters that are special to JSON. Control charaters, -** '"' and '\\'. +** The set of all space characters recognized by jsonIsspace(). +** Useful as the second argument to strspn(). +*/ +static const char jsonSpaces[] = "\011\012\015\040"; + +/* +** Characters that are special to JSON. Control characters, +** '"' and '\\' and '\''. Actually, '\'' is not special to +** canonical JSON, but it is special in JSON-5, so we include +** it in the set of special characters. */ static const char jsonIsOk[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -202637,22 +203372,49 @@ static const char jsonIsOk[256] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; - -#if !defined(SQLITE_DEBUG) && !defined(SQLITE_COVERAGE_TEST) -# define VVA(X) -#else -# define VVA(X) X -#endif - /* Objects */ +typedef struct JsonCache JsonCache; typedef struct JsonString JsonString; -typedef struct JsonNode JsonNode; typedef struct JsonParse JsonParse; -typedef struct JsonCleanup JsonCleanup; + +/* +** Magic number used for the JSON parse cache in sqlite3_get_auxdata() +*/ +#define JSON_CACHE_ID (-429938) /* Cache entry */ +#define JSON_CACHE_SIZE 4 /* Max number of cache entries */ + +/* +** jsonUnescapeOneChar() returns this invalid code point if it encounters +** a syntax error. +*/ +#define JSON_INVALID_CHAR 0x99999 + +/* A cache mapping JSON text into JSONB blobs. +** +** Each cache entry is a JsonParse object with the following restrictions: +** +** * The bReadOnly flag must be set +** +** * The aBlob[] array must be owned by the JsonParse object. In other +** words, nBlobAlloc must be non-zero. +** +** * eEdit and delta must be zero. +** +** * zJson must be an RCStr. In other words bJsonIsRCStr must be true. +*/ +struct JsonCache { + sqlite3 *db; /* Database connection */ + int nUsed; /* Number of active entries in the cache */ + JsonParse *a[JSON_CACHE_SIZE]; /* One line for each cache entry */ +}; /* An instance of this object represents a JSON string ** under construction. Really, this is a generic string accumulator ** that can be and is used to create strings other than JSON. +** +** If the generated string is longer than will fit into the zSpace[] buffer, +** then it will be an RCStr string. This aids with caching of large +** JSON strings. */ struct JsonString { sqlite3_context *pCtx; /* Function context - put error messages here */ @@ -202660,121 +203422,75 @@ struct JsonString { u64 nAlloc; /* Bytes of storage available in zBuf[] */ u64 nUsed; /* Bytes of zBuf[] currently used */ u8 bStatic; /* True if zBuf is static space */ - u8 bErr; /* True if an error has been encountered */ + u8 eErr; /* True if an error has been encountered */ char zSpace[100]; /* Initial static space */ }; -/* A deferred cleanup task. A list of JsonCleanup objects might be -** run when the JsonParse object is destroyed. -*/ -struct JsonCleanup { - JsonCleanup *pJCNext; /* Next in a list */ - void (*xOp)(void*); /* Routine to run */ - void *pArg; /* Argument to xOp() */ -}; +/* Allowed values for JsonString.eErr */ +#define JSTRING_OOM 0x01 /* Out of memory */ +#define JSTRING_MALFORMED 0x02 /* Malformed JSONB */ +#define JSTRING_ERR 0x04 /* Error already sent to sqlite3_result */ -/* JSON type values +/* The "subtype" set for text JSON values passed through using +** sqlite3_result_subtype() and sqlite3_value_subtype(). */ -#define JSON_SUBST 0 /* Special edit node. Uses u.iPrev */ -#define JSON_NULL 1 -#define JSON_TRUE 2 -#define JSON_FALSE 3 -#define JSON_INT 4 -#define JSON_REAL 5 -#define JSON_STRING 6 -#define JSON_ARRAY 7 -#define JSON_OBJECT 8 - -/* The "subtype" set for JSON values */ #define JSON_SUBTYPE 74 /* Ascii for "J" */ /* -** Names of the various JSON types: +** Bit values for the flags passed into various SQL function implementations +** via the sqlite3_user_data() value. */ -static const char * const jsonType[] = { - "subst", - "null", "true", "false", "integer", "real", "text", "array", "object" -}; - -/* Bit values for the JsonNode.jnFlag field -*/ -#define JNODE_RAW 0x01 /* Content is raw, not JSON encoded */ -#define JNODE_ESCAPE 0x02 /* Content is text with \ escapes */ -#define JNODE_REMOVE 0x04 /* Do not output */ -#define JNODE_REPLACE 0x08 /* Target of a JSON_SUBST node */ -#define JNODE_APPEND 0x10 /* More ARRAY/OBJECT entries at u.iAppend */ -#define JNODE_LABEL 0x20 /* Is a label of an object */ -#define JNODE_JSON5 0x40 /* Node contains JSON5 enhancements */ +#define JSON_JSON 0x01 /* Result is always JSON */ +#define JSON_SQL 0x02 /* Result is always SQL */ +#define JSON_ABPATH 0x03 /* Allow abbreviated JSON path specs */ +#define JSON_ISSET 0x04 /* json_set(), not json_insert() */ +#define JSON_BLOB 0x08 /* Use the BLOB output format */ -/* A single node of parsed JSON. An array of these nodes describes -** a parse of JSON + edits. +/* A parsed JSON value. Lifecycle: ** -** Use the json_parse() SQL function (available when compiled with -** -DSQLITE_DEBUG) to see a dump of complete JsonParse objects, including -** a complete listing and decoding of the array of JsonNodes. -*/ -struct JsonNode { - u8 eType; /* One of the JSON_ type values */ - u8 jnFlags; /* JNODE flags */ - u8 eU; /* Which union element to use */ - u32 n; /* Bytes of content for INT, REAL or STRING - ** Number of sub-nodes for ARRAY and OBJECT - ** Node that SUBST applies to */ - union { - const char *zJContent; /* 1: Content for INT, REAL, and STRING */ - u32 iAppend; /* 2: More terms for ARRAY and OBJECT */ - u32 iKey; /* 3: Key for ARRAY objects in json_tree() */ - u32 iPrev; /* 4: Previous SUBST node, or 0 */ - } u; -}; - - -/* A parsed and possibly edited JSON string. Lifecycle: +** 1. JSON comes in and is parsed into a JSONB value in aBlob. The +** original text is stored in zJson. This step is skipped if the +** input is JSONB instead of text JSON. ** -** 1. JSON comes in and is parsed into an array aNode[]. The original -** JSON text is stored in zJson. +** 2. The aBlob[] array is searched using the JSON path notation, if needed. ** -** 2. Zero or more changes are made (via json_remove() or json_replace() -** or similar) to the aNode[] array. +** 3. Zero or more changes are made to aBlob[] (via json_remove() or +** json_replace() or json_patch() or similar). ** -** 3. A new, edited and mimified JSON string is generated from aNode -** and stored in zAlt. The JsonParse object always owns zAlt. -** -** Step 1 always happens. Step 2 and 3 may or may not happen, depending -** on the operation. -** -** aNode[].u.zJContent entries typically point into zJson. Hence zJson -** must remain valid for the lifespan of the parse. For edits, -** aNode[].u.zJContent might point to malloced space other than zJson. -** Entries in pClup are responsible for freeing that extra malloced space. -** -** When walking the parse tree in aNode[], edits are ignored if useMod is -** false. +** 4. New JSON text is generated from the aBlob[] for output. This step +** is skipped if the function is one of the jsonb_* functions that +** returns JSONB instead of text JSON. */ struct JsonParse { - u32 nNode; /* Number of slots of aNode[] used */ - u32 nAlloc; /* Number of slots of aNode[] allocated */ - JsonNode *aNode; /* Array of nodes containing the parse */ - char *zJson; /* Original JSON string (before edits) */ - char *zAlt; /* Revised and/or mimified JSON */ - u32 *aUp; /* Index of parent of each node */ - JsonCleanup *pClup;/* Cleanup operations prior to freeing this object */ + u8 *aBlob; /* JSONB representation of JSON value */ + u32 nBlob; /* Bytes of aBlob[] actually used */ + u32 nBlobAlloc; /* Bytes allocated to aBlob[]. 0 if aBlob is external */ + char *zJson; /* Json text used for parsing */ + sqlite3 *db; /* The database connection to which this object belongs */ + int nJson; /* Length of the zJson string in bytes */ + u32 nJPRef; /* Number of references to this object */ + u32 iErr; /* Error location in zJson[] */ u16 iDepth; /* Nesting depth */ u8 nErr; /* Number of errors seen */ u8 oom; /* Set to true if out of memory */ u8 bJsonIsRCStr; /* True if zJson is an RCStr */ u8 hasNonstd; /* True if input uses non-standard features like JSON5 */ - u8 useMod; /* Actually use the edits contain inside aNode */ - u8 hasMod; /* aNode contains edits from the original zJson */ - u32 nJPRef; /* Number of references to this object */ - int nJson; /* Length of the zJson string in bytes */ - int nAlt; /* Length of alternative JSON string zAlt, in bytes */ - u32 iErr; /* Error location in zJson[] */ - u32 iSubst; /* Last JSON_SUBST entry in aNode[] */ - u32 iHold; /* Age of this entry in the cache for LRU replacement */ + u8 bReadOnly; /* Do not modify. */ + /* Search and edit information. See jsonLookupStep() */ + u8 eEdit; /* Edit operation to apply */ + int delta; /* Size change due to the edit */ + u32 nIns; /* Number of bytes to insert */ + u32 iLabel; /* Location of label if search landed on an object value */ + u8 *aIns; /* Content to be inserted */ }; +/* Allowed values for JsonParse.eEdit */ +#define JEDIT_DEL 1 /* Delete if exists */ +#define JEDIT_REPL 2 /* Overwrite if exists */ +#define JEDIT_INS 3 /* Insert if not exists */ +#define JEDIT_SET 4 /* Insert or overwrite */ + /* ** Maximum nesting depth of JSON for this implementation. ** @@ -202782,15 +203498,151 @@ struct JsonParse { ** descent parser. A depth of 1000 is far deeper than any sane JSON ** should go. Historical note: This limit was 2000 prior to version 3.42.0 */ -#define JSON_MAX_DEPTH 1000 +#ifndef SQLITE_JSON_MAX_DEPTH +# define JSON_MAX_DEPTH 1000 +#else +# define JSON_MAX_DEPTH SQLITE_JSON_MAX_DEPTH +#endif + +/* +** Allowed values for the flgs argument to jsonParseFuncArg(); +*/ +#define JSON_EDITABLE 0x01 /* Generate a writable JsonParse object */ +#define JSON_KEEPERROR 0x02 /* Return non-NULL even if there is an error */ + +/************************************************************************** +** Forward references +**************************************************************************/ +static void jsonReturnStringAsBlob(JsonString*); +static int jsonFuncArgMightBeBinary(sqlite3_value *pJson); +static u32 jsonTranslateBlobToText(const JsonParse*,u32,JsonString*); +static void jsonReturnParse(sqlite3_context*,JsonParse*); +static JsonParse *jsonParseFuncArg(sqlite3_context*,sqlite3_value*,u32); +static void jsonParseFree(JsonParse*); +static u32 jsonbPayloadSize(const JsonParse*, u32, u32*); +static u32 jsonUnescapeOneChar(const char*, u32, u32*); + +/************************************************************************** +** Utility routines for dealing with JsonCache objects +**************************************************************************/ + +/* +** Free a JsonCache object. +*/ +static void jsonCacheDelete(JsonCache *p){ + int i; + for(i=0; inUsed; i++){ + jsonParseFree(p->a[i]); + } + sqlite3DbFree(p->db, p); +} +static void jsonCacheDeleteGeneric(void *p){ + jsonCacheDelete((JsonCache*)p); +} + +/* +** Insert a new entry into the cache. If the cache is full, expel +** the least recently used entry. Return SQLITE_OK on success or a +** result code otherwise. +** +** Cache entries are stored in age order, oldest first. +*/ +static int jsonCacheInsert( + sqlite3_context *ctx, /* The SQL statement context holding the cache */ + JsonParse *pParse /* The parse object to be added to the cache */ +){ + JsonCache *p; + + assert( pParse->zJson!=0 ); + assert( pParse->bJsonIsRCStr ); + assert( pParse->delta==0 ); + p = sqlite3_get_auxdata(ctx, JSON_CACHE_ID); + if( p==0 ){ + sqlite3 *db = sqlite3_context_db_handle(ctx); + p = sqlite3DbMallocZero(db, sizeof(*p)); + if( p==0 ) return SQLITE_NOMEM; + p->db = db; + sqlite3_set_auxdata(ctx, JSON_CACHE_ID, p, jsonCacheDeleteGeneric); + p = sqlite3_get_auxdata(ctx, JSON_CACHE_ID); + if( p==0 ) return SQLITE_NOMEM; + } + if( p->nUsed >= JSON_CACHE_SIZE ){ + jsonParseFree(p->a[0]); + memmove(p->a, &p->a[1], (JSON_CACHE_SIZE-1)*sizeof(p->a[0])); + p->nUsed = JSON_CACHE_SIZE-1; + } + assert( pParse->nBlobAlloc>0 ); + pParse->eEdit = 0; + pParse->nJPRef++; + pParse->bReadOnly = 1; + p->a[p->nUsed] = pParse; + p->nUsed++; + return SQLITE_OK; +} + +/* +** Search for a cached translation the json text supplied by pArg. Return +** the JsonParse object if found. Return NULL if not found. +** +** When a match if found, the matching entry is moved to become the +** most-recently used entry if it isn't so already. +** +** The JsonParse object returned still belongs to the Cache and might +** be deleted at any moment. If the caller whants the JsonParse to +** linger, it needs to increment the nPJRef reference counter. +*/ +static JsonParse *jsonCacheSearch( + sqlite3_context *ctx, /* The SQL statement context holding the cache */ + sqlite3_value *pArg /* Function argument containing SQL text */ +){ + JsonCache *p; + int i; + const char *zJson; + int nJson; + + if( sqlite3_value_type(pArg)!=SQLITE_TEXT ){ + return 0; + } + zJson = (const char*)sqlite3_value_text(pArg); + if( zJson==0 ) return 0; + nJson = sqlite3_value_bytes(pArg); + + p = sqlite3_get_auxdata(ctx, JSON_CACHE_ID); + if( p==0 ){ + return 0; + } + for(i=0; inUsed; i++){ + if( p->a[i]->zJson==zJson ) break; + } + if( i>=p->nUsed ){ + for(i=0; inUsed; i++){ + if( p->a[i]->nJson!=nJson ) continue; + if( memcmp(p->a[i]->zJson, zJson, nJson)==0 ) break; + } + } + if( inUsed ){ + if( inUsed-1 ){ + /* Make the matching entry the most recently used entry */ + JsonParse *tmp = p->a[i]; + memmove(&p->a[i], &p->a[i+1], (p->nUsed-i-1)*sizeof(tmp)); + p->a[p->nUsed-1] = tmp; + i = p->nUsed - 1; + } + assert( p->a[i]->delta==0 ); + return p->a[i]; + }else{ + return 0; + } +} /************************************************************************** ** Utility routines for dealing with JsonString objects **************************************************************************/ -/* Set the JsonString object to an empty string +/* Turn uninitialized bulk memory into a valid JsonString object +** holding a zero-length string. */ -static void jsonZero(JsonString *p){ +static void jsonStringZero(JsonString *p){ p->zBuf = p->zSpace; p->nAlloc = sizeof(p->zSpace); p->nUsed = 0; @@ -202799,39 +203651,39 @@ static void jsonZero(JsonString *p){ /* Initialize the JsonString object */ -static void jsonInit(JsonString *p, sqlite3_context *pCtx){ +static void jsonStringInit(JsonString *p, sqlite3_context *pCtx){ p->pCtx = pCtx; - p->bErr = 0; - jsonZero(p); + p->eErr = 0; + jsonStringZero(p); } /* Free all allocated memory and reset the JsonString object back to its ** initial state. */ -static void jsonReset(JsonString *p){ +static void jsonStringReset(JsonString *p){ if( !p->bStatic ) sqlite3RCStrUnref(p->zBuf); - jsonZero(p); + jsonStringZero(p); } /* Report an out-of-memory (OOM) condition */ -static void jsonOom(JsonString *p){ - p->bErr = 1; - sqlite3_result_error_nomem(p->pCtx); - jsonReset(p); +static void jsonStringOom(JsonString *p){ + p->eErr |= JSTRING_OOM; + if( p->pCtx ) sqlite3_result_error_nomem(p->pCtx); + jsonStringReset(p); } /* Enlarge pJson->zBuf so that it can hold at least N more bytes. ** Return zero on success. Return non-zero on an OOM error */ -static int jsonGrow(JsonString *p, u32 N){ +static int jsonStringGrow(JsonString *p, u32 N){ u64 nTotal = NnAlloc ? p->nAlloc*2 : p->nAlloc+N+10; char *zNew; if( p->bStatic ){ - if( p->bErr ) return 1; + if( p->eErr ) return 1; zNew = sqlite3RCStrNew(nTotal); if( zNew==0 ){ - jsonOom(p); + jsonStringOom(p); return SQLITE_NOMEM; } memcpy(zNew, p->zBuf, (size_t)p->nUsed); @@ -202840,8 +203692,8 @@ static int jsonGrow(JsonString *p, u32 N){ }else{ p->zBuf = sqlite3RCStrResize(p->zBuf, nTotal); if( p->zBuf==0 ){ - p->bErr = 1; - jsonZero(p); + p->eErr |= JSTRING_OOM; + jsonStringZero(p); return SQLITE_NOMEM; } } @@ -202851,20 +203703,20 @@ static int jsonGrow(JsonString *p, u32 N){ /* Append N bytes from zIn onto the end of the JsonString string. */ -static SQLITE_NOINLINE void jsonAppendExpand( +static SQLITE_NOINLINE void jsonStringExpandAndAppend( JsonString *p, const char *zIn, u32 N ){ assert( N>0 ); - if( jsonGrow(p,N) ) return; + if( jsonStringGrow(p,N) ) return; memcpy(p->zBuf+p->nUsed, zIn, N); p->nUsed += N; } static void jsonAppendRaw(JsonString *p, const char *zIn, u32 N){ if( N==0 ) return; if( N+p->nUsed >= p->nAlloc ){ - jsonAppendExpand(p,zIn,N); + jsonStringExpandAndAppend(p,zIn,N); }else{ memcpy(p->zBuf+p->nUsed, zIn, N); p->nUsed += N; @@ -202873,7 +203725,7 @@ static void jsonAppendRaw(JsonString *p, const char *zIn, u32 N){ static void jsonAppendRawNZ(JsonString *p, const char *zIn, u32 N){ assert( N>0 ); if( N+p->nUsed >= p->nAlloc ){ - jsonAppendExpand(p,zIn,N); + jsonStringExpandAndAppend(p,zIn,N); }else{ memcpy(p->zBuf+p->nUsed, zIn, N); p->nUsed += N; @@ -202885,7 +203737,7 @@ static void jsonAppendRawNZ(JsonString *p, const char *zIn, u32 N){ */ static void jsonPrintf(int N, JsonString *p, const char *zFormat, ...){ va_list ap; - if( (p->nUsed + N >= p->nAlloc) && jsonGrow(p, N) ) return; + if( (p->nUsed + N >= p->nAlloc) && jsonStringGrow(p, N) ) return; va_start(ap, zFormat); sqlite3_vsnprintf(N, p->zBuf+p->nUsed, zFormat, ap); va_end(ap); @@ -202895,7 +203747,7 @@ static void jsonPrintf(int N, JsonString *p, const char *zFormat, ...){ /* Append a single character */ static SQLITE_NOINLINE void jsonAppendCharExpand(JsonString *p, char c){ - if( jsonGrow(p,1) ) return; + if( jsonStringGrow(p,1) ) return; p->zBuf[p->nUsed++] = c; } static void jsonAppendChar(JsonString *p, char c){ @@ -202906,24 +203758,17 @@ static void jsonAppendChar(JsonString *p, char c){ } } -/* Try to force the string to be a zero-terminated RCStr string. +/* Make sure there is a zero terminator on p->zBuf[] ** ** Return true on success. Return false if an OOM prevents this ** from happening. */ -static int jsonForceRCStr(JsonString *p){ +static int jsonStringTerminate(JsonString *p){ jsonAppendChar(p, 0); - if( p->bErr ) return 0; p->nUsed--; - if( p->bStatic==0 ) return 1; - p->nAlloc = 0; - p->nUsed++; - jsonGrow(p, p->nUsed); - p->nUsed--; - return p->bStatic==0; + return p->eErr==0; } - /* Append a comma separator to the output buffer, if the previous ** character is not '[' or '{'. */ @@ -202936,21 +203781,66 @@ static void jsonAppendSeparator(JsonString *p){ } /* Append the N-byte string in zIn to the end of the JsonString string -** under construction. Enclose the string in "..." and escape -** any double-quotes or backslash characters contained within the +** under construction. Enclose the string in double-quotes ("...") and +** escape any double-quotes or backslash characters contained within the ** string. +** +** This routine is a high-runner. There is a measurable performance +** increase associated with unwinding the jsonIsOk[] loop. */ static void jsonAppendString(JsonString *p, const char *zIn, u32 N){ - u32 i; - if( zIn==0 || ((N+p->nUsed+2 >= p->nAlloc) && jsonGrow(p,N+2)!=0) ) return; + u32 k; + u8 c; + const u8 *z = (const u8*)zIn; + if( z==0 ) return; + if( (N+p->nUsed+2 >= p->nAlloc) && jsonStringGrow(p,N+2)!=0 ) return; p->zBuf[p->nUsed++] = '"'; - for(i=0; izBuf[p->nUsed++] = c; - }else if( c=='"' || c=='\\' ){ + while( 1 /*exit-by-break*/ ){ + k = 0; + /* The following while() is the 4-way unwound equivalent of + ** + ** while( k=N ){ + while( k=N ){ + if( k>0 ){ + memcpy(&p->zBuf[p->nUsed], z, k); + p->nUsed += k; + } + break; + } + if( k>0 ){ + memcpy(&p->zBuf[p->nUsed], z, k); + p->nUsed += k; + z += k; + N -= k; + } + c = z[0]; + if( c=='"' || c=='\\' ){ json_simple_escape: - if( (p->nUsed+N+3-i > p->nAlloc) && jsonGrow(p,N+3-i)!=0 ) return; + if( (p->nUsed+N+3 > p->nAlloc) && jsonStringGrow(p,N+3)!=0 ) return; p->zBuf[p->nUsed++] = '\\'; p->zBuf[p->nUsed++] = c; }else if( c=='\'' ){ @@ -202971,7 +203861,7 @@ static void jsonAppendString(JsonString *p, const char *zIn, u32 N){ c = aSpecial[c]; goto json_simple_escape; } - if( (p->nUsed+N+7+i > p->nAlloc) && jsonGrow(p,N+7-i)!=0 ) return; + if( (p->nUsed+N+7 > p->nAlloc) && jsonStringGrow(p,N+7)!=0 ) return; p->zBuf[p->nUsed++] = '\\'; p->zBuf[p->nUsed++] = 'u'; p->zBuf[p->nUsed++] = '0'; @@ -202979,140 +203869,18 @@ static void jsonAppendString(JsonString *p, const char *zIn, u32 N){ p->zBuf[p->nUsed++] = "0123456789abcdef"[c>>4]; p->zBuf[p->nUsed++] = "0123456789abcdef"[c&0xf]; } + z++; + N--; } p->zBuf[p->nUsed++] = '"'; assert( p->nUsednAlloc ); } /* -** The zIn[0..N] string is a JSON5 string literal. Append to p a translation -** of the string literal that standard JSON and that omits all JSON5 -** features. +** Append an sqlite3_value (such as a function parameter) to the JSON +** string under construction in p. */ -static void jsonAppendNormalizedString(JsonString *p, const char *zIn, u32 N){ - u32 i; - jsonAppendChar(p, '"'); - zIn++; - N -= 2; - while( N>0 ){ - for(i=0; i0 ){ - jsonAppendRawNZ(p, zIn, i); - zIn += i; - N -= i; - if( N==0 ) break; - } - assert( zIn[0]=='\\' ); - switch( (u8)zIn[1] ){ - case '\'': - jsonAppendChar(p, '\''); - break; - case 'v': - jsonAppendRawNZ(p, "\\u0009", 6); - break; - case 'x': - jsonAppendRawNZ(p, "\\u00", 4); - jsonAppendRawNZ(p, &zIn[2], 2); - zIn += 2; - N -= 2; - break; - case '0': - jsonAppendRawNZ(p, "\\u0000", 6); - break; - case '\r': - if( zIn[2]=='\n' ){ - zIn++; - N--; - } - break; - case '\n': - break; - case 0xe2: - assert( N>=4 ); - assert( 0x80==(u8)zIn[2] ); - assert( 0xa8==(u8)zIn[3] || 0xa9==(u8)zIn[3] ); - zIn += 2; - N -= 2; - break; - default: - jsonAppendRawNZ(p, zIn, 2); - break; - } - zIn += 2; - N -= 2; - } - jsonAppendChar(p, '"'); -} - -/* -** The zIn[0..N] string is a JSON5 integer literal. Append to p a translation -** of the string literal that standard JSON and that omits all JSON5 -** features. -*/ -static void jsonAppendNormalizedInt(JsonString *p, const char *zIn, u32 N){ - if( zIn[0]=='+' ){ - zIn++; - N--; - }else if( zIn[0]=='-' ){ - jsonAppendChar(p, '-'); - zIn++; - N--; - } - if( zIn[0]=='0' && (zIn[1]=='x' || zIn[1]=='X') ){ - sqlite3_int64 i = 0; - int rc = sqlite3DecOrHexToI64(zIn, &i); - if( rc<=1 ){ - jsonPrintf(100,p,"%lld",i); - }else{ - assert( rc==2 ); - jsonAppendRawNZ(p, "9.0e999", 7); - } - return; - } - assert( N>0 ); - jsonAppendRawNZ(p, zIn, N); -} - -/* -** The zIn[0..N] string is a JSON5 real literal. Append to p a translation -** of the string literal that standard JSON and that omits all JSON5 -** features. -*/ -static void jsonAppendNormalizedReal(JsonString *p, const char *zIn, u32 N){ - u32 i; - if( zIn[0]=='+' ){ - zIn++; - N--; - }else if( zIn[0]=='-' ){ - jsonAppendChar(p, '-'); - zIn++; - N--; - } - if( zIn[0]=='.' ){ - jsonAppendChar(p, '0'); - } - for(i=0; i0 ){ - jsonAppendRawNZ(p, zIn, N); - } -} - - - -/* -** Append a function parameter value to the JSON string under -** construction. -*/ -static void jsonAppendValue( +static void jsonAppendSqlValue( JsonString *p, /* Append to this JSON string */ sqlite3_value *pValue /* Value to append */ ){ @@ -203142,290 +203910,127 @@ static void jsonAppendValue( break; } default: { - if( p->bErr==0 ){ + if( jsonFuncArgMightBeBinary(pValue) ){ + JsonParse px; + memset(&px, 0, sizeof(px)); + px.aBlob = (u8*)sqlite3_value_blob(pValue); + px.nBlob = sqlite3_value_bytes(pValue); + jsonTranslateBlobToText(&px, 0, p); + }else if( p->eErr==0 ){ sqlite3_result_error(p->pCtx, "JSON cannot hold BLOB values", -1); - p->bErr = 2; - jsonReset(p); + p->eErr = JSTRING_ERR; + jsonStringReset(p); } break; } } } - -/* Make the JSON in p the result of the SQL function. +/* Make the text in p (which is probably a generated JSON text string) +** the result of the SQL function. ** -** The JSON string is reset. +** The JsonString is reset. +** +** If pParse and ctx are both non-NULL, then the SQL string in p is +** loaded into the zJson field of the pParse object as a RCStr and the +** pParse is added to the cache. */ -static void jsonResult(JsonString *p){ - if( p->bErr==0 ){ - if( p->bStatic ){ +static void jsonReturnString( + JsonString *p, /* String to return */ + JsonParse *pParse, /* JSONB source or NULL */ + sqlite3_context *ctx /* Where to cache */ +){ + assert( (pParse!=0)==(ctx!=0) ); + assert( ctx==0 || ctx==p->pCtx ); + if( p->eErr==0 ){ + int flags = SQLITE_PTR_TO_INT(sqlite3_user_data(p->pCtx)); + if( flags & JSON_BLOB ){ + jsonReturnStringAsBlob(p); + }else if( p->bStatic ){ sqlite3_result_text64(p->pCtx, p->zBuf, p->nUsed, SQLITE_TRANSIENT, SQLITE_UTF8); - }else if( jsonForceRCStr(p) ){ - sqlite3RCStrRef(p->zBuf); - sqlite3_result_text64(p->pCtx, p->zBuf, p->nUsed, + }else if( jsonStringTerminate(p) ){ + if( pParse && pParse->bJsonIsRCStr==0 && pParse->nBlobAlloc>0 ){ + int rc; + pParse->zJson = sqlite3RCStrRef(p->zBuf); + pParse->nJson = p->nUsed; + pParse->bJsonIsRCStr = 1; + rc = jsonCacheInsert(ctx, pParse); + if( rc==SQLITE_NOMEM ){ + sqlite3_result_error_nomem(ctx); + jsonStringReset(p); + return; + } + } + sqlite3_result_text64(p->pCtx, sqlite3RCStrRef(p->zBuf), p->nUsed, sqlite3RCStrUnref, SQLITE_UTF8); + }else{ + sqlite3_result_error_nomem(p->pCtx); } - } - if( p->bErr==1 ){ + }else if( p->eErr & JSTRING_OOM ){ sqlite3_result_error_nomem(p->pCtx); + }else if( p->eErr & JSTRING_MALFORMED ){ + sqlite3_result_error(p->pCtx, "malformed JSON", -1); } - jsonReset(p); + jsonStringReset(p); } /************************************************************************** -** Utility routines for dealing with JsonNode and JsonParse objects +** Utility routines for dealing with JsonParse objects **************************************************************************/ -/* -** Return the number of consecutive JsonNode slots need to represent -** the parsed JSON at pNode. The minimum answer is 1. For ARRAY and -** OBJECT types, the number might be larger. -** -** Appended elements are not counted. The value returned is the number -** by which the JsonNode counter should increment in order to go to the -** next peer value. -*/ -static u32 jsonNodeSize(JsonNode *pNode){ - return pNode->eType>=JSON_ARRAY ? pNode->n+1 : 1; -} - /* ** Reclaim all memory allocated by a JsonParse object. But do not ** delete the JsonParse object itself. */ static void jsonParseReset(JsonParse *pParse){ - while( pParse->pClup ){ - JsonCleanup *pTask = pParse->pClup; - pParse->pClup = pTask->pJCNext; - pTask->xOp(pTask->pArg); - sqlite3_free(pTask); - } assert( pParse->nJPRef<=1 ); - if( pParse->aNode ){ - sqlite3_free(pParse->aNode); - pParse->aNode = 0; - } - pParse->nNode = 0; - pParse->nAlloc = 0; - if( pParse->aUp ){ - sqlite3_free(pParse->aUp); - pParse->aUp = 0; - } if( pParse->bJsonIsRCStr ){ sqlite3RCStrUnref(pParse->zJson); pParse->zJson = 0; + pParse->nJson = 0; pParse->bJsonIsRCStr = 0; } - if( pParse->zAlt ){ - sqlite3RCStrUnref(pParse->zAlt); - pParse->zAlt = 0; + if( pParse->nBlobAlloc ){ + sqlite3DbFree(pParse->db, pParse->aBlob); + pParse->aBlob = 0; + pParse->nBlob = 0; + pParse->nBlobAlloc = 0; } } /* -** Free a JsonParse object that was obtained from sqlite3_malloc(). -** -** Note that destroying JsonParse might call sqlite3RCStrUnref() to -** destroy the zJson value. The RCStr object might recursively invoke -** JsonParse to destroy this pParse object again. Take care to ensure -** that this recursive destructor sequence terminates harmlessly. +** Decrement the reference count on the JsonParse object. When the +** count reaches zero, free the object. */ static void jsonParseFree(JsonParse *pParse){ - if( pParse->nJPRef>1 ){ - pParse->nJPRef--; - }else{ - jsonParseReset(pParse); - sqlite3_free(pParse); - } -} - -/* -** Add a cleanup task to the JsonParse object. -** -** If an OOM occurs, the cleanup operation happens immediately -** and this function returns SQLITE_NOMEM. -*/ -static int jsonParseAddCleanup( - JsonParse *pParse, /* Add the cleanup task to this parser */ - void(*xOp)(void*), /* The cleanup task */ - void *pArg /* Argument to the cleanup */ -){ - JsonCleanup *pTask = sqlite3_malloc64( sizeof(*pTask) ); - if( pTask==0 ){ - pParse->oom = 1; - xOp(pArg); - return SQLITE_ERROR; - } - pTask->pJCNext = pParse->pClup; - pParse->pClup = pTask; - pTask->xOp = xOp; - pTask->pArg = pArg; - return SQLITE_OK; -} - -/* -** Convert the JsonNode pNode into a pure JSON string and -** append to pOut. Subsubstructure is also included. Return -** the number of JsonNode objects that are encoded. -*/ -static void jsonRenderNode( - JsonParse *pParse, /* the complete parse of the JSON */ - JsonNode *pNode, /* The node to render */ - JsonString *pOut /* Write JSON here */ -){ - assert( pNode!=0 ); - while( (pNode->jnFlags & JNODE_REPLACE)!=0 && pParse->useMod ){ - u32 idx = (u32)(pNode - pParse->aNode); - u32 i = pParse->iSubst; - while( 1 /*exit-by-break*/ ){ - assert( inNode ); - assert( pParse->aNode[i].eType==JSON_SUBST ); - assert( pParse->aNode[i].eU==4 ); - assert( pParse->aNode[i].u.iPrevaNode[i].n==idx ){ - pNode = &pParse->aNode[i+1]; - break; - } - i = pParse->aNode[i].u.iPrev; - } - } - switch( pNode->eType ){ - default: { - assert( pNode->eType==JSON_NULL ); - jsonAppendRawNZ(pOut, "null", 4); - break; - } - case JSON_TRUE: { - jsonAppendRawNZ(pOut, "true", 4); - break; - } - case JSON_FALSE: { - jsonAppendRawNZ(pOut, "false", 5); - break; - } - case JSON_STRING: { - assert( pNode->eU==1 ); - if( pNode->jnFlags & JNODE_RAW ){ - if( pNode->jnFlags & JNODE_LABEL ){ - jsonAppendChar(pOut, '"'); - jsonAppendRaw(pOut, pNode->u.zJContent, pNode->n); - jsonAppendChar(pOut, '"'); - }else{ - jsonAppendString(pOut, pNode->u.zJContent, pNode->n); - } - }else if( pNode->jnFlags & JNODE_JSON5 ){ - jsonAppendNormalizedString(pOut, pNode->u.zJContent, pNode->n); - }else{ - assert( pNode->n>0 ); - jsonAppendRawNZ(pOut, pNode->u.zJContent, pNode->n); - } - break; - } - case JSON_REAL: { - assert( pNode->eU==1 ); - if( pNode->jnFlags & JNODE_JSON5 ){ - jsonAppendNormalizedReal(pOut, pNode->u.zJContent, pNode->n); - }else{ - assert( pNode->n>0 ); - jsonAppendRawNZ(pOut, pNode->u.zJContent, pNode->n); - } - break; - } - case JSON_INT: { - assert( pNode->eU==1 ); - if( pNode->jnFlags & JNODE_JSON5 ){ - jsonAppendNormalizedInt(pOut, pNode->u.zJContent, pNode->n); - }else{ - assert( pNode->n>0 ); - jsonAppendRawNZ(pOut, pNode->u.zJContent, pNode->n); - } - break; - } - case JSON_ARRAY: { - u32 j = 1; - jsonAppendChar(pOut, '['); - for(;;){ - while( j<=pNode->n ){ - if( (pNode[j].jnFlags & JNODE_REMOVE)==0 || pParse->useMod==0 ){ - jsonAppendSeparator(pOut); - jsonRenderNode(pParse, &pNode[j], pOut); - } - j += jsonNodeSize(&pNode[j]); - } - if( (pNode->jnFlags & JNODE_APPEND)==0 ) break; - if( pParse->useMod==0 ) break; - assert( pNode->eU==2 ); - pNode = &pParse->aNode[pNode->u.iAppend]; - j = 1; - } - jsonAppendChar(pOut, ']'); - break; - } - case JSON_OBJECT: { - u32 j = 1; - jsonAppendChar(pOut, '{'); - for(;;){ - while( j<=pNode->n ){ - if( (pNode[j+1].jnFlags & JNODE_REMOVE)==0 || pParse->useMod==0 ){ - jsonAppendSeparator(pOut); - jsonRenderNode(pParse, &pNode[j], pOut); - jsonAppendChar(pOut, ':'); - jsonRenderNode(pParse, &pNode[j+1], pOut); - } - j += 1 + jsonNodeSize(&pNode[j+1]); - } - if( (pNode->jnFlags & JNODE_APPEND)==0 ) break; - if( pParse->useMod==0 ) break; - assert( pNode->eU==2 ); - pNode = &pParse->aNode[pNode->u.iAppend]; - j = 1; - } - jsonAppendChar(pOut, '}'); - break; + if( pParse ){ + if( pParse->nJPRef>1 ){ + pParse->nJPRef--; + }else{ + jsonParseReset(pParse); + sqlite3DbFree(pParse->db, pParse); } } } -/* -** Return a JsonNode and all its descendants as a JSON string. -*/ -static void jsonReturnJson( - JsonParse *pParse, /* The complete JSON */ - JsonNode *pNode, /* Node to return */ - sqlite3_context *pCtx, /* Return value for this function */ - int bGenerateAlt /* Also store the rendered text in zAlt */ -){ - JsonString s; - if( pParse->oom ){ - sqlite3_result_error_nomem(pCtx); - return; - } - if( pParse->nErr==0 ){ - jsonInit(&s, pCtx); - jsonRenderNode(pParse, pNode, &s); - if( bGenerateAlt && pParse->zAlt==0 && jsonForceRCStr(&s) ){ - pParse->zAlt = sqlite3RCStrRef(s.zBuf); - pParse->nAlt = s.nUsed; - } - jsonResult(&s); - sqlite3_result_subtype(pCtx, JSON_SUBTYPE); - } -} +/************************************************************************** +** Utility routines for the JSON text parser +**************************************************************************/ /* ** Translate a single byte of Hex into an integer. -** This routine only works if h really is a valid hexadecimal -** character: 0..9a..fA..F +** This routine only gives a correct answer if h really is a valid hexadecimal +** character: 0..9a..fA..F. But unlike sqlite3HexToInt(), it does not +** assert() if the digit is not hex. */ static u8 jsonHexToInt(int h){ - assert( (h>='0' && h<='9') || (h>='a' && h<='f') || (h>='A' && h<='F') ); +#ifdef SQLITE_ASCII + h += 9*(1&(h>>6)); +#endif #ifdef SQLITE_EBCDIC h += 9*(1&~(h>>4)); -#else - h += 9*(1&(h>>6)); #endif return (u8)(h & 0xf); } @@ -203435,10 +204040,6 @@ static u8 jsonHexToInt(int h){ */ static u32 jsonHexToInt4(const char *z){ u32 v; - assert( sqlite3Isxdigit(z[0]) ); - assert( sqlite3Isxdigit(z[1]) ); - assert( sqlite3Isxdigit(z[2]) ); - assert( sqlite3Isxdigit(z[3]) ); v = (jsonHexToInt(z[0])<<12) + (jsonHexToInt(z[1])<<8) + (jsonHexToInt(z[2])<<4) @@ -203446,281 +204047,6 @@ static u32 jsonHexToInt4(const char *z){ return v; } -/* -** Make the JsonNode the return value of the function. -*/ -static void jsonReturn( - JsonParse *pParse, /* Complete JSON parse tree */ - JsonNode *pNode, /* Node to return */ - sqlite3_context *pCtx /* Return value for this function */ -){ - switch( pNode->eType ){ - default: { - assert( pNode->eType==JSON_NULL ); - sqlite3_result_null(pCtx); - break; - } - case JSON_TRUE: { - sqlite3_result_int(pCtx, 1); - break; - } - case JSON_FALSE: { - sqlite3_result_int(pCtx, 0); - break; - } - case JSON_INT: { - sqlite3_int64 i = 0; - int rc; - int bNeg = 0; - const char *z; - - assert( pNode->eU==1 ); - z = pNode->u.zJContent; - if( z[0]=='-' ){ z++; bNeg = 1; } - else if( z[0]=='+' ){ z++; } - rc = sqlite3DecOrHexToI64(z, &i); - if( rc<=1 ){ - sqlite3_result_int64(pCtx, bNeg ? -i : i); - }else if( rc==3 && bNeg ){ - sqlite3_result_int64(pCtx, SMALLEST_INT64); - }else{ - goto to_double; - } - break; - } - case JSON_REAL: { - double r; - const char *z; - assert( pNode->eU==1 ); - to_double: - z = pNode->u.zJContent; - sqlite3AtoF(z, &r, sqlite3Strlen30(z), SQLITE_UTF8); - sqlite3_result_double(pCtx, r); - break; - } - case JSON_STRING: { - if( pNode->jnFlags & JNODE_RAW ){ - assert( pNode->eU==1 ); - sqlite3_result_text(pCtx, pNode->u.zJContent, pNode->n, - SQLITE_TRANSIENT); - }else if( (pNode->jnFlags & JNODE_ESCAPE)==0 ){ - /* JSON formatted without any backslash-escapes */ - assert( pNode->eU==1 ); - sqlite3_result_text(pCtx, pNode->u.zJContent+1, pNode->n-2, - SQLITE_TRANSIENT); - }else{ - /* Translate JSON formatted string into raw text */ - u32 i; - u32 n = pNode->n; - const char *z; - char *zOut; - u32 j; - u32 nOut = n; - assert( pNode->eU==1 ); - z = pNode->u.zJContent; - zOut = sqlite3_malloc( nOut+1 ); - if( zOut==0 ){ - sqlite3_result_error_nomem(pCtx); - break; - } - for(i=1, j=0; i>6)); - zOut[j++] = 0x80 | (v&0x3f); - }else{ - u32 vlo; - if( (v&0xfc00)==0xd800 - && i>18); - zOut[j++] = 0x80 | ((v>>12)&0x3f); - zOut[j++] = 0x80 | ((v>>6)&0x3f); - zOut[j++] = 0x80 | (v&0x3f); - }else{ - zOut[j++] = 0xe0 | (v>>12); - zOut[j++] = 0x80 | ((v>>6)&0x3f); - zOut[j++] = 0x80 | (v&0x3f); - } - } - continue; - }else if( c=='b' ){ - c = '\b'; - }else if( c=='f' ){ - c = '\f'; - }else if( c=='n' ){ - c = '\n'; - }else if( c=='r' ){ - c = '\r'; - }else if( c=='t' ){ - c = '\t'; - }else if( c=='v' ){ - c = '\v'; - }else if( c=='\'' || c=='"' || c=='/' || c=='\\' ){ - /* pass through unchanged */ - }else if( c=='0' ){ - c = 0; - }else if( c=='x' ){ - c = (jsonHexToInt(z[i+1])<<4) | jsonHexToInt(z[i+2]); - i += 2; - }else if( c=='\r' && z[i+1]=='\n' ){ - i++; - continue; - }else if( 0xe2==(u8)c ){ - assert( 0x80==(u8)z[i+1] ); - assert( 0xa8==(u8)z[i+2] || 0xa9==(u8)z[i+2] ); - i += 2; - continue; - }else{ - continue; - } - } /* end if( c=='\\' ) */ - zOut[j++] = c; - } /* end for() */ - zOut[j] = 0; - sqlite3_result_text(pCtx, zOut, j, sqlite3_free); - } - break; - } - case JSON_ARRAY: - case JSON_OBJECT: { - jsonReturnJson(pParse, pNode, pCtx, 0); - break; - } - } -} - -/* Forward reference */ -static int jsonParseAddNode(JsonParse*,u32,u32,const char*); - -/* -** A macro to hint to the compiler that a function should not be -** inlined. -*/ -#if defined(__GNUC__) -# define JSON_NOINLINE __attribute__((noinline)) -#elif defined(_MSC_VER) && _MSC_VER>=1310 -# define JSON_NOINLINE __declspec(noinline) -#else -# define JSON_NOINLINE -#endif - - -/* -** Add a single node to pParse->aNode after first expanding the -** size of the aNode array. Return the index of the new node. -** -** If an OOM error occurs, set pParse->oom and return -1. -*/ -static JSON_NOINLINE int jsonParseAddNodeExpand( - JsonParse *pParse, /* Append the node to this object */ - u32 eType, /* Node type */ - u32 n, /* Content size or sub-node count */ - const char *zContent /* Content */ -){ - u32 nNew; - JsonNode *pNew; - assert( pParse->nNode>=pParse->nAlloc ); - if( pParse->oom ) return -1; - nNew = pParse->nAlloc*2 + 10; - pNew = sqlite3_realloc64(pParse->aNode, sizeof(JsonNode)*nNew); - if( pNew==0 ){ - pParse->oom = 1; - return -1; - } - pParse->nAlloc = sqlite3_msize(pNew)/sizeof(JsonNode); - pParse->aNode = pNew; - assert( pParse->nNodenAlloc ); - return jsonParseAddNode(pParse, eType, n, zContent); -} - -/* -** Create a new JsonNode instance based on the arguments and append that -** instance to the JsonParse. Return the index in pParse->aNode[] of the -** new node, or -1 if a memory allocation fails. -*/ -static int jsonParseAddNode( - JsonParse *pParse, /* Append the node to this object */ - u32 eType, /* Node type */ - u32 n, /* Content size or sub-node count */ - const char *zContent /* Content */ -){ - JsonNode *p; - assert( pParse->aNode!=0 || pParse->nNode>=pParse->nAlloc ); - if( pParse->nNode>=pParse->nAlloc ){ - return jsonParseAddNodeExpand(pParse, eType, n, zContent); - } - assert( pParse->aNode!=0 ); - p = &pParse->aNode[pParse->nNode]; - assert( p!=0 ); - p->eType = (u8)(eType & 0xff); - p->jnFlags = (u8)(eType >> 8); - VVA( p->eU = zContent ? 1 : 0 ); - p->n = n; - p->u.zJContent = zContent; - return pParse->nNode++; -} - -/* -** Add an array of new nodes to the current pParse->aNode array. -** Return the index of the first node added. -** -** If an OOM error occurs, set pParse->oom. -*/ -static void jsonParseAddNodeArray( - JsonParse *pParse, /* Append the node to this object */ - JsonNode *aNode, /* Array of nodes to add */ - u32 nNode /* Number of elements in aNew */ -){ - assert( aNode!=0 ); - assert( nNode>=1 ); - if( pParse->nNode + nNode > pParse->nAlloc ){ - u32 nNew = pParse->nNode + nNode; - JsonNode *aNew = sqlite3_realloc64(pParse->aNode, nNew*sizeof(JsonNode)); - if( aNew==0 ){ - pParse->oom = 1; - return; - } - pParse->nAlloc = sqlite3_msize(aNew)/sizeof(JsonNode); - pParse->aNode = aNew; - } - memcpy(&pParse->aNode[pParse->nNode], aNode, nNode*sizeof(JsonNode)); - pParse->nNode += nNode; -} - -/* -** Add a new JSON_SUBST node. The node immediately following -** this new node will be the substitute content for iNode. -*/ -static int jsonParseAddSubstNode( - JsonParse *pParse, /* Add the JSON_SUBST here */ - u32 iNode /* References this node */ -){ - int idx = jsonParseAddNode(pParse, JSON_SUBST, iNode, 0); - if( pParse->oom ) return -1; - pParse->aNode[iNode].jnFlags |= JNODE_REPLACE; - pParse->aNode[idx].eU = 4; - pParse->aNode[idx].u.iPrev = pParse->iSubst; - pParse->iSubst = idx; - pParse->hasMod = 1; - pParse->useMod = 1; - return idx; -} - /* ** Return true if z[] begins with 2 (or more) hexadecimal digits */ @@ -203874,63 +204200,500 @@ static const struct NanInfName { char *zMatch; char *zRepl; } aNanInfName[] = { - { 'i', 'I', 3, JSON_REAL, 7, "inf", "9.0e999" }, - { 'i', 'I', 8, JSON_REAL, 7, "infinity", "9.0e999" }, - { 'n', 'N', 3, JSON_NULL, 4, "NaN", "null" }, - { 'q', 'Q', 4, JSON_NULL, 4, "QNaN", "null" }, - { 's', 'S', 4, JSON_NULL, 4, "SNaN", "null" }, + { 'i', 'I', 3, JSONB_FLOAT, 7, "inf", "9.0e999" }, + { 'i', 'I', 8, JSONB_FLOAT, 7, "infinity", "9.0e999" }, + { 'n', 'N', 3, JSONB_NULL, 4, "NaN", "null" }, + { 'q', 'Q', 4, JSONB_NULL, 4, "QNaN", "null" }, + { 's', 'S', 4, JSONB_NULL, 4, "SNaN", "null" }, }; + /* -** Parse a single JSON value which begins at pParse->zJson[i]. Return the -** index of the first character past the end of the value parsed. +** Report the wrong number of arguments for json_insert(), json_replace() +** or json_set(). +*/ +static void jsonWrongNumArgs( + sqlite3_context *pCtx, + const char *zFuncName +){ + char *zMsg = sqlite3_mprintf("json_%s() needs an odd number of arguments", + zFuncName); + sqlite3_result_error(pCtx, zMsg, -1); + sqlite3_free(zMsg); +} + +/**************************************************************************** +** Utility routines for dealing with the binary BLOB representation of JSON +****************************************************************************/ + +/* +** Expand pParse->aBlob so that it holds at least N bytes. ** -** Special return values: +** Return the number of errors. +*/ +static int jsonBlobExpand(JsonParse *pParse, u32 N){ + u8 *aNew; + u32 t; + assert( N>pParse->nBlobAlloc ); + if( pParse->nBlobAlloc==0 ){ + t = 100; + }else{ + t = pParse->nBlobAlloc*2; + } + if( tdb, pParse->aBlob, t); + if( aNew==0 ){ pParse->oom = 1; return 1; } + pParse->aBlob = aNew; + pParse->nBlobAlloc = t; + return 0; +} + +/* +** If pParse->aBlob is not previously editable (because it is taken +** from sqlite3_value_blob(), as indicated by the fact that +** pParse->nBlobAlloc==0 and pParse->nBlob>0) then make it editable +** by making a copy into space obtained from malloc. +** +** Return true on success. Return false on OOM. +*/ +static int jsonBlobMakeEditable(JsonParse *pParse, u32 nExtra){ + u8 *aOld; + u32 nSize; + assert( !pParse->bReadOnly ); + if( pParse->oom ) return 0; + if( pParse->nBlobAlloc>0 ) return 1; + aOld = pParse->aBlob; + nSize = pParse->nBlob + nExtra; + pParse->aBlob = 0; + if( jsonBlobExpand(pParse, nSize) ){ + return 0; + } + assert( pParse->nBlobAlloc >= pParse->nBlob + nExtra ); + memcpy(pParse->aBlob, aOld, pParse->nBlob); + return 1; +} + +/* Expand pParse->aBlob and append one bytes. +*/ +static SQLITE_NOINLINE void jsonBlobExpandAndAppendOneByte( + JsonParse *pParse, + u8 c +){ + jsonBlobExpand(pParse, pParse->nBlob+1); + if( pParse->oom==0 ){ + assert( pParse->nBlob+1<=pParse->nBlobAlloc ); + pParse->aBlob[pParse->nBlob++] = c; + } +} + +/* Append a single character. +*/ +static void jsonBlobAppendOneByte(JsonParse *pParse, u8 c){ + if( pParse->nBlob >= pParse->nBlobAlloc ){ + jsonBlobExpandAndAppendOneByte(pParse, c); + }else{ + pParse->aBlob[pParse->nBlob++] = c; + } +} + +/* Slow version of jsonBlobAppendNode() that first resizes the +** pParse->aBlob structure. +*/ +static void jsonBlobAppendNode(JsonParse*,u8,u32,const void*); +static SQLITE_NOINLINE void jsonBlobExpandAndAppendNode( + JsonParse *pParse, + u8 eType, + u32 szPayload, + const void *aPayload +){ + if( jsonBlobExpand(pParse, pParse->nBlob+szPayload+9) ) return; + jsonBlobAppendNode(pParse, eType, szPayload, aPayload); +} + + +/* Append an node type byte together with the payload size and +** possibly also the payload. +** +** If aPayload is not NULL, then it is a pointer to the payload which +** is also appended. If aPayload is NULL, the pParse->aBlob[] array +** is resized (if necessary) so that it is big enough to hold the +** payload, but the payload is not appended and pParse->nBlob is left +** pointing to where the first byte of payload will eventually be. +*/ +static void jsonBlobAppendNode( + JsonParse *pParse, /* The JsonParse object under construction */ + u8 eType, /* Node type. One of JSONB_* */ + u32 szPayload, /* Number of bytes of payload */ + const void *aPayload /* The payload. Might be NULL */ +){ + u8 *a; + if( pParse->nBlob+szPayload+9 > pParse->nBlobAlloc ){ + jsonBlobExpandAndAppendNode(pParse,eType,szPayload,aPayload); + return; + } + assert( pParse->aBlob!=0 ); + a = &pParse->aBlob[pParse->nBlob]; + if( szPayload<=11 ){ + a[0] = eType | (szPayload<<4); + pParse->nBlob += 1; + }else if( szPayload<=0xff ){ + a[0] = eType | 0xc0; + a[1] = szPayload & 0xff; + pParse->nBlob += 2; + }else if( szPayload<=0xffff ){ + a[0] = eType | 0xd0; + a[1] = (szPayload >> 8) & 0xff; + a[2] = szPayload & 0xff; + pParse->nBlob += 3; + }else{ + a[0] = eType | 0xe0; + a[1] = (szPayload >> 24) & 0xff; + a[2] = (szPayload >> 16) & 0xff; + a[3] = (szPayload >> 8) & 0xff; + a[4] = szPayload & 0xff; + pParse->nBlob += 5; + } + if( aPayload ){ + pParse->nBlob += szPayload; + memcpy(&pParse->aBlob[pParse->nBlob-szPayload], aPayload, szPayload); + } +} + +/* Change the payload size for the node at index i to be szPayload. +*/ +static int jsonBlobChangePayloadSize( + JsonParse *pParse, + u32 i, + u32 szPayload +){ + u8 *a; + u8 szType; + u8 nExtra; + u8 nNeeded; + int delta; + if( pParse->oom ) return 0; + a = &pParse->aBlob[i]; + szType = a[0]>>4; + if( szType<=11 ){ + nExtra = 0; + }else if( szType==12 ){ + nExtra = 1; + }else if( szType==13 ){ + nExtra = 2; + }else{ + nExtra = 4; + } + if( szPayload<=11 ){ + nNeeded = 0; + }else if( szPayload<=0xff ){ + nNeeded = 1; + }else if( szPayload<=0xffff ){ + nNeeded = 2; + }else{ + nNeeded = 4; + } + delta = nNeeded - nExtra; + if( delta ){ + u32 newSize = pParse->nBlob + delta; + if( delta>0 ){ + if( newSize>pParse->nBlobAlloc && jsonBlobExpand(pParse, newSize) ){ + return 0; /* OOM error. Error state recorded in pParse->oom. */ + } + a = &pParse->aBlob[i]; + memmove(&a[1+delta], &a[1], pParse->nBlob - (i+1)); + }else{ + memmove(&a[1], &a[1-delta], pParse->nBlob - (i+1-delta)); + } + pParse->nBlob = newSize; + } + if( nNeeded==0 ){ + a[0] = (a[0] & 0x0f) | (szPayload<<4); + }else if( nNeeded==1 ){ + a[0] = (a[0] & 0x0f) | 0xc0; + a[1] = szPayload & 0xff; + }else if( nNeeded==2 ){ + a[0] = (a[0] & 0x0f) | 0xd0; + a[1] = (szPayload >> 8) & 0xff; + a[2] = szPayload & 0xff; + }else{ + a[0] = (a[0] & 0x0f) | 0xe0; + a[1] = (szPayload >> 24) & 0xff; + a[2] = (szPayload >> 16) & 0xff; + a[3] = (szPayload >> 8) & 0xff; + a[4] = szPayload & 0xff; + } + return delta; +} + +/* +** If z[0] is 'u' and is followed by exactly 4 hexadecimal character, +** then set *pOp to JSONB_TEXTJ and return true. If not, do not make +** any changes to *pOp and return false. +*/ +static int jsonIs4HexB(const char *z, int *pOp){ + if( z[0]!='u' ) return 0; + if( !jsonIs4Hex(&z[1]) ) return 0; + *pOp = JSONB_TEXTJ; + return 1; +} + +/* +** Check a single element of the JSONB in pParse for validity. +** +** The element to be checked starts at offset i and must end at on the +** last byte before iEnd. +** +** Return 0 if everything is correct. Return the 1-based byte offset of the +** error if a problem is detected. (In other words, if the error is at offset +** 0, return 1). +*/ +static u32 jsonbValidityCheck( + const JsonParse *pParse, /* Input JSONB. Only aBlob and nBlob are used */ + u32 i, /* Start of element as pParse->aBlob[i] */ + u32 iEnd, /* One more than the last byte of the element */ + u32 iDepth /* Current nesting depth */ +){ + u32 n, sz, j, k; + const u8 *z; + u8 x; + if( iDepth>JSON_MAX_DEPTH ) return i+1; + sz = 0; + n = jsonbPayloadSize(pParse, i, &sz); + if( NEVER(n==0) ) return i+1; /* Checked by caller */ + if( NEVER(i+n+sz!=iEnd) ) return i+1; /* Checked by caller */ + z = pParse->aBlob; + x = z[i] & 0x0f; + switch( x ){ + case JSONB_NULL: + case JSONB_TRUE: + case JSONB_FALSE: { + return n+sz==1 ? 0 : i+1; + } + case JSONB_INT: { + if( sz<1 ) return i+1; + j = i+n; + if( z[j]=='-' ){ + j++; + if( sz<2 ) return i+1; + } + k = i+n+sz; + while( jk ) return j+1; + if( z[j+1]!='.' && z[j+1]!='e' && z[j+1]!='E' ) return j+1; + j++; + } + for(; j0 ) return j+1; + if( x==JSONB_FLOAT && (j==k-1 || !sqlite3Isdigit(z[j+1])) ){ + return j+1; + } + seen = 1; + continue; + } + if( z[j]=='e' || z[j]=='E' ){ + if( seen==2 ) return j+1; + if( j==k-1 ) return j+1; + if( z[j+1]=='+' || z[j+1]=='-' ){ + j++; + if( j==k-1 ) return j+1; + } + seen = 2; + continue; + } + return j+1; + } + if( seen==0 ) return i+1; + return 0; + } + case JSONB_TEXT: { + j = i+n; + k = j+sz; + while( j=k ){ + return j+1; + }else if( strchr("\"\\/bfnrt",z[j+1])!=0 ){ + j++; + }else if( z[j+1]=='u' ){ + if( j+5>=k ) return j+1; + if( !jsonIs4Hex((const char*)&z[j+2]) ) return j+1; + j++; + }else if( x!=JSONB_TEXT5 ){ + return j+1; + }else{ + u32 c = 0; + u32 szC = jsonUnescapeOneChar((const char*)&z[j], k-j, &c); + if( c==JSON_INVALID_CHAR ) return j+1; + j += szC - 1; + } + } + j++; + } + return 0; + } + case JSONB_TEXTRAW: { + return 0; + } + case JSONB_ARRAY: { + u32 sub; + j = i+n; + k = j+sz; + while( jk ) return j+1; + sub = jsonbValidityCheck(pParse, j, j+n+sz, iDepth+1); + if( sub ) return sub; + j += n + sz; + } + assert( j==k ); + return 0; + } + case JSONB_OBJECT: { + u32 cnt = 0; + u32 sub; + j = i+n; + k = j+sz; + while( jk ) return j+1; + if( (cnt & 1)==0 ){ + x = z[j] & 0x0f; + if( xJSONB_TEXTRAW ) return j+1; + } + sub = jsonbValidityCheck(pParse, j, j+n+sz, iDepth+1); + if( sub ) return sub; + cnt++; + j += n + sz; + } + assert( j==k ); + if( (cnt & 1)!=0 ) return j+1; + return 0; + } + default: { + return i+1; + } + } +} + +/* +** Translate a single element of JSON text at pParse->zJson[i] into +** its equivalent binary JSONB representation. Append the translation into +** pParse->aBlob[] beginning at pParse->nBlob. The size of +** pParse->aBlob[] is increased as necessary. +** +** Return the index of the first character past the end of the element parsed, +** or one of the following special result codes: ** ** 0 End of input -** -1 Syntax error -** -2 '}' seen -** -3 ']' seen -** -4 ',' seen -** -5 ':' seen +** -1 Syntax error or OOM +** -2 '}' seen \ +** -3 ']' seen \___ For these returns, pParse->iErr is set to +** -4 ',' seen / the index in zJson[] of the seen character +** -5 ':' seen / */ -static int jsonParseValue(JsonParse *pParse, u32 i){ +static int jsonTranslateTextToBlob(JsonParse *pParse, u32 i){ char c; u32 j; - int iThis; + u32 iThis, iStart; int x; - JsonNode *pNode; + u8 t; const char *z = pParse->zJson; json_parse_restart: switch( (u8)z[i] ){ case '{': { /* Parse object */ - iThis = jsonParseAddNode(pParse, JSON_OBJECT, 0, 0); - if( iThis<0 ) return -1; + iThis = pParse->nBlob; + jsonBlobAppendNode(pParse, JSONB_OBJECT, pParse->nJson-i, 0); if( ++pParse->iDepth > JSON_MAX_DEPTH ){ pParse->iErr = i; return -1; } + iStart = pParse->nBlob; for(j=i+1;;j++){ - u32 nNode = pParse->nNode; - x = jsonParseValue(pParse, j); + u32 iBlob = pParse->nBlob; + x = jsonTranslateTextToBlob(pParse, j); if( x<=0 ){ + int op; if( x==(-2) ){ j = pParse->iErr; - if( pParse->nNode!=(u32)iThis+1 ) pParse->hasNonstd = 1; + if( pParse->nBlob!=(u32)iStart ) pParse->hasNonstd = 1; break; } j += json5Whitespace(&z[j]); + op = JSONB_TEXT; if( sqlite3JsonId1(z[j]) - || (z[j]=='\\' && z[j+1]=='u' && jsonIs4Hex(&z[j+2])) + || (z[j]=='\\' && jsonIs4HexB(&z[j+1], &op)) ){ int k = j+1; while( (sqlite3JsonId2(z[k]) && json5Whitespace(&z[k])==0) - || (z[k]=='\\' && z[k+1]=='u' && jsonIs4Hex(&z[k+2])) + || (z[k]=='\\' && jsonIs4HexB(&z[k+1], &op)) ){ k++; } - jsonParseAddNode(pParse, JSON_STRING | (JNODE_RAW<<8), k-j, &z[j]); + assert( iBlob==pParse->nBlob ); + jsonBlobAppendNode(pParse, op, k-j, &z[j]); pParse->hasNonstd = 1; x = k; }else{ @@ -203939,24 +204702,24 @@ json_parse_restart: } } if( pParse->oom ) return -1; - pNode = &pParse->aNode[nNode]; - if( pNode->eType!=JSON_STRING ){ + t = pParse->aBlob[iBlob] & 0x0f; + if( tJSONB_TEXTRAW ){ pParse->iErr = j; return -1; } - pNode->jnFlags |= JNODE_LABEL; j = x; if( z[j]==':' ){ j++; }else{ - if( fast_isspace(z[j]) ){ - do{ j++; }while( fast_isspace(z[j]) ); + if( jsonIsspace(z[j]) ){ + /* strspn() is not helpful here */ + do{ j++; }while( jsonIsspace(z[j]) ); if( z[j]==':' ){ j++; goto parse_object_value; } } - x = jsonParseValue(pParse, j); + x = jsonTranslateTextToBlob(pParse, j); if( x!=(-5) ){ if( x!=(-1) ) pParse->iErr = j; return -1; @@ -203964,7 +204727,7 @@ json_parse_restart: j = pParse->iErr+1; } parse_object_value: - x = jsonParseValue(pParse, j); + x = jsonTranslateTextToBlob(pParse, j); if( x<=0 ){ if( x!=(-1) ) pParse->iErr = j; return -1; @@ -203975,15 +204738,15 @@ json_parse_restart: }else if( z[j]=='}' ){ break; }else{ - if( fast_isspace(z[j]) ){ - do{ j++; }while( fast_isspace(z[j]) ); + if( jsonIsspace(z[j]) ){ + j += 1 + (u32)strspn(&z[j+1], jsonSpaces); if( z[j]==',' ){ continue; }else if( z[j]=='}' ){ break; } } - x = jsonParseValue(pParse, j); + x = jsonTranslateTextToBlob(pParse, j); if( x==(-4) ){ j = pParse->iErr; continue; @@ -203996,25 +204759,26 @@ json_parse_restart: pParse->iErr = j; return -1; } - pParse->aNode[iThis].n = pParse->nNode - (u32)iThis - 1; + jsonBlobChangePayloadSize(pParse, iThis, pParse->nBlob - iStart); pParse->iDepth--; return j+1; } case '[': { /* Parse array */ - iThis = jsonParseAddNode(pParse, JSON_ARRAY, 0, 0); - if( iThis<0 ) return -1; + iThis = pParse->nBlob; + jsonBlobAppendNode(pParse, JSONB_ARRAY, pParse->nJson - i, 0); + iStart = pParse->nBlob; + if( pParse->oom ) return -1; if( ++pParse->iDepth > JSON_MAX_DEPTH ){ pParse->iErr = i; return -1; } - memset(&pParse->aNode[iThis].u, 0, sizeof(pParse->aNode[iThis].u)); for(j=i+1;;j++){ - x = jsonParseValue(pParse, j); + x = jsonTranslateTextToBlob(pParse, j); if( x<=0 ){ if( x==(-3) ){ j = pParse->iErr; - if( pParse->nNode!=(u32)iThis+1 ) pParse->hasNonstd = 1; + if( pParse->nBlob!=iStart ) pParse->hasNonstd = 1; break; } if( x!=(-1) ) pParse->iErr = j; @@ -204026,15 +204790,15 @@ json_parse_restart: }else if( z[j]==']' ){ break; }else{ - if( fast_isspace(z[j]) ){ - do{ j++; }while( fast_isspace(z[j]) ); + if( jsonIsspace(z[j]) ){ + j += 1 + (u32)strspn(&z[j+1], jsonSpaces); if( z[j]==',' ){ continue; }else if( z[j]==']' ){ break; } } - x = jsonParseValue(pParse, j); + x = jsonTranslateTextToBlob(pParse, j); if( x==(-4) ){ j = pParse->iErr; continue; @@ -204047,23 +204811,33 @@ json_parse_restart: pParse->iErr = j; return -1; } - pParse->aNode[iThis].n = pParse->nNode - (u32)iThis - 1; + jsonBlobChangePayloadSize(pParse, iThis, pParse->nBlob - iStart); pParse->iDepth--; return j+1; } case '\'': { - u8 jnFlags; + u8 opcode; char cDelim; pParse->hasNonstd = 1; - jnFlags = JNODE_JSON5; + opcode = JSONB_TEXT; goto parse_string; case '"': /* Parse string */ - jnFlags = 0; + opcode = JSONB_TEXT; parse_string: cDelim = z[i]; - for(j=i+1; 1; j++){ - if( jsonIsOk[(unsigned char)z[j]] ) continue; + j = i+1; + while( 1 /*exit-by-break*/ ){ + if( jsonIsOk[(u8)z[j]] ){ + if( !jsonIsOk[(u8)z[j+1]] ){ + j += 1; + }else if( !jsonIsOk[(u8)z[j+2]] ){ + j += 2; + }else{ + j += 3; + continue; + } + } c = z[j]; if( c==cDelim ){ break; @@ -204072,16 +204846,16 @@ json_parse_restart: if( c=='"' || c=='\\' || c=='/' || c=='b' || c=='f' || c=='n' || c=='r' || c=='t' || (c=='u' && jsonIs4Hex(&z[j+1])) ){ - jnFlags |= JNODE_ESCAPE; + if( opcode==JSONB_TEXT ) opcode = JSONB_TEXTJ; }else if( c=='\'' || c=='0' || c=='v' || c=='\n' || (0xe2==(u8)c && 0x80==(u8)z[j+1] && (0xa8==(u8)z[j+2] || 0xa9==(u8)z[j+2])) || (c=='x' && jsonIs2Hex(&z[j+1])) ){ - jnFlags |= (JNODE_ESCAPE|JNODE_JSON5); + opcode = JSONB_TEXT5; pParse->hasNonstd = 1; }else if( c=='\r' ){ if( z[j+1]=='\n' ) j++; - jnFlags |= (JNODE_ESCAPE|JNODE_JSON5); + opcode = JSONB_TEXT5; pParse->hasNonstd = 1; }else{ pParse->iErr = j; @@ -204091,14 +204865,17 @@ json_parse_restart: /* Control characters are not allowed in strings */ pParse->iErr = j; return -1; + }else if( c=='"' ){ + opcode = JSONB_TEXT5; } + j++; } - jsonParseAddNode(pParse, JSON_STRING | (jnFlags<<8), j+1-i, &z[i]); + jsonBlobAppendNode(pParse, opcode, j-1-i, &z[i+1]); return j+1; } case 't': { if( strncmp(z+i,"true",4)==0 && !sqlite3Isalnum(z[i+4]) ){ - jsonParseAddNode(pParse, JSON_TRUE, 0, 0); + jsonBlobAppendOneByte(pParse, JSONB_TRUE); return i+4; } pParse->iErr = i; @@ -204106,23 +204883,22 @@ json_parse_restart: } case 'f': { if( strncmp(z+i,"false",5)==0 && !sqlite3Isalnum(z[i+5]) ){ - jsonParseAddNode(pParse, JSON_FALSE, 0, 0); + jsonBlobAppendOneByte(pParse, JSONB_FALSE); return i+5; } pParse->iErr = i; return -1; } case '+': { - u8 seenDP, seenE, jnFlags; + u8 seenE; pParse->hasNonstd = 1; - jnFlags = JNODE_JSON5; + t = 0x00; /* Bit 0x01: JSON5. Bit 0x02: FLOAT */ goto parse_number; case '.': if( sqlite3Isdigit(z[i+1]) ){ pParse->hasNonstd = 1; - jnFlags = JNODE_JSON5; + t = 0x03; /* Bit 0x01: JSON5. Bit 0x02: FLOAT */ seenE = 0; - seenDP = JSON_REAL; goto parse_number_2; } pParse->iErr = i; @@ -204139,9 +204915,8 @@ json_parse_restart: case '8': case '9': /* Parse number */ - jnFlags = 0; + t = 0x00; /* Bit 0x01: JSON5. Bit 0x02: FLOAT */ parse_number: - seenDP = JSON_INT; seenE = 0; assert( '-' < '0' ); assert( '+' < '0' ); @@ -204151,9 +204926,9 @@ json_parse_restart: if( c<='0' ){ if( c=='0' ){ if( (z[i+1]=='x' || z[i+1]=='X') && sqlite3Isxdigit(z[i+2]) ){ - assert( seenDP==JSON_INT ); + assert( t==0x00 ); pParse->hasNonstd = 1; - jnFlags |= JNODE_JSON5; + t = 0x01; for(j=i+3; sqlite3Isxdigit(z[j]); j++){} goto parse_number_finish; }else if( sqlite3Isdigit(z[i+1]) ){ @@ -204170,15 +204945,15 @@ json_parse_restart: ){ pParse->hasNonstd = 1; if( z[i]=='-' ){ - jsonParseAddNode(pParse, JSON_REAL, 8, "-9.0e999"); + jsonBlobAppendNode(pParse, JSONB_FLOAT, 6, "-9e999"); }else{ - jsonParseAddNode(pParse, JSON_REAL, 7, "9.0e999"); + jsonBlobAppendNode(pParse, JSONB_FLOAT, 5, "9e999"); } return i + (sqlite3StrNICmp(&z[i+4],"inity",5)==0 ? 9 : 4); } if( z[i+1]=='.' ){ pParse->hasNonstd = 1; - jnFlags |= JNODE_JSON5; + t |= 0x01; goto parse_number_2; } pParse->iErr = i; @@ -204190,30 +204965,31 @@ json_parse_restart: return -1; }else if( (z[i+2]=='x' || z[i+2]=='X') && sqlite3Isxdigit(z[i+3]) ){ pParse->hasNonstd = 1; - jnFlags |= JNODE_JSON5; + t |= 0x01; for(j=i+4; sqlite3Isxdigit(z[j]); j++){} goto parse_number_finish; } } } } + parse_number_2: for(j=i+1;; j++){ c = z[j]; if( sqlite3Isdigit(c) ) continue; if( c=='.' ){ - if( seenDP==JSON_REAL ){ + if( (t & 0x02)!=0 ){ pParse->iErr = j; return -1; } - seenDP = JSON_REAL; + t |= 0x02; continue; } if( c=='e' || c=='E' ){ if( z[j-1]<'0' ){ if( ALWAYS(z[j-1]=='.') && ALWAYS(j-2>=i) && sqlite3Isdigit(z[j-2]) ){ pParse->hasNonstd = 1; - jnFlags |= JNODE_JSON5; + t |= 0x01; }else{ pParse->iErr = j; return -1; @@ -204223,7 +204999,7 @@ json_parse_restart: pParse->iErr = j; return -1; } - seenDP = JSON_REAL; + t |= 0x02; seenE = 1; c = z[j+1]; if( c=='+' || c=='-' ){ @@ -204241,14 +205017,18 @@ json_parse_restart: if( z[j-1]<'0' ){ if( ALWAYS(z[j-1]=='.') && ALWAYS(j-2>=i) && sqlite3Isdigit(z[j-2]) ){ pParse->hasNonstd = 1; - jnFlags |= JNODE_JSON5; + t |= 0x01; }else{ pParse->iErr = j; return -1; } } parse_number_finish: - jsonParseAddNode(pParse, seenDP | (jnFlags<<8), j - i, &z[i]); + assert( JSONB_INT+0x01==JSONB_INT5 ); + assert( JSONB_FLOAT+0x01==JSONB_FLOAT5 ); + assert( JSONB_INT+0x02==JSONB_FLOAT ); + if( z[i]=='+' ) i++; + jsonBlobAppendNode(pParse, JSONB_INT+t, j-i, &z[i]); return j; } case '}': { @@ -204274,9 +205054,7 @@ json_parse_restart: case 0x0a: case 0x0d: case 0x20: { - do{ - i++; - }while( fast_isspace(z[i]) ); + i += 1 + (u32)strspn(&z[i+1], jsonSpaces); goto json_parse_restart; } case 0x0b: @@ -204298,7 +205076,7 @@ json_parse_restart: } case 'n': { if( strncmp(z+i,"null",4)==0 && !sqlite3Isalnum(z[i+4]) ){ - jsonParseAddNode(pParse, JSON_NULL, 0, 0); + jsonBlobAppendOneByte(pParse, JSONB_NULL); return i+4; } /* fall-through into the default case that checks for NaN */ @@ -204314,8 +205092,11 @@ json_parse_restart: continue; } if( sqlite3Isalnum(z[i+nn]) ) continue; - jsonParseAddNode(pParse, aNanInfName[k].eType, - aNanInfName[k].nRepl, aNanInfName[k].zRepl); + if( aNanInfName[k].eType==JSONB_FLOAT ){ + jsonBlobAppendNode(pParse, JSONB_FLOAT, 5, "9e999"); + }else{ + jsonBlobAppendOneByte(pParse, JSONB_NULL); + } pParse->hasNonstd = 1; return i + nn; } @@ -204325,6 +205106,7 @@ json_parse_restart: } /* End switch(z[i]) */ } + /* ** Parse a complete JSON string. Return 0 on success or non-zero if there ** are any errors. If an error occurs, free all memory held by pParse, @@ -204333,20 +205115,26 @@ json_parse_restart: ** pParse must be initialized to an empty parse object prior to calling ** this routine. */ -static int jsonParse( +static int jsonConvertTextToBlob( JsonParse *pParse, /* Initialize and fill this JsonParse object */ sqlite3_context *pCtx /* Report errors here */ ){ int i; const char *zJson = pParse->zJson; - i = jsonParseValue(pParse, 0); + i = jsonTranslateTextToBlob(pParse, 0); if( pParse->oom ) i = -1; if( i>0 ){ +#ifdef SQLITE_DEBUG assert( pParse->iDepth==0 ); - while( fast_isspace(zJson[i]) ) i++; + if( sqlite3Config.bJsonSelfcheck ){ + assert( jsonbValidityCheck(pParse, 0, pParse->nBlob, 0)==0 ); + } +#endif + while( jsonIsspace(zJson[i]) ) i++; if( zJson[i] ){ i += json5Whitespace(&zJson[i]); if( zJson[i] ){ + if( pCtx ) sqlite3_result_error(pCtx, "malformed JSON", -1); jsonParseReset(pParse); return 1; } @@ -204367,248 +205155,710 @@ static int jsonParse( return 0; } - -/* Mark node i of pParse as being a child of iParent. Call recursively -** to fill in all the descendants of node i. +/* +** The input string pStr is a well-formed JSON text string. Convert +** this into the JSONB format and make it the return value of the +** SQL function. */ -static void jsonParseFillInParentage(JsonParse *pParse, u32 i, u32 iParent){ - JsonNode *pNode = &pParse->aNode[i]; - u32 j; - pParse->aUp[i] = iParent; - switch( pNode->eType ){ - case JSON_ARRAY: { - for(j=1; j<=pNode->n; j += jsonNodeSize(pNode+j)){ - jsonParseFillInParentage(pParse, i+j, i); - } - break; - } - case JSON_OBJECT: { - for(j=1; j<=pNode->n; j += jsonNodeSize(pNode+j+1)+1){ - pParse->aUp[i+j] = i; - jsonParseFillInParentage(pParse, i+j+1, i); - } - break; - } - default: { - break; - } +static void jsonReturnStringAsBlob(JsonString *pStr){ + JsonParse px; + memset(&px, 0, sizeof(px)); + jsonStringTerminate(pStr); + px.zJson = pStr->zBuf; + px.nJson = pStr->nUsed; + px.db = sqlite3_context_db_handle(pStr->pCtx); + (void)jsonTranslateTextToBlob(&px, 0); + if( px.oom ){ + sqlite3DbFree(px.db, px.aBlob); + sqlite3_result_error_nomem(pStr->pCtx); + }else{ + assert( px.nBlobAlloc>0 ); + assert( !px.bReadOnly ); + sqlite3_result_blob(pStr->pCtx, px.aBlob, px.nBlob, SQLITE_DYNAMIC); } } -/* -** Compute the parentage of all nodes in a completed parse. +/* The byte at index i is a node type-code. This routine +** determines the payload size for that node and writes that +** payload size in to *pSz. It returns the offset from i to the +** beginning of the payload. Return 0 on error. */ -static int jsonParseFindParents(JsonParse *pParse){ - u32 *aUp; - assert( pParse->aUp==0 ); - aUp = pParse->aUp = sqlite3_malloc64( sizeof(u32)*pParse->nNode ); - if( aUp==0 ){ - pParse->oom = 1; - return SQLITE_NOMEM; - } - jsonParseFillInParentage(pParse, 0, 0); - return SQLITE_OK; -} - -/* -** Magic number used for the JSON parse cache in sqlite3_get_auxdata() -*/ -#define JSON_CACHE_ID (-429938) /* First cache entry */ -#define JSON_CACHE_SZ 4 /* Max number of cache entries */ - -/* -** Obtain a complete parse of the JSON found in the pJson argument -** -** Use the sqlite3_get_auxdata() cache to find a preexisting parse -** if it is available. If the cache is not available or if it -** is no longer valid, parse the JSON again and return the new parse. -** Also register the new parse so that it will be available for -** future sqlite3_get_auxdata() calls. -** -** If an error occurs and pErrCtx!=0 then report the error on pErrCtx -** and return NULL. -** -** The returned pointer (if it is not NULL) is owned by the cache in -** most cases, not the caller. The caller does NOT need to invoke -** jsonParseFree(), in most cases. -** -** Except, if an error occurs and pErrCtx==0 then return the JsonParse -** object with JsonParse.nErr non-zero and the caller will own the JsonParse -** object. In that case, it will be the responsibility of the caller to -** invoke jsonParseFree(). To summarize: -** -** pErrCtx!=0 || p->nErr==0 ==> Return value p is owned by the -** cache. Call does not need to -** free it. -** -** pErrCtx==0 && p->nErr!=0 ==> Return value is owned by the caller -** and so the caller must free it. -*/ -static JsonParse *jsonParseCached( - sqlite3_context *pCtx, /* Context to use for cache search */ - sqlite3_value *pJson, /* Function param containing JSON text */ - sqlite3_context *pErrCtx, /* Write parse errors here if not NULL */ - int bUnedited /* No prior edits allowed */ -){ - char *zJson = (char*)sqlite3_value_text(pJson); - int nJson = sqlite3_value_bytes(pJson); - JsonParse *p; - JsonParse *pMatch = 0; - int iKey; - int iMinKey = 0; - u32 iMinHold = 0xffffffff; - u32 iMaxHold = 0; - int bJsonRCStr; - - if( zJson==0 ) return 0; - for(iKey=0; iKeynJson==nJson - && (p->hasMod==0 || bUnedited==0) - && (p->zJson==zJson || memcmp(p->zJson,zJson,nJson)==0) - ){ - p->nErr = 0; - p->useMod = 0; - pMatch = p; - }else - if( pMatch==0 - && p->zAlt!=0 - && bUnedited==0 - && p->nAlt==nJson - && memcmp(p->zAlt, zJson, nJson)==0 - ){ - p->nErr = 0; - p->useMod = 1; - pMatch = p; - }else if( p->iHoldiHold; - iMinKey = iKey; - } - if( p->iHold>iMaxHold ){ - iMaxHold = p->iHold; - } - } - if( pMatch ){ - /* The input JSON text was found in the cache. Use the preexisting - ** parse of this JSON */ - pMatch->nErr = 0; - pMatch->iHold = iMaxHold+1; - assert( pMatch->nJPRef>0 ); /* pMatch is owned by the cache */ - return pMatch; - } - - /* The input JSON was not found anywhere in the cache. We will need - ** to parse it ourselves and generate a new JsonParse object. - */ - bJsonRCStr = sqlite3ValueIsOfClass(pJson,sqlite3RCStrUnref); - p = sqlite3_malloc64( sizeof(*p) + (bJsonRCStr ? 0 : nJson+1) ); - if( p==0 ){ - sqlite3_result_error_nomem(pCtx); +static u32 jsonbPayloadSize(const JsonParse *pParse, u32 i, u32 *pSz){ + u8 x; + u32 sz; + u32 n; + if( NEVER(i>pParse->nBlob) ){ + *pSz = 0; return 0; } - memset(p, 0, sizeof(*p)); - if( bJsonRCStr ){ - p->zJson = sqlite3RCStrRef(zJson); - p->bJsonIsRCStr = 1; - }else{ - p->zJson = (char*)&p[1]; - memcpy(p->zJson, zJson, nJson+1); - } - p->nJPRef = 1; - if( jsonParse(p, pErrCtx) ){ - if( pErrCtx==0 ){ - p->nErr = 1; - assert( p->nJPRef==1 ); /* Caller will own the new JsonParse object p */ - return p; - } - jsonParseFree(p); - return 0; - } - p->nJson = nJson; - p->iHold = iMaxHold+1; - /* Transfer ownership of the new JsonParse to the cache */ - sqlite3_set_auxdata(pCtx, JSON_CACHE_ID+iMinKey, p, - (void(*)(void*))jsonParseFree); - return (JsonParse*)sqlite3_get_auxdata(pCtx, JSON_CACHE_ID+iMinKey); -} - -/* -** Compare the OBJECT label at pNode against zKey,nKey. Return true on -** a match. -*/ -static int jsonLabelCompare(const JsonNode *pNode, const char *zKey, u32 nKey){ - assert( pNode->eU==1 ); - if( pNode->jnFlags & JNODE_RAW ){ - if( pNode->n!=nKey ) return 0; - return strncmp(pNode->u.zJContent, zKey, nKey)==0; - }else{ - if( pNode->n!=nKey+2 ) return 0; - return strncmp(pNode->u.zJContent+1, zKey, nKey)==0; - } -} -static int jsonSameLabel(const JsonNode *p1, const JsonNode *p2){ - if( p1->jnFlags & JNODE_RAW ){ - return jsonLabelCompare(p2, p1->u.zJContent, p1->n); - }else if( p2->jnFlags & JNODE_RAW ){ - return jsonLabelCompare(p1, p2->u.zJContent, p2->n); - }else{ - return p1->n==p2->n && strncmp(p1->u.zJContent,p2->u.zJContent,p1->n)==0; - } -} - -/* forward declaration */ -static JsonNode *jsonLookupAppend(JsonParse*,const char*,int*,const char**); - -/* -** Search along zPath to find the node specified. Return a pointer -** to that node, or NULL if zPath is malformed or if there is no such -** node. -** -** If pApnd!=0, then try to append new nodes to complete zPath if it is -** possible to do so and if no existing node corresponds to zPath. If -** new nodes are appended *pApnd is set to 1. -*/ -static JsonNode *jsonLookupStep( - JsonParse *pParse, /* The JSON to search */ - u32 iRoot, /* Begin the search at this node */ - const char *zPath, /* The path to search */ - int *pApnd, /* Append nodes to complete path if not NULL */ - const char **pzErr /* Make *pzErr point to any syntax error in zPath */ -){ - u32 i, j, nKey; - const char *zKey; - JsonNode *pRoot; - if( pParse->oom ) return 0; - pRoot = &pParse->aNode[iRoot]; - if( pRoot->jnFlags & (JNODE_REPLACE|JNODE_REMOVE) && pParse->useMod ){ - while( (pRoot->jnFlags & JNODE_REPLACE)!=0 ){ - u32 idx = (u32)(pRoot - pParse->aNode); - i = pParse->iSubst; - while( 1 /*exit-by-break*/ ){ - assert( inNode ); - assert( pParse->aNode[i].eType==JSON_SUBST ); - assert( pParse->aNode[i].eU==4 ); - assert( pParse->aNode[i].u.iPrevaNode[i].n==idx ){ - pRoot = &pParse->aNode[i+1]; - iRoot = i+1; - break; - } - i = pParse->aNode[i].u.iPrev; - } - } - if( pRoot->jnFlags & JNODE_REMOVE ){ + x = pParse->aBlob[i]>>4; + if( x<=11 ){ + sz = x; + n = 1; + }else if( x==12 ){ + if( i+1>=pParse->nBlob ){ + *pSz = 0; return 0; } + sz = pParse->aBlob[i+1]; + n = 2; + }else if( x==13 ){ + if( i+2>=pParse->nBlob ){ + *pSz = 0; + return 0; + } + sz = (pParse->aBlob[i+1]<<8) + pParse->aBlob[i+2]; + n = 3; + }else if( x==14 ){ + if( i+4>=pParse->nBlob ){ + *pSz = 0; + return 0; + } + sz = ((u32)pParse->aBlob[i+1]<<24) + (pParse->aBlob[i+2]<<16) + + (pParse->aBlob[i+3]<<8) + pParse->aBlob[i+4]; + n = 5; + }else{ + if( i+8>=pParse->nBlob + || pParse->aBlob[i+1]!=0 + || pParse->aBlob[i+2]!=0 + || pParse->aBlob[i+3]!=0 + || pParse->aBlob[i+4]!=0 + ){ + *pSz = 0; + return 0; + } + sz = (pParse->aBlob[i+5]<<24) + (pParse->aBlob[i+6]<<16) + + (pParse->aBlob[i+7]<<8) + pParse->aBlob[i+8]; + n = 9; + } + if( i+sz+n > pParse->nBlob + && i+sz+n > pParse->nBlob-pParse->delta + ){ + sz = 0; + n = 0; + } + *pSz = sz; + return n; +} + + +/* +** Translate the binary JSONB representation of JSON beginning at +** pParse->aBlob[i] into a JSON text string. Append the JSON +** text onto the end of pOut. Return the index in pParse->aBlob[] +** of the first byte past the end of the element that is translated. +** +** If an error is detected in the BLOB input, the pOut->eErr flag +** might get set to JSTRING_MALFORMED. But not all BLOB input errors +** are detected. So a malformed JSONB input might either result +** in an error, or in incorrect JSON. +** +** The pOut->eErr JSTRING_OOM flag is set on a OOM. +*/ +static u32 jsonTranslateBlobToText( + const JsonParse *pParse, /* the complete parse of the JSON */ + u32 i, /* Start rendering at this index */ + JsonString *pOut /* Write JSON here */ +){ + u32 sz, n, j, iEnd; + + n = jsonbPayloadSize(pParse, i, &sz); + if( n==0 ){ + pOut->eErr |= JSTRING_MALFORMED; + return pParse->nBlob+1; + } + switch( pParse->aBlob[i] & 0x0f ){ + case JSONB_NULL: { + jsonAppendRawNZ(pOut, "null", 4); + return i+1; + } + case JSONB_TRUE: { + jsonAppendRawNZ(pOut, "true", 4); + return i+1; + } + case JSONB_FALSE: { + jsonAppendRawNZ(pOut, "false", 5); + return i+1; + } + case JSONB_INT: + case JSONB_FLOAT: { + jsonAppendRaw(pOut, (const char*)&pParse->aBlob[i+n], sz); + break; + } + case JSONB_INT5: { /* Integer literal in hexadecimal notation */ + u32 k = 2; + sqlite3_uint64 u = 0; + const char *zIn = (const char*)&pParse->aBlob[i+n]; + int bOverflow = 0; + if( zIn[0]=='-' ){ + jsonAppendChar(pOut, '-'); + k++; + }else if( zIn[0]=='+' ){ + k++; + } + for(; keErr |= JSTRING_MALFORMED; + break; + }else if( (u>>60)!=0 ){ + bOverflow = 1; + }else{ + u = u*16 + sqlite3HexToInt(zIn[k]); + } + } + jsonPrintf(100,pOut,bOverflow?"9.0e999":"%llu", u); + break; + } + case JSONB_FLOAT5: { /* Float literal missing digits beside "." */ + u32 k = 0; + const char *zIn = (const char*)&pParse->aBlob[i+n]; + if( zIn[0]=='-' ){ + jsonAppendChar(pOut, '-'); + k++; + } + if( zIn[k]=='.' ){ + jsonAppendChar(pOut, '0'); + } + for(; kaBlob[i+n], sz); + jsonAppendChar(pOut, '"'); + break; + } + case JSONB_TEXT5: { + const char *zIn; + u32 k; + u32 sz2 = sz; + zIn = (const char*)&pParse->aBlob[i+n]; + jsonAppendChar(pOut, '"'); + while( sz2>0 ){ + for(k=0; k0 ){ + jsonAppendRawNZ(pOut, zIn, k); + if( k>=sz2 ){ + break; + } + zIn += k; + sz2 -= k; + } + if( zIn[0]=='"' ){ + jsonAppendRawNZ(pOut, "\\\"", 2); + zIn++; + sz2--; + continue; + } + assert( zIn[0]=='\\' ); + assert( sz2>=1 ); + if( sz2<2 ){ + pOut->eErr |= JSTRING_MALFORMED; + break; + } + switch( (u8)zIn[1] ){ + case '\'': + jsonAppendChar(pOut, '\''); + break; + case 'v': + jsonAppendRawNZ(pOut, "\\u0009", 6); + break; + case 'x': + if( sz2<4 ){ + pOut->eErr |= JSTRING_MALFORMED; + sz2 = 2; + break; + } + jsonAppendRawNZ(pOut, "\\u00", 4); + jsonAppendRawNZ(pOut, &zIn[2], 2); + zIn += 2; + sz2 -= 2; + break; + case '0': + jsonAppendRawNZ(pOut, "\\u0000", 6); + break; + case '\r': + if( sz2>2 && zIn[2]=='\n' ){ + zIn++; + sz2--; + } + break; + case '\n': + break; + case 0xe2: + /* '\' followed by either U+2028 or U+2029 is ignored as + ** whitespace. Not that in UTF8, U+2028 is 0xe2 0x80 0x29. + ** U+2029 is the same except for the last byte */ + if( sz2<4 + || 0x80!=(u8)zIn[2] + || (0xa8!=(u8)zIn[3] && 0xa9!=(u8)zIn[3]) + ){ + pOut->eErr |= JSTRING_MALFORMED; + sz2 = 2; + break; + } + zIn += 2; + sz2 -= 2; + break; + default: + jsonAppendRawNZ(pOut, zIn, 2); + break; + } + assert( sz2>=2 ); + zIn += 2; + sz2 -= 2; + } + jsonAppendChar(pOut, '"'); + break; + } + case JSONB_TEXTRAW: { + jsonAppendString(pOut, (const char*)&pParse->aBlob[i+n], sz); + break; + } + case JSONB_ARRAY: { + jsonAppendChar(pOut, '['); + j = i+n; + iEnd = j+sz; + while( j0 ) pOut->nUsed--; + jsonAppendChar(pOut, ']'); + break; + } + case JSONB_OBJECT: { + int x = 0; + jsonAppendChar(pOut, '{'); + j = i+n; + iEnd = j+sz; + while( jeErr |= JSTRING_MALFORMED; + if( sz>0 ) pOut->nUsed--; + jsonAppendChar(pOut, '}'); + break; + } + + default: { + pOut->eErr |= JSTRING_MALFORMED; + break; + } + } + return i+n+sz; +} + +/* Return true if the input pJson +** +** For performance reasons, this routine does not do a detailed check of the +** input BLOB to ensure that it is well-formed. Hence, false positives are +** possible. False negatives should never occur, however. +*/ +static int jsonFuncArgMightBeBinary(sqlite3_value *pJson){ + u32 sz, n; + const u8 *aBlob; + int nBlob; + JsonParse s; + if( sqlite3_value_type(pJson)!=SQLITE_BLOB ) return 0; + aBlob = sqlite3_value_blob(pJson); + nBlob = sqlite3_value_bytes(pJson); + if( nBlob<1 ) return 0; + if( NEVER(aBlob==0) || (aBlob[0] & 0x0f)>JSONB_OBJECT ) return 0; + memset(&s, 0, sizeof(s)); + s.aBlob = (u8*)aBlob; + s.nBlob = nBlob; + n = jsonbPayloadSize(&s, 0, &sz); + if( n==0 ) return 0; + if( sz+n!=(u32)nBlob ) return 0; + if( (aBlob[0] & 0x0f)<=JSONB_FALSE && sz>0 ) return 0; + return sz+n==(u32)nBlob; +} + +/* +** Given that a JSONB_ARRAY object starts at offset i, return +** the number of entries in that array. +*/ +static u32 jsonbArrayCount(JsonParse *pParse, u32 iRoot){ + u32 n, sz, i, iEnd; + u32 k = 0; + n = jsonbPayloadSize(pParse, iRoot, &sz); + iEnd = iRoot+n+sz; + for(i=iRoot+n; n>0 && idelta. +*/ +static void jsonAfterEditSizeAdjust(JsonParse *pParse, u32 iRoot){ + u32 sz = 0; + u32 nBlob; + assert( pParse->delta!=0 ); + assert( pParse->nBlobAlloc >= pParse->nBlob ); + nBlob = pParse->nBlob; + pParse->nBlob = pParse->nBlobAlloc; + (void)jsonbPayloadSize(pParse, iRoot, &sz); + pParse->nBlob = nBlob; + sz += pParse->delta; + pParse->delta += jsonBlobChangePayloadSize(pParse, iRoot, sz); +} + +/* +** Modify the JSONB blob at pParse->aBlob by removing nDel bytes of +** content beginning at iDel, and replacing them with nIns bytes of +** content given by aIns. +** +** nDel may be zero, in which case no bytes are removed. But iDel is +** still important as new bytes will be insert beginning at iDel. +** +** aIns may be zero, in which case space is created to hold nIns bytes +** beginning at iDel, but that space is uninitialized. +** +** Set pParse->oom if an OOM occurs. +*/ +static void jsonBlobEdit( + JsonParse *pParse, /* The JSONB to be modified is in pParse->aBlob */ + u32 iDel, /* First byte to be removed */ + u32 nDel, /* Number of bytes to remove */ + const u8 *aIns, /* Content to insert */ + u32 nIns /* Bytes of content to insert */ +){ + i64 d = (i64)nIns - (i64)nDel; + if( d!=0 ){ + if( pParse->nBlob + d > pParse->nBlobAlloc ){ + jsonBlobExpand(pParse, pParse->nBlob+d); + if( pParse->oom ) return; + } + memmove(&pParse->aBlob[iDel+nIns], + &pParse->aBlob[iDel+nDel], + pParse->nBlob - (iDel+nDel)); + pParse->nBlob += d; + pParse->delta += d; + } + if( nIns && aIns ) memcpy(&pParse->aBlob[iDel], aIns, nIns); +} + +/* +** Return the number of escaped newlines to be ignored. +** An escaped newline is a one of the following byte sequences: +** +** 0x5c 0x0a +** 0x5c 0x0d +** 0x5c 0x0d 0x0a +** 0x5c 0xe2 0x80 0xa8 +** 0x5c 0xe2 0x80 0xa9 +*/ +static u32 jsonBytesToBypass(const char *z, u32 n){ + u32 i = 0; + while( i+10 ); + assert( z[0]=='\\' ); + if( n<2 ){ + *piOut = JSON_INVALID_CHAR; + return n; + } + switch( (u8)z[1] ){ + case 'u': { + u32 v, vlo; + if( n<6 ){ + *piOut = JSON_INVALID_CHAR; + return n; + } + v = jsonHexToInt4(&z[2]); + if( (v & 0xfc00)==0xd800 + && n>=12 + && z[6]=='\\' + && z[7]=='u' + && ((vlo = jsonHexToInt4(&z[8]))&0xfc00)==0xdc00 + ){ + *piOut = ((v&0x3ff)<<10) + (vlo&0x3ff) + 0x10000; + return 12; + }else{ + *piOut = v; + return 6; + } + } + case 'b': { *piOut = '\b'; return 2; } + case 'f': { *piOut = '\f'; return 2; } + case 'n': { *piOut = '\n'; return 2; } + case 'r': { *piOut = '\r'; return 2; } + case 't': { *piOut = '\t'; return 2; } + case 'v': { *piOut = '\v'; return 2; } + case '0': { *piOut = 0; return 2; } + case '\'': + case '"': + case '/': + case '\\':{ *piOut = z[1]; return 2; } + case 'x': { + if( n<4 ){ + *piOut = JSON_INVALID_CHAR; + return n; + } + *piOut = (jsonHexToInt(z[2])<<4) | jsonHexToInt(z[3]); + return 4; + } + case 0xe2: + case '\r': + case '\n': { + u32 nSkip = jsonBytesToBypass(z, n); + if( nSkip==0 ){ + *piOut = JSON_INVALID_CHAR; + return n; + }else if( nSkip==n ){ + *piOut = 0; + return n; + }else if( z[nSkip]=='\\' ){ + return nSkip + jsonUnescapeOneChar(&z[nSkip], n-nSkip, piOut); + }else{ + int sz = sqlite3Utf8ReadLimited((u8*)&z[nSkip], n-nSkip, piOut); + return nSkip + sz; + } + } + default: { + *piOut = JSON_INVALID_CHAR; + return 2; + } + } +} + + +/* +** Compare two object labels. Return 1 if they are equal and +** 0 if they differ. +** +** In this version, we know that one or the other or both of the +** two comparands contains an escape sequence. +*/ +static SQLITE_NOINLINE int jsonLabelCompareEscaped( + const char *zLeft, /* The left label */ + u32 nLeft, /* Size of the left label in bytes */ + int rawLeft, /* True if zLeft contains no escapes */ + const char *zRight, /* The right label */ + u32 nRight, /* Size of the right label in bytes */ + int rawRight /* True if zRight is escape-free */ +){ + u32 cLeft, cRight; + assert( rawLeft==0 || rawRight==0 ); + while( 1 /*exit-by-return*/ ){ + if( nLeft==0 ){ + cLeft = 0; + }else if( rawLeft || zLeft[0]!='\\' ){ + cLeft = ((u8*)zLeft)[0]; + if( cLeft>=0xc0 ){ + int sz = sqlite3Utf8ReadLimited((u8*)zLeft, nLeft, &cLeft); + zLeft += sz; + nLeft -= sz; + }else{ + zLeft++; + nLeft--; + } + }else{ + u32 n = jsonUnescapeOneChar(zLeft, nLeft, &cLeft); + zLeft += n; + assert( n<=nLeft ); + nLeft -= n; + } + if( nRight==0 ){ + cRight = 0; + }else if( rawRight || zRight[0]!='\\' ){ + cRight = ((u8*)zRight)[0]; + if( cRight>=0xc0 ){ + int sz = sqlite3Utf8ReadLimited((u8*)zRight, nRight, &cRight); + zRight += sz; + nRight -= sz; + }else{ + zRight++; + nRight--; + } + }else{ + u32 n = jsonUnescapeOneChar(zRight, nRight, &cRight); + zRight += n; + assert( n<=nRight ); + nRight -= n; + } + if( cLeft!=cRight ) return 0; + if( cLeft==0 ) return 1; + } +} + +/* +** Compare two object labels. Return 1 if they are equal and +** 0 if they differ. Return -1 if an OOM occurs. +*/ +static int jsonLabelCompare( + const char *zLeft, /* The left label */ + u32 nLeft, /* Size of the left label in bytes */ + int rawLeft, /* True if zLeft contains no escapes */ + const char *zRight, /* The right label */ + u32 nRight, /* Size of the right label in bytes */ + int rawRight /* True if zRight is escape-free */ +){ + if( rawLeft && rawRight ){ + /* Simpliest case: Neither label contains escapes. A simple + ** memcmp() is sufficient. */ + if( nLeft!=nRight ) return 0; + return memcmp(zLeft, zRight, nLeft)==0; + }else{ + return jsonLabelCompareEscaped(zLeft, nLeft, rawLeft, + zRight, nRight, rawRight); + } +} + +/* +** Error returns from jsonLookupStep() +*/ +#define JSON_LOOKUP_ERROR 0xffffffff +#define JSON_LOOKUP_NOTFOUND 0xfffffffe +#define JSON_LOOKUP_PATHERROR 0xfffffffd +#define JSON_LOOKUP_ISERROR(x) ((x)>=JSON_LOOKUP_PATHERROR) + +/* Forward declaration */ +static u32 jsonLookupStep(JsonParse*,u32,const char*,u32); + + +/* This helper routine for jsonLookupStep() populates pIns with +** binary data that is to be inserted into pParse. +** +** In the common case, pIns just points to pParse->aIns and pParse->nIns. +** But if the zPath of the original edit operation includes path elements +** that go deeper, additional substructure must be created. +** +** For example: +** +** json_insert('{}', '$.a.b.c', 123); +** +** The search stops at '$.a' But additional substructure must be +** created for the ".b.c" part of the patch so that the final result +** is: {"a":{"b":{"c"::123}}}. This routine populates pIns with +** the binary equivalent of {"b":{"c":123}} so that it can be inserted. +** +** The caller is responsible for resetting pIns when it has finished +** using the substructure. +*/ +static u32 jsonCreateEditSubstructure( + JsonParse *pParse, /* The original JSONB that is being edited */ + JsonParse *pIns, /* Populate this with the blob data to insert */ + const char *zTail /* Tail of the path that determins substructure */ +){ + static const u8 emptyObject[] = { JSONB_ARRAY, JSONB_OBJECT }; + int rc; + memset(pIns, 0, sizeof(*pIns)); + pIns->db = pParse->db; + if( zTail[0]==0 ){ + /* No substructure. Just insert what is given in pParse. */ + pIns->aBlob = pParse->aIns; + pIns->nBlob = pParse->nIns; + rc = 0; + }else{ + /* Construct the binary substructure */ + pIns->nBlob = 1; + pIns->aBlob = (u8*)&emptyObject[zTail[0]=='.']; + pIns->eEdit = pParse->eEdit; + pIns->nIns = pParse->nIns; + pIns->aIns = pParse->aIns; + rc = jsonLookupStep(pIns, 0, zTail, 0); + pParse->oom |= pIns->oom; + } + return rc; /* Error code only */ +} + +/* +** Search along zPath to find the Json element specified. Return an +** index into pParse->aBlob[] for the start of that element's value. +** +** If the value found by this routine is the value half of label/value pair +** within an object, then set pPath->iLabel to the start of the corresponding +** label, before returning. +** +** Return one of the JSON_LOOKUP error codes if problems are seen. +** +** This routine will also modify the blob. If pParse->eEdit is one of +** JEDIT_DEL, JEDIT_REPL, JEDIT_INS, or JEDIT_SET, then changes might be +** made to the selected value. If an edit is performed, then the return +** value does not necessarily point to the select element. If an edit +** is performed, the return value is only useful for detecting error +** conditions. +*/ +static u32 jsonLookupStep( + JsonParse *pParse, /* The JSON to search */ + u32 iRoot, /* Begin the search at this element of aBlob[] */ + const char *zPath, /* The path to search */ + u32 iLabel /* Label if iRoot is a value of in an object */ +){ + u32 i, j, k, nKey, sz, n, iEnd, rc; + const char *zKey; + u8 x; + + if( zPath[0]==0 ){ + if( pParse->eEdit && jsonBlobMakeEditable(pParse, pParse->nIns) ){ + n = jsonbPayloadSize(pParse, iRoot, &sz); + sz += n; + if( pParse->eEdit==JEDIT_DEL ){ + if( iLabel>0 ){ + sz += iRoot - iLabel; + iRoot = iLabel; + } + jsonBlobEdit(pParse, iRoot, sz, 0, 0); + }else if( pParse->eEdit==JEDIT_INS ){ + /* Already exists, so json_insert() is a no-op */ + }else{ + /* json_set() or json_replace() */ + jsonBlobEdit(pParse, iRoot, sz, pParse->aIns, pParse->nIns); + } + } + pParse->iLabel = iLabel; + return iRoot; } - if( zPath[0]==0 ) return pRoot; if( zPath[0]=='.' ){ - if( pRoot->eType!=JSON_OBJECT ) return 0; + int rawKey = 1; + x = pParse->aBlob[iRoot]; zPath++; if( zPath[0]=='"' ){ zKey = zPath + 1; @@ -204617,251 +205867,677 @@ static JsonNode *jsonLookupStep( if( zPath[i] ){ i++; }else{ - *pzErr = zPath; - return 0; + return JSON_LOOKUP_PATHERROR; } testcase( nKey==0 ); + rawKey = memchr(zKey, '\\', nKey)==0; }else{ zKey = zPath; for(i=0; zPath[i] && zPath[i]!='.' && zPath[i]!='['; i++){} nKey = i; if( nKey==0 ){ - *pzErr = zPath; - return 0; + return JSON_LOOKUP_PATHERROR; } } - j = 1; - for(;;){ - while( j<=pRoot->n ){ - if( jsonLabelCompare(pRoot+j, zKey, nKey) ){ - return jsonLookupStep(pParse, iRoot+j+1, &zPath[i], pApnd, pzErr); + if( (x & 0x0f)!=JSONB_OBJECT ) return JSON_LOOKUP_NOTFOUND; + n = jsonbPayloadSize(pParse, iRoot, &sz); + j = iRoot + n; /* j is the index of a label */ + iEnd = j+sz; + while( jaBlob[j] & 0x0f; + if( xJSONB_TEXTRAW ) return JSON_LOOKUP_ERROR; + n = jsonbPayloadSize(pParse, j, &sz); + if( n==0 ) return JSON_LOOKUP_ERROR; + k = j+n; /* k is the index of the label text */ + if( k+sz>=iEnd ) return JSON_LOOKUP_ERROR; + zLabel = (const char*)&pParse->aBlob[k]; + rawLabel = x==JSONB_TEXT || x==JSONB_TEXTRAW; + if( jsonLabelCompare(zKey, nKey, rawKey, zLabel, sz, rawLabel) ){ + u32 v = k+sz; /* v is the index of the value */ + if( ((pParse->aBlob[v])&0x0f)>JSONB_OBJECT ) return JSON_LOOKUP_ERROR; + n = jsonbPayloadSize(pParse, v, &sz); + if( n==0 || v+n+sz>iEnd ) return JSON_LOOKUP_ERROR; + assert( j>0 ); + rc = jsonLookupStep(pParse, v, &zPath[i], j); + if( pParse->delta ) jsonAfterEditSizeAdjust(pParse, iRoot); + return rc; + } + j = k+sz; + if( ((pParse->aBlob[j])&0x0f)>JSONB_OBJECT ) return JSON_LOOKUP_ERROR; + n = jsonbPayloadSize(pParse, j, &sz); + if( n==0 ) return JSON_LOOKUP_ERROR; + j += n+sz; + } + if( j>iEnd ) return JSON_LOOKUP_ERROR; + if( pParse->eEdit>=JEDIT_INS ){ + u32 nIns; /* Total bytes to insert (label+value) */ + JsonParse v; /* BLOB encoding of the value to be inserted */ + JsonParse ix; /* Header of the label to be inserted */ + testcase( pParse->eEdit==JEDIT_INS ); + testcase( pParse->eEdit==JEDIT_SET ); + memset(&ix, 0, sizeof(ix)); + ix.db = pParse->db; + jsonBlobAppendNode(&ix, rawKey?JSONB_TEXTRAW:JSONB_TEXT5, nKey, 0); + pParse->oom |= ix.oom; + rc = jsonCreateEditSubstructure(pParse, &v, &zPath[i]); + if( !JSON_LOOKUP_ISERROR(rc) + && jsonBlobMakeEditable(pParse, ix.nBlob+nKey+v.nBlob) + ){ + assert( !pParse->oom ); + nIns = ix.nBlob + nKey + v.nBlob; + jsonBlobEdit(pParse, j, 0, 0, nIns); + if( !pParse->oom ){ + assert( pParse->aBlob!=0 ); /* Because pParse->oom!=0 */ + assert( ix.aBlob!=0 ); /* Because pPasre->oom!=0 */ + memcpy(&pParse->aBlob[j], ix.aBlob, ix.nBlob); + k = j + ix.nBlob; + memcpy(&pParse->aBlob[k], zKey, nKey); + k += nKey; + memcpy(&pParse->aBlob[k], v.aBlob, v.nBlob); + if( ALWAYS(pParse->delta) ) jsonAfterEditSizeAdjust(pParse, iRoot); } - j++; - j += jsonNodeSize(&pRoot[j]); } - if( (pRoot->jnFlags & JNODE_APPEND)==0 ) break; - if( pParse->useMod==0 ) break; - assert( pRoot->eU==2 ); - iRoot = pRoot->u.iAppend; - pRoot = &pParse->aNode[iRoot]; - j = 1; - } - if( pApnd ){ - u32 iStart, iLabel; - JsonNode *pNode; - assert( pParse->useMod ); - iStart = jsonParseAddNode(pParse, JSON_OBJECT, 2, 0); - iLabel = jsonParseAddNode(pParse, JSON_STRING, nKey, zKey); - zPath += i; - pNode = jsonLookupAppend(pParse, zPath, pApnd, pzErr); - if( pParse->oom ) return 0; - if( pNode ){ - pRoot = &pParse->aNode[iRoot]; - assert( pRoot->eU==0 ); - pRoot->u.iAppend = iStart; - pRoot->jnFlags |= JNODE_APPEND; - VVA( pRoot->eU = 2 ); - pParse->aNode[iLabel].jnFlags |= JNODE_RAW; - } - return pNode; + jsonParseReset(&v); + jsonParseReset(&ix); + return rc; } }else if( zPath[0]=='[' ){ - i = 0; - j = 1; - while( sqlite3Isdigit(zPath[j]) ){ - i = i*10 + zPath[j] - '0'; - j++; + x = pParse->aBlob[iRoot] & 0x0f; + if( x!=JSONB_ARRAY ) return JSON_LOOKUP_NOTFOUND; + n = jsonbPayloadSize(pParse, iRoot, &sz); + k = 0; + i = 1; + while( sqlite3Isdigit(zPath[i]) ){ + k = k*10 + zPath[i] - '0'; + i++; } - if( j<2 || zPath[j]!=']' ){ + if( i<2 || zPath[i]!=']' ){ if( zPath[1]=='#' ){ - JsonNode *pBase = pRoot; - int iBase = iRoot; - if( pRoot->eType!=JSON_ARRAY ) return 0; - for(;;){ - while( j<=pBase->n ){ - if( (pBase[j].jnFlags & JNODE_REMOVE)==0 || pParse->useMod==0 ) i++; - j += jsonNodeSize(&pBase[j]); - } - if( (pBase->jnFlags & JNODE_APPEND)==0 ) break; - if( pParse->useMod==0 ) break; - assert( pBase->eU==2 ); - iBase = pBase->u.iAppend; - pBase = &pParse->aNode[iBase]; - j = 1; - } - j = 2; + k = jsonbArrayCount(pParse, iRoot); + i = 2; if( zPath[2]=='-' && sqlite3Isdigit(zPath[3]) ){ - unsigned int x = 0; - j = 3; + unsigned int nn = 0; + i = 3; do{ - x = x*10 + zPath[j] - '0'; - j++; - }while( sqlite3Isdigit(zPath[j]) ); - if( x>i ) return 0; - i -= x; + nn = nn*10 + zPath[i] - '0'; + i++; + }while( sqlite3Isdigit(zPath[i]) ); + if( nn>k ) return JSON_LOOKUP_NOTFOUND; + k -= nn; } - if( zPath[j]!=']' ){ - *pzErr = zPath; - return 0; + if( zPath[i]!=']' ){ + return JSON_LOOKUP_PATHERROR; } }else{ - *pzErr = zPath; - return 0; + return JSON_LOOKUP_PATHERROR; } } - if( pRoot->eType!=JSON_ARRAY ) return 0; - zPath += j + 1; - j = 1; - for(;;){ - while( j<=pRoot->n - && (i>0 || ((pRoot[j].jnFlags & JNODE_REMOVE)!=0 && pParse->useMod)) + j = iRoot+n; + iEnd = j+sz; + while( jdelta ) jsonAfterEditSizeAdjust(pParse, iRoot); + return rc; + } + k--; + n = jsonbPayloadSize(pParse, j, &sz); + if( n==0 ) return JSON_LOOKUP_ERROR; + j += n+sz; + } + if( j>iEnd ) return JSON_LOOKUP_ERROR; + if( k>0 ) return JSON_LOOKUP_NOTFOUND; + if( pParse->eEdit>=JEDIT_INS ){ + JsonParse v; + testcase( pParse->eEdit==JEDIT_INS ); + testcase( pParse->eEdit==JEDIT_SET ); + rc = jsonCreateEditSubstructure(pParse, &v, &zPath[i+1]); + if( !JSON_LOOKUP_ISERROR(rc) + && jsonBlobMakeEditable(pParse, v.nBlob) ){ - if( (pRoot[j].jnFlags & JNODE_REMOVE)==0 || pParse->useMod==0 ) i--; - j += jsonNodeSize(&pRoot[j]); + assert( !pParse->oom ); + jsonBlobEdit(pParse, j, 0, v.aBlob, v.nBlob); } - if( i==0 && j<=pRoot->n ) break; - if( (pRoot->jnFlags & JNODE_APPEND)==0 ) break; - if( pParse->useMod==0 ) break; - assert( pRoot->eU==2 ); - iRoot = pRoot->u.iAppend; - pRoot = &pParse->aNode[iRoot]; - j = 1; - } - if( j<=pRoot->n ){ - return jsonLookupStep(pParse, iRoot+j, zPath, pApnd, pzErr); - } - if( i==0 && pApnd ){ - u32 iStart; - JsonNode *pNode; - assert( pParse->useMod ); - iStart = jsonParseAddNode(pParse, JSON_ARRAY, 1, 0); - pNode = jsonLookupAppend(pParse, zPath, pApnd, pzErr); - if( pParse->oom ) return 0; - if( pNode ){ - pRoot = &pParse->aNode[iRoot]; - assert( pRoot->eU==0 ); - pRoot->u.iAppend = iStart; - pRoot->jnFlags |= JNODE_APPEND; - VVA( pRoot->eU = 2 ); - } - return pNode; + jsonParseReset(&v); + if( pParse->delta ) jsonAfterEditSizeAdjust(pParse, iRoot); + return rc; } }else{ - *pzErr = zPath; + return JSON_LOOKUP_PATHERROR; } - return 0; + return JSON_LOOKUP_NOTFOUND; } /* -** Append content to pParse that will complete zPath. Return a pointer -** to the inserted node, or return NULL if the append fails. +** Convert a JSON BLOB into text and make that text the return value +** of an SQL function. */ -static JsonNode *jsonLookupAppend( - JsonParse *pParse, /* Append content to the JSON parse */ - const char *zPath, /* Description of content to append */ - int *pApnd, /* Set this flag to 1 */ - const char **pzErr /* Make this point to any syntax error */ +static void jsonReturnTextJsonFromBlob( + sqlite3_context *ctx, + const u8 *aBlob, + u32 nBlob ){ - *pApnd = 1; - if( zPath[0]==0 ){ - jsonParseAddNode(pParse, JSON_NULL, 0, 0); - return pParse->oom ? 0 : &pParse->aNode[pParse->nNode-1]; + JsonParse x; + JsonString s; + + if( NEVER(aBlob==0) ) return; + memset(&x, 0, sizeof(x)); + x.aBlob = (u8*)aBlob; + x.nBlob = nBlob; + jsonStringInit(&s, ctx); + jsonTranslateBlobToText(&x, 0, &s); + jsonReturnString(&s, 0, 0); +} + + +/* +** Return the value of the BLOB node at index i. +** +** If the value is a primitive, return it as an SQL value. +** If the value is an array or object, return it as either +** JSON text or the BLOB encoding, depending on the JSON_B flag +** on the userdata. +*/ +static void jsonReturnFromBlob( + JsonParse *pParse, /* Complete JSON parse tree */ + u32 i, /* Index of the node */ + sqlite3_context *pCtx, /* Return value for this function */ + int textOnly /* return text JSON. Disregard user-data */ +){ + u32 n, sz; + int rc; + sqlite3 *db = sqlite3_context_db_handle(pCtx); + + n = jsonbPayloadSize(pParse, i, &sz); + if( n==0 ){ + sqlite3_result_error(pCtx, "malformed JSON", -1); + return; } - if( zPath[0]=='.' ){ - jsonParseAddNode(pParse, JSON_OBJECT, 0, 0); - }else if( strncmp(zPath,"[0]",3)==0 ){ - jsonParseAddNode(pParse, JSON_ARRAY, 0, 0); + switch( pParse->aBlob[i] & 0x0f ){ + case JSONB_NULL: { + if( sz ) goto returnfromblob_malformed; + sqlite3_result_null(pCtx); + break; + } + case JSONB_TRUE: { + if( sz ) goto returnfromblob_malformed; + sqlite3_result_int(pCtx, 1); + break; + } + case JSONB_FALSE: { + if( sz ) goto returnfromblob_malformed; + sqlite3_result_int(pCtx, 0); + break; + } + case JSONB_INT5: + case JSONB_INT: { + sqlite3_int64 iRes = 0; + char *z; + int bNeg = 0; + char x; + if( sz==0 ) goto returnfromblob_malformed; + x = (char)pParse->aBlob[i+n]; + if( x=='-' ){ + if( sz<2 ) goto returnfromblob_malformed; + n++; + sz--; + bNeg = 1; + } + z = sqlite3DbStrNDup(db, (const char*)&pParse->aBlob[i+n], (int)sz); + if( z==0 ) goto returnfromblob_oom; + rc = sqlite3DecOrHexToI64(z, &iRes); + sqlite3DbFree(db, z); + if( rc==0 ){ + sqlite3_result_int64(pCtx, bNeg ? -iRes : iRes); + }else if( rc==3 && bNeg ){ + sqlite3_result_int64(pCtx, SMALLEST_INT64); + }else if( rc==1 ){ + goto returnfromblob_malformed; + }else{ + if( bNeg ){ n--; sz++; } + goto to_double; + } + break; + } + case JSONB_FLOAT5: + case JSONB_FLOAT: { + double r; + char *z; + if( sz==0 ) goto returnfromblob_malformed; + to_double: + z = sqlite3DbStrNDup(db, (const char*)&pParse->aBlob[i+n], (int)sz); + if( z==0 ) goto returnfromblob_oom; + rc = sqlite3AtoF(z, &r, sqlite3Strlen30(z), SQLITE_UTF8); + sqlite3DbFree(db, z); + if( rc<=0 ) goto returnfromblob_malformed; + sqlite3_result_double(pCtx, r); + break; + } + case JSONB_TEXTRAW: + case JSONB_TEXT: { + sqlite3_result_text(pCtx, (char*)&pParse->aBlob[i+n], sz, + SQLITE_TRANSIENT); + break; + } + case JSONB_TEXT5: + case JSONB_TEXTJ: { + /* Translate JSON formatted string into raw text */ + u32 iIn, iOut; + const char *z; + char *zOut; + u32 nOut = sz; + z = (const char*)&pParse->aBlob[i+n]; + zOut = sqlite3DbMallocRaw(db, nOut+1); + if( zOut==0 ) goto returnfromblob_oom; + for(iIn=iOut=0; iIn=2 ); + zOut[iOut++] = (char)(0xc0 | (v>>6)); + zOut[iOut++] = 0x80 | (v&0x3f); + }else if( v<0x10000 ){ + assert( szEscape>=3 ); + zOut[iOut++] = 0xe0 | (v>>12); + zOut[iOut++] = 0x80 | ((v>>6)&0x3f); + zOut[iOut++] = 0x80 | (v&0x3f); + }else if( v==JSON_INVALID_CHAR ){ + /* Silently ignore illegal unicode */ + }else{ + assert( szEscape>=4 ); + zOut[iOut++] = 0xf0 | (v>>18); + zOut[iOut++] = 0x80 | ((v>>12)&0x3f); + zOut[iOut++] = 0x80 | ((v>>6)&0x3f); + zOut[iOut++] = 0x80 | (v&0x3f); + } + iIn += szEscape - 1; + }else{ + zOut[iOut++] = c; + } + } /* end for() */ + assert( iOut<=nOut ); + zOut[iOut] = 0; + sqlite3_result_text(pCtx, zOut, iOut, SQLITE_DYNAMIC); + break; + } + case JSONB_ARRAY: + case JSONB_OBJECT: { + int flags = textOnly ? 0 : SQLITE_PTR_TO_INT(sqlite3_user_data(pCtx)); + if( flags & JSON_BLOB ){ + sqlite3_result_blob(pCtx, &pParse->aBlob[i], sz+n, SQLITE_TRANSIENT); + }else{ + jsonReturnTextJsonFromBlob(pCtx, &pParse->aBlob[i], sz+n); + } + break; + } + default: { + goto returnfromblob_malformed; + } + } + return; + +returnfromblob_oom: + sqlite3_result_error_nomem(pCtx); + return; + +returnfromblob_malformed: + sqlite3_result_error(pCtx, "malformed JSON", -1); + return; +} + +/* +** pArg is a function argument that might be an SQL value or a JSON +** value. Figure out what it is and encode it as a JSONB blob. +** Return the results in pParse. +** +** pParse is uninitialized upon entry. This routine will handle the +** initialization of pParse. The result will be contained in +** pParse->aBlob and pParse->nBlob. pParse->aBlob might be dynamically +** allocated (if pParse->nBlobAlloc is greater than zero) in which case +** the caller is responsible for freeing the space allocated to pParse->aBlob +** when it has finished with it. Or pParse->aBlob might be a static string +** or a value obtained from sqlite3_value_blob(pArg). +** +** If the argument is a BLOB that is clearly not a JSONB, then this +** function might set an error message in ctx and return non-zero. +** It might also set an error message and return non-zero on an OOM error. +*/ +static int jsonFunctionArgToBlob( + sqlite3_context *ctx, + sqlite3_value *pArg, + JsonParse *pParse +){ + int eType = sqlite3_value_type(pArg); + static u8 aNull[] = { 0x00 }; + memset(pParse, 0, sizeof(pParse[0])); + pParse->db = sqlite3_context_db_handle(ctx); + switch( eType ){ + default: { + pParse->aBlob = aNull; + pParse->nBlob = 1; + return 0; + } + case SQLITE_BLOB: { + if( jsonFuncArgMightBeBinary(pArg) ){ + pParse->aBlob = (u8*)sqlite3_value_blob(pArg); + pParse->nBlob = sqlite3_value_bytes(pArg); + }else{ + sqlite3_result_error(ctx, "JSON cannot hold BLOB values", -1); + return 1; + } + break; + } + case SQLITE_TEXT: { + const char *zJson = (const char*)sqlite3_value_text(pArg); + int nJson = sqlite3_value_bytes(pArg); + if( zJson==0 ) return 1; + if( sqlite3_value_subtype(pArg)==JSON_SUBTYPE ){ + pParse->zJson = (char*)zJson; + pParse->nJson = nJson; + if( jsonConvertTextToBlob(pParse, ctx) ){ + sqlite3_result_error(ctx, "malformed JSON", -1); + sqlite3DbFree(pParse->db, pParse->aBlob); + memset(pParse, 0, sizeof(pParse[0])); + return 1; + } + }else{ + jsonBlobAppendNode(pParse, JSONB_TEXTRAW, nJson, zJson); + } + break; + } + case SQLITE_FLOAT: { + double r = sqlite3_value_double(pArg); + if( NEVER(sqlite3IsNaN(r)) ){ + jsonBlobAppendNode(pParse, JSONB_NULL, 0, 0); + }else{ + int n = sqlite3_value_bytes(pArg); + const char *z = (const char*)sqlite3_value_text(pArg); + if( z==0 ) return 1; + if( z[0]=='I' ){ + jsonBlobAppendNode(pParse, JSONB_FLOAT, 5, "9e999"); + }else if( z[0]=='-' && z[1]=='I' ){ + jsonBlobAppendNode(pParse, JSONB_FLOAT, 6, "-9e999"); + }else{ + jsonBlobAppendNode(pParse, JSONB_FLOAT, n, z); + } + } + break; + } + case SQLITE_INTEGER: { + int n = sqlite3_value_bytes(pArg); + const char *z = (const char*)sqlite3_value_text(pArg); + if( z==0 ) return 1; + jsonBlobAppendNode(pParse, JSONB_INT, n, z); + break; + } + } + if( pParse->oom ){ + sqlite3_result_error_nomem(ctx); + return 1; }else{ return 0; } - if( pParse->oom ) return 0; - return jsonLookupStep(pParse, pParse->nNode-1, zPath, pApnd, pzErr); } /* -** Return the text of a syntax error message on a JSON path. Space is -** obtained from sqlite3_malloc(). -*/ -static char *jsonPathSyntaxError(const char *zErr){ - return sqlite3_mprintf("JSON path error near '%q'", zErr); -} - -/* -** Do a node lookup using zPath. Return a pointer to the node on success. -** Return NULL if not found or if there is an error. +** Generate a bad path error. ** -** On an error, write an error message into pCtx and increment the -** pParse->nErr counter. -** -** If pApnd!=NULL then try to append missing nodes and set *pApnd = 1 if -** nodes are appended. +** If ctx is not NULL then push the error message into ctx and return NULL. +** If ctx is NULL, then return the text of the error message. */ -static JsonNode *jsonLookup( - JsonParse *pParse, /* The JSON to search */ - const char *zPath, /* The path to search */ - int *pApnd, /* Append nodes to complete path if not NULL */ - sqlite3_context *pCtx /* Report errors here, if not NULL */ +static char *jsonBadPathError( + sqlite3_context *ctx, /* The function call containing the error */ + const char *zPath /* The path with the problem */ ){ - const char *zErr = 0; - JsonNode *pNode = 0; - char *zMsg; - - if( zPath==0 ) return 0; - if( zPath[0]!='$' ){ - zErr = zPath; - goto lookup_err; - } - zPath++; - pNode = jsonLookupStep(pParse, 0, zPath, pApnd, &zErr); - if( zErr==0 ) return pNode; - -lookup_err: - pParse->nErr++; - assert( zErr!=0 && pCtx!=0 ); - zMsg = jsonPathSyntaxError(zErr); + char *zMsg = sqlite3_mprintf("bad JSON path: %Q", zPath); + if( ctx==0 ) return zMsg; if( zMsg ){ - sqlite3_result_error(pCtx, zMsg, -1); + sqlite3_result_error(ctx, zMsg, -1); sqlite3_free(zMsg); }else{ - sqlite3_result_error_nomem(pCtx); + sqlite3_result_error_nomem(ctx); } return 0; } - -/* -** Report the wrong number of arguments for json_insert(), json_replace() -** or json_set(). +/* argv[0] is a BLOB that seems likely to be a JSONB. Subsequent +** arguments come in parse where each pair contains a JSON path and +** content to insert or set at that patch. Do the updates +** and return the result. +** +** The specific operation is determined by eEdit, which can be one +** of JEDIT_INS, JEDIT_REPL, or JEDIT_SET. */ -static void jsonWrongNumArgs( - sqlite3_context *pCtx, - const char *zFuncName +static void jsonInsertIntoBlob( + sqlite3_context *ctx, + int argc, + sqlite3_value **argv, + int eEdit /* JEDIT_INS, JEDIT_REPL, or JEDIT_SET */ ){ - char *zMsg = sqlite3_mprintf("json_%s() needs an odd number of arguments", - zFuncName); - sqlite3_result_error(pCtx, zMsg, -1); - sqlite3_free(zMsg); + int i; + u32 rc = 0; + const char *zPath = 0; + int flgs; + JsonParse *p; + JsonParse ax; + + assert( (argc&1)==1 ); + flgs = argc==1 ? 0 : JSON_EDITABLE; + p = jsonParseFuncArg(ctx, argv[0], flgs); + if( p==0 ) return; + for(i=1; inBlob, ax.aBlob, ax.nBlob); + } + rc = 0; + }else{ + p->eEdit = eEdit; + p->nIns = ax.nBlob; + p->aIns = ax.aBlob; + p->delta = 0; + rc = jsonLookupStep(p, 0, zPath+1, 0); + } + jsonParseReset(&ax); + if( rc==JSON_LOOKUP_NOTFOUND ) continue; + if( JSON_LOOKUP_ISERROR(rc) ) goto jsonInsertIntoBlob_patherror; + } + jsonReturnParse(ctx, p); + jsonParseFree(p); + return; + +jsonInsertIntoBlob_patherror: + jsonParseFree(p); + if( rc==JSON_LOOKUP_ERROR ){ + sqlite3_result_error(ctx, "malformed JSON", -1); + }else{ + jsonBadPathError(ctx, zPath); + } + return; } /* -** Mark all NULL entries in the Object passed in as JNODE_REMOVE. +** Generate a JsonParse object, containing valid JSONB in aBlob and nBlob, +** from the SQL function argument pArg. Return a pointer to the new +** JsonParse object. +** +** Ownership of the new JsonParse object is passed to the caller. The +** caller should invoke jsonParseFree() on the return value when it +** has finished using it. +** +** If any errors are detected, an appropriate error messages is set +** using sqlite3_result_error() or the equivalent and this routine +** returns NULL. This routine also returns NULL if the pArg argument +** is an SQL NULL value, but no error message is set in that case. This +** is so that SQL functions that are given NULL arguments will return +** a NULL value. */ -static void jsonRemoveAllNulls(JsonNode *pNode){ - int i, n; - assert( pNode->eType==JSON_OBJECT ); - n = pNode->n; - for(i=2; i<=n; i += jsonNodeSize(&pNode[i])+1){ - switch( pNode[i].eType ){ - case JSON_NULL: - pNode[i].jnFlags |= JNODE_REMOVE; - break; - case JSON_OBJECT: - jsonRemoveAllNulls(&pNode[i]); - break; +static JsonParse *jsonParseFuncArg( + sqlite3_context *ctx, + sqlite3_value *pArg, + u32 flgs +){ + int eType; /* Datatype of pArg */ + JsonParse *p = 0; /* Value to be returned */ + JsonParse *pFromCache = 0; /* Value taken from cache */ + sqlite3 *db; /* The database connection */ + + assert( ctx!=0 ); + eType = sqlite3_value_type(pArg); + if( eType==SQLITE_NULL ){ + return 0; + } + pFromCache = jsonCacheSearch(ctx, pArg); + if( pFromCache ){ + pFromCache->nJPRef++; + if( (flgs & JSON_EDITABLE)==0 ){ + return pFromCache; } } + db = sqlite3_context_db_handle(ctx); +rebuild_from_cache: + p = sqlite3DbMallocZero(db, sizeof(*p)); + if( p==0 ) goto json_pfa_oom; + memset(p, 0, sizeof(*p)); + p->db = db; + p->nJPRef = 1; + if( pFromCache!=0 ){ + u32 nBlob = pFromCache->nBlob; + p->aBlob = sqlite3DbMallocRaw(db, nBlob); + if( p->aBlob==0 ) goto json_pfa_oom; + memcpy(p->aBlob, pFromCache->aBlob, nBlob); + p->nBlobAlloc = p->nBlob = nBlob; + p->hasNonstd = pFromCache->hasNonstd; + jsonParseFree(pFromCache); + return p; + } + if( eType==SQLITE_BLOB ){ + u32 n, sz = 0; + p->aBlob = (u8*)sqlite3_value_blob(pArg); + p->nBlob = (u32)sqlite3_value_bytes(pArg); + if( p->nBlob==0 ){ + goto json_pfa_malformed; + } + if( NEVER(p->aBlob==0) ){ + goto json_pfa_oom; + } + if( (p->aBlob[0] & 0x0f)>JSONB_OBJECT ){ + goto json_pfa_malformed; + } + n = jsonbPayloadSize(p, 0, &sz); + if( n==0 + || sz+n!=p->nBlob + || ((p->aBlob[0] & 0x0f)<=JSONB_FALSE && sz>0) + ){ + goto json_pfa_malformed; + } + if( (flgs & JSON_EDITABLE)!=0 && jsonBlobMakeEditable(p, 0)==0 ){ + goto json_pfa_oom; + } + return p; + } + p->zJson = (char*)sqlite3_value_text(pArg); + p->nJson = sqlite3_value_bytes(pArg); + if( p->nJson==0 ) goto json_pfa_malformed; + if( NEVER(p->zJson==0) ) goto json_pfa_oom; + if( jsonConvertTextToBlob(p, (flgs & JSON_KEEPERROR) ? 0 : ctx) ){ + if( flgs & JSON_KEEPERROR ){ + p->nErr = 1; + return p; + }else{ + jsonParseFree(p); + return 0; + } + }else{ + int isRCStr = sqlite3ValueIsOfClass(pArg, sqlite3RCStrUnref); + int rc; + if( !isRCStr ){ + char *zNew = sqlite3RCStrNew( p->nJson ); + if( zNew==0 ) goto json_pfa_oom; + memcpy(zNew, p->zJson, p->nJson); + p->zJson = zNew; + p->zJson[p->nJson] = 0; + }else{ + sqlite3RCStrRef(p->zJson); + } + p->bJsonIsRCStr = 1; + rc = jsonCacheInsert(ctx, p); + if( rc==SQLITE_NOMEM ) goto json_pfa_oom; + if( flgs & JSON_EDITABLE ){ + pFromCache = p; + p = 0; + goto rebuild_from_cache; + } + } + return p; + +json_pfa_malformed: + if( flgs & JSON_KEEPERROR ){ + p->nErr = 1; + return p; + }else{ + jsonParseFree(p); + sqlite3_result_error(ctx, "malformed JSON", -1); + return 0; + } + +json_pfa_oom: + jsonParseFree(pFromCache); + jsonParseFree(p); + sqlite3_result_error_nomem(ctx); + return 0; } +/* +** Make the return value of a JSON function either the raw JSONB blob +** or make it JSON text, depending on whether the JSON_BLOB flag is +** set on the function. +*/ +static void jsonReturnParse( + sqlite3_context *ctx, + JsonParse *p +){ + int flgs; + if( p->oom ){ + sqlite3_result_error_nomem(ctx); + return; + } + flgs = SQLITE_PTR_TO_INT(sqlite3_user_data(ctx)); + if( flgs & JSON_BLOB ){ + if( p->nBlobAlloc>0 && !p->bReadOnly ){ + sqlite3_result_blob(ctx, p->aBlob, p->nBlob, SQLITE_DYNAMIC); + p->nBlobAlloc = 0; + }else{ + sqlite3_result_blob(ctx, p->aBlob, p->nBlob, SQLITE_TRANSIENT); + } + }else{ + JsonString s; + jsonStringInit(&s, ctx); + p->delta = 0; + jsonTranslateBlobToText(p, 0, &s); + jsonReturnString(&s, p, ctx); + sqlite3_result_subtype(ctx, JSON_SUBTYPE); + } +} /**************************************************************************** ** SQL functions used for testing and debugging @@ -204869,63 +206545,124 @@ static void jsonRemoveAllNulls(JsonNode *pNode){ #if SQLITE_DEBUG /* -** Print N node entries. +** Decode JSONB bytes in aBlob[] starting at iStart through but not +** including iEnd. Indent the +** content by nIndent spaces. */ -static void jsonDebugPrintNodeEntries( - JsonNode *aNode, /* First node entry to print */ - int N /* Number of node entries to print */ +static void jsonDebugPrintBlob( + JsonParse *pParse, /* JSON content */ + u32 iStart, /* Start rendering here */ + u32 iEnd, /* Do not render this byte or any byte after this one */ + int nIndent, /* Indent by this many spaces */ + sqlite3_str *pOut /* Generate output into this sqlite3_str object */ ){ - int i; - for(i=0; iaBlob[iStart] & 0x0f; + u32 savedNBlob = pParse->nBlob; + sqlite3_str_appendf(pOut, "%5d:%*s", iStart, nIndent, ""); + if( pParse->nBlobAlloc>pParse->nBlob ){ + pParse->nBlob = pParse->nBlobAlloc; } - printf("node %4u: %-7s n=%-5d", i, zType, aNode[i].n); - if( (aNode[i].jnFlags & ~JNODE_LABEL)!=0 ){ - u8 f = aNode[i].jnFlags; - if( f & JNODE_RAW ) printf(" RAW"); - if( f & JNODE_ESCAPE ) printf(" ESCAPE"); - if( f & JNODE_REMOVE ) printf(" REMOVE"); - if( f & JNODE_REPLACE ) printf(" REPLACE"); - if( f & JNODE_APPEND ) printf(" APPEND"); - if( f & JNODE_JSON5 ) printf(" JSON5"); + nn = n = jsonbPayloadSize(pParse, iStart, &sz); + if( nn==0 ) nn = 1; + if( sz>0 && xaBlob[iStart+i]); } + if( n==0 ){ + sqlite3_str_appendf(pOut, " ERROR invalid node size\n"); + iStart = n==0 ? iStart+1 : iEnd; + continue; + } + pParse->nBlob = savedNBlob; + if( iStart+n+sz>iEnd ){ + iEnd = iStart+n+sz; + if( iEnd>pParse->nBlob ){ + if( pParse->nBlobAlloc>0 && iEnd>pParse->nBlobAlloc ){ + iEnd = pParse->nBlobAlloc; + }else{ + iEnd = pParse->nBlob; + } + } + } + sqlite3_str_appendall(pOut," <-- "); + switch( x ){ + case JSONB_NULL: sqlite3_str_appendall(pOut,"null"); break; + case JSONB_TRUE: sqlite3_str_appendall(pOut,"true"); break; + case JSONB_FALSE: sqlite3_str_appendall(pOut,"false"); break; + case JSONB_INT: sqlite3_str_appendall(pOut,"int"); break; + case JSONB_INT5: sqlite3_str_appendall(pOut,"int5"); break; + case JSONB_FLOAT: sqlite3_str_appendall(pOut,"float"); break; + case JSONB_FLOAT5: sqlite3_str_appendall(pOut,"float5"); break; + case JSONB_TEXT: sqlite3_str_appendall(pOut,"text"); break; + case JSONB_TEXTJ: sqlite3_str_appendall(pOut,"textj"); break; + case JSONB_TEXT5: sqlite3_str_appendall(pOut,"text5"); break; + case JSONB_TEXTRAW: sqlite3_str_appendall(pOut,"textraw"); break; + case JSONB_ARRAY: { + sqlite3_str_appendf(pOut,"array, %u bytes\n", sz); + jsonDebugPrintBlob(pParse, iStart+n, iStart+n+sz, nIndent+2, pOut); + showContent = 0; + break; + } + case JSONB_OBJECT: { + sqlite3_str_appendf(pOut, "object, %u bytes\n", sz); + jsonDebugPrintBlob(pParse, iStart+n, iStart+n+sz, nIndent+2, pOut); + showContent = 0; + break; + } + default: { + sqlite3_str_appendall(pOut, "ERROR: unknown node type\n"); + showContent = 0; + break; + } + } + if( showContent ){ + if( sz==0 && x<=JSONB_FALSE ){ + sqlite3_str_append(pOut, "\n", 1); + }else{ + u32 i; + sqlite3_str_appendall(pOut, ": \""); + for(i=iStart+n; iaBlob[i]; + if( c<0x20 || c>=0x7f ) c = '.'; + sqlite3_str_append(pOut, (char*)&c, 1); + } + sqlite3_str_append(pOut, "\"\n", 2); + } + } + iStart += n + sz; } } +static void jsonShowParse(JsonParse *pParse){ + sqlite3_str out; + char zBuf[1000]; + if( pParse==0 ){ + printf("NULL pointer\n"); + return; + }else{ + printf("nBlobAlloc = %u\n", pParse->nBlobAlloc); + printf("nBlob = %u\n", pParse->nBlob); + printf("delta = %d\n", pParse->delta); + if( pParse->nBlob==0 ) return; + printf("content (bytes 0..%u):\n", pParse->nBlob-1); + } + sqlite3StrAccumInit(&out, 0, zBuf, sizeof(zBuf), 1000000); + jsonDebugPrintBlob(pParse, 0, pParse->nBlob, 0, &out); + printf("%s", sqlite3_str_value(&out)); + sqlite3_str_reset(&out); +} #endif /* SQLITE_DEBUG */ - -#if 0 /* 1 for debugging. 0 normally. Requires -DSQLITE_DEBUG too */ -static void jsonDebugPrintParse(JsonParse *p){ - jsonDebugPrintNodeEntries(p->aNode, p->nNode); -} -static void jsonDebugPrintNode(JsonNode *pNode){ - jsonDebugPrintNodeEntries(pNode, jsonNodeSize(pNode)); -} -#else - /* The usual case */ -# define jsonDebugPrintNode(X) -# define jsonDebugPrintParse(X) -#endif - #ifdef SQLITE_DEBUG /* ** SQL function: json_parse(JSON) ** -** Parse JSON using jsonParseCached(). Then print a dump of that -** parse on standard output. Return the mimified JSON result, just -** like the json() function. +** Parse JSON using jsonParseFuncArg(). Return text that is a +** human-readable dump of the binary JSONB for the input parameter. */ static void jsonParseFunc( sqlite3_context *ctx, @@ -204933,38 +206670,19 @@ static void jsonParseFunc( sqlite3_value **argv ){ JsonParse *p; /* The parse */ + sqlite3_str out; - assert( argc==1 ); - p = jsonParseCached(ctx, argv[0], ctx, 0); + assert( argc>=1 ); + sqlite3StrAccumInit(&out, 0, 0, 0, 1000000); + p = jsonParseFuncArg(ctx, argv[0], 0); if( p==0 ) return; - printf("nNode = %u\n", p->nNode); - printf("nAlloc = %u\n", p->nAlloc); - printf("nJson = %d\n", p->nJson); - printf("nAlt = %d\n", p->nAlt); - printf("nErr = %u\n", p->nErr); - printf("oom = %u\n", p->oom); - printf("hasNonstd = %u\n", p->hasNonstd); - printf("useMod = %u\n", p->useMod); - printf("hasMod = %u\n", p->hasMod); - printf("nJPRef = %u\n", p->nJPRef); - printf("iSubst = %u\n", p->iSubst); - printf("iHold = %u\n", p->iHold); - jsonDebugPrintNodeEntries(p->aNode, p->nNode); - jsonReturnJson(p, p->aNode, ctx, 1); -} - -/* -** The json_test1(JSON) function return true (1) if the input is JSON -** text generated by another json function. It returns (0) if the input -** is not known to be JSON. -*/ -static void jsonTest1Func( - sqlite3_context *ctx, - int argc, - sqlite3_value **argv -){ - UNUSED_PARAMETER(argc); - sqlite3_result_int(ctx, sqlite3_value_subtype(argv[0])==JSON_SUBTYPE); + if( argc==1 ){ + jsonDebugPrintBlob(p, 0, p->nBlob, 0, &out); + sqlite3_result_text64(ctx, out.zText, out.nChar, SQLITE_DYNAMIC, SQLITE_UTF8); + }else{ + jsonShowParse(p); + } + jsonParseFree(p); } #endif /* SQLITE_DEBUG */ @@ -204973,7 +206691,7 @@ static void jsonTest1Func( ****************************************************************************/ /* -** Implementation of the json_QUOTE(VALUE) function. Return a JSON value +** Implementation of the json_quote(VALUE) function. Return a JSON value ** corresponding to the SQL value input. Mostly this means putting ** double-quotes around strings and returning the unquoted string "null" ** when given a NULL input. @@ -204986,9 +206704,9 @@ static void jsonQuoteFunc( JsonString jx; UNUSED_PARAMETER(argc); - jsonInit(&jx, ctx); - jsonAppendValue(&jx, argv[0]); - jsonResult(&jx); + jsonStringInit(&jx, ctx); + jsonAppendSqlValue(&jx, argv[0]); + jsonReturnString(&jx, 0, 0); sqlite3_result_subtype(ctx, JSON_SUBTYPE); } @@ -205005,18 +206723,17 @@ static void jsonArrayFunc( int i; JsonString jx; - jsonInit(&jx, ctx); + jsonStringInit(&jx, ctx); jsonAppendChar(&jx, '['); for(i=0; inNode ); if( argc==2 ){ const char *zPath = (const char*)sqlite3_value_text(argv[1]); - pNode = jsonLookup(p, zPath, 0, ctx); - }else{ - pNode = p->aNode; - } - if( pNode==0 ){ - return; - } - if( pNode->eType==JSON_ARRAY ){ - while( 1 /*exit-by-break*/ ){ - i = 1; - while( i<=pNode->n ){ - if( (pNode[i].jnFlags & JNODE_REMOVE)==0 ) n++; - i += jsonNodeSize(&pNode[i]); - } - if( (pNode->jnFlags & JNODE_APPEND)==0 ) break; - if( p->useMod==0 ) break; - assert( pNode->eU==2 ); - pNode = &p->aNode[pNode->u.iAppend]; + if( zPath==0 ){ + jsonParseFree(p); + return; } + i = jsonLookupStep(p, 0, zPath[0]=='$' ? zPath+1 : "@", 0); + if( JSON_LOOKUP_ISERROR(i) ){ + if( i==JSON_LOOKUP_NOTFOUND ){ + /* no-op */ + }else if( i==JSON_LOOKUP_PATHERROR ){ + jsonBadPathError(ctx, zPath); + }else{ + sqlite3_result_error(ctx, "malformed JSON", -1); + } + eErr = 1; + i = 0; + } + }else{ + i = 0; } - sqlite3_result_int64(ctx, n); + if( (p->aBlob[i] & 0x0f)==JSONB_ARRAY ){ + cnt = jsonbArrayCount(p, i); + } + if( !eErr ) sqlite3_result_int64(ctx, cnt); + jsonParseFree(p); } -/* -** Bit values for the flags passed into jsonExtractFunc() or -** jsonSetFunc() via the user-data value. -*/ -#define JSON_JSON 0x01 /* Result is always JSON */ -#define JSON_SQL 0x02 /* Result is always SQL */ -#define JSON_ABPATH 0x03 /* Allow abbreviated JSON path specs */ -#define JSON_ISSET 0x04 /* json_set(), not json_insert() */ +/* True if the string is all digits */ +static int jsonAllDigits(const char *z, int n){ + int i; + for(i=0; i and ->> operators accept abbreviated PATH arguments. This - ** is mostly for compatibility with PostgreSQL, but also for - ** convenience. - ** - ** NUMBER ==> $[NUMBER] // PG compatible - ** LABEL ==> $.LABEL // PG compatible - ** [NUMBER] ==> $[NUMBER] // Not PG. Purely for convenience - */ - jsonInit(&jx, ctx); - if( sqlite3Isdigit(zPath[0]) ){ - jsonAppendRawNZ(&jx, "$[", 2); - jsonAppendRaw(&jx, zPath, (int)strlen(zPath)); - jsonAppendRawNZ(&jx, "]", 2); - }else{ - jsonAppendRawNZ(&jx, "$.", 1 + (zPath[0]!='[')); - jsonAppendRaw(&jx, zPath, (int)strlen(zPath)); - jsonAppendChar(&jx, 0); - } - pNode = jx.bErr ? 0 : jsonLookup(p, jx.zBuf, 0, ctx); - jsonReset(&jx); - }else{ - pNode = jsonLookup(p, zPath, 0, ctx); - } - if( pNode ){ - if( flags & JSON_JSON ){ - jsonReturnJson(p, pNode, ctx, 0); - }else{ - jsonReturn(p, pNode, ctx); - sqlite3_result_subtype(ctx, 0); - } - } - }else{ - pNode = jsonLookup(p, zPath, 0, ctx); - if( p->nErr==0 && pNode ) jsonReturn(p, pNode, ctx); - } - }else{ - /* Two or more PATH arguments results in a JSON array with each - ** element of the array being the value selected by one of the PATHs */ - int i; - jsonInit(&jx, ctx); + flags = SQLITE_PTR_TO_INT(sqlite3_user_data(ctx)); + jsonStringInit(&jx, ctx); + if( argc>2 ){ jsonAppendChar(&jx, '['); - for(i=1; inErr ) break; - jsonAppendSeparator(&jx); - if( pNode ){ - jsonRenderNode(p, pNode, &jx); + } + for(i=1; i and ->> operators accept abbreviated PATH arguments. This + ** is mostly for compatibility with PostgreSQL, but also for + ** convenience. + ** + ** NUMBER ==> $[NUMBER] // PG compatible + ** LABEL ==> $.LABEL // PG compatible + ** [NUMBER] ==> $[NUMBER] // Not PG. Purely for convenience + */ + jsonStringInit(&jx, ctx); + if( jsonAllDigits(zPath, nPath) ){ + jsonAppendRawNZ(&jx, "[", 1); + jsonAppendRaw(&jx, zPath, nPath); + jsonAppendRawNZ(&jx, "]", 2); + }else if( jsonAllAlphanum(zPath, nPath) ){ + jsonAppendRawNZ(&jx, ".", 1); + jsonAppendRaw(&jx, zPath, nPath); + }else if( zPath[0]=='[' && nPath>=3 && zPath[nPath-1]==']' ){ + jsonAppendRaw(&jx, zPath, nPath); }else{ + jsonAppendRawNZ(&jx, ".\"", 2); + jsonAppendRaw(&jx, zPath, nPath); + jsonAppendRawNZ(&jx, "\"", 1); + } + jsonStringTerminate(&jx); + j = jsonLookupStep(p, 0, jx.zBuf, 0); + jsonStringReset(&jx); + }else{ + jsonBadPathError(ctx, zPath); + goto json_extract_error; + } + if( jnBlob ){ + if( argc==2 ){ + if( flags & JSON_JSON ){ + jsonStringInit(&jx, ctx); + jsonTranslateBlobToText(p, j, &jx); + jsonReturnString(&jx, 0, 0); + jsonStringReset(&jx); + assert( (flags & JSON_BLOB)==0 ); + sqlite3_result_subtype(ctx, JSON_SUBTYPE); + }else{ + jsonReturnFromBlob(p, j, ctx, 0); + if( (flags & (JSON_SQL|JSON_BLOB))==0 + && (p->aBlob[j]&0x0f)>=JSONB_ARRAY + ){ + sqlite3_result_subtype(ctx, JSON_SUBTYPE); + } + } + }else{ + jsonAppendSeparator(&jx); + jsonTranslateBlobToText(p, j, &jx); + } + }else if( j==JSON_LOOKUP_NOTFOUND ){ + if( argc==2 ){ + goto json_extract_error; /* Return NULL if not found */ + }else{ + jsonAppendSeparator(&jx); jsonAppendRawNZ(&jx, "null", 4); } + }else if( j==JSON_LOOKUP_ERROR ){ + sqlite3_result_error(ctx, "malformed JSON", -1); + goto json_extract_error; + }else{ + jsonBadPathError(ctx, zPath); + goto json_extract_error; } - if( i==argc ){ - jsonAppendChar(&jx, ']'); - jsonResult(&jx); + } + if( argc>2 ){ + jsonAppendChar(&jx, ']'); + jsonReturnString(&jx, 0, 0); + if( (flags & JSON_BLOB)==0 ){ sqlite3_result_subtype(ctx, JSON_SUBTYPE); } - jsonReset(&jx); } +json_extract_error: + jsonStringReset(&jx); + jsonParseFree(p); + return; } -/* This is the RFC 7396 MergePatch algorithm. +/* +** Return codes for jsonMergePatch() */ -static JsonNode *jsonMergePatch( - JsonParse *pParse, /* The JSON parser that contains the TARGET */ - u32 iTarget, /* Node of the TARGET in pParse */ - JsonNode *pPatch /* The PATCH */ +#define JSON_MERGE_OK 0 /* Success */ +#define JSON_MERGE_BADTARGET 1 /* Malformed TARGET blob */ +#define JSON_MERGE_BADPATCH 2 /* Malformed PATCH blob */ +#define JSON_MERGE_OOM 3 /* Out-of-memory condition */ + +/* +** RFC-7396 MergePatch for two JSONB blobs. +** +** pTarget is the target. pPatch is the patch. The target is updated +** in place. The patch is read-only. +** +** The original RFC-7396 algorithm is this: +** +** define MergePatch(Target, Patch): +** if Patch is an Object: +** if Target is not an Object: +** Target = {} # Ignore the contents and set it to an empty Object +** for each Name/Value pair in Patch: +** if Value is null: +** if Name exists in Target: +** remove the Name/Value pair from Target +** else: +** Target[Name] = MergePatch(Target[Name], Value) +** return Target +** else: +** return Patch +** +** Here is an equivalent algorithm restructured to show the actual +** implementation: +** +** 01 define MergePatch(Target, Patch): +** 02 if Patch is not an Object: +** 03 return Patch +** 04 else: // if Patch is an Object +** 05 if Target is not an Object: +** 06 Target = {} +** 07 for each Name/Value pair in Patch: +** 08 if Name exists in Target: +** 09 if Value is null: +** 10 remove the Name/Value pair from Target +** 11 else +** 12 Target[name] = MergePatch(Target[Name], Value) +** 13 else if Value is not NULL: +** 14 if Value is not an Object: +** 15 Target[name] = Value +** 16 else: +** 17 Target[name] = MergePatch('{}',value) +** 18 return Target +** | +** ^---- Line numbers referenced in comments in the implementation +*/ +static int jsonMergePatch( + JsonParse *pTarget, /* The JSON parser that contains the TARGET */ + u32 iTarget, /* Index of TARGET in pTarget->aBlob[] */ + const JsonParse *pPatch, /* The PATCH */ + u32 iPatch /* Index of PATCH in pPatch->aBlob[] */ ){ - u32 i, j; - u32 iRoot; - JsonNode *pTarget; - if( pPatch->eType!=JSON_OBJECT ){ - return pPatch; + u8 x; /* Type of a single node */ + u32 n, sz=0; /* Return values from jsonbPayloadSize() */ + u32 iTCursor; /* Cursor position while scanning the target object */ + u32 iTStart; /* First label in the target object */ + u32 iTEndBE; /* Original first byte past end of target, before edit */ + u32 iTEnd; /* Current first byte past end of target */ + u8 eTLabel; /* Node type of the target label */ + u32 iTLabel = 0; /* Index of the label */ + u32 nTLabel = 0; /* Header size in bytes for the target label */ + u32 szTLabel = 0; /* Size of the target label payload */ + u32 iTValue = 0; /* Index of the target value */ + u32 nTValue = 0; /* Header size of the target value */ + u32 szTValue = 0; /* Payload size for the target value */ + + u32 iPCursor; /* Cursor position while scanning the patch */ + u32 iPEnd; /* First byte past the end of the patch */ + u8 ePLabel; /* Node type of the patch label */ + u32 iPLabel; /* Start of patch label */ + u32 nPLabel; /* Size of header on the patch label */ + u32 szPLabel; /* Payload size of the patch label */ + u32 iPValue; /* Start of patch value */ + u32 nPValue; /* Header size for the patch value */ + u32 szPValue; /* Payload size of the patch value */ + + assert( iTarget>=0 && iTargetnBlob ); + assert( iPatch>=0 && iPatchnBlob ); + x = pPatch->aBlob[iPatch] & 0x0f; + if( x!=JSONB_OBJECT ){ /* Algorithm line 02 */ + u32 szPatch; /* Total size of the patch, header+payload */ + u32 szTarget; /* Total size of the target, header+payload */ + n = jsonbPayloadSize(pPatch, iPatch, &sz); + szPatch = n+sz; + sz = 0; + n = jsonbPayloadSize(pTarget, iTarget, &sz); + szTarget = n+sz; + jsonBlobEdit(pTarget, iTarget, szTarget, pPatch->aBlob+iPatch, szPatch); + return pTarget->oom ? JSON_MERGE_OOM : JSON_MERGE_OK; /* Line 03 */ } - assert( iTargetnNode ); - pTarget = &pParse->aNode[iTarget]; - assert( (pPatch->jnFlags & JNODE_APPEND)==0 ); - if( pTarget->eType!=JSON_OBJECT ){ - jsonRemoveAllNulls(pPatch); - return pPatch; + x = pTarget->aBlob[iTarget] & 0x0f; + if( x!=JSONB_OBJECT ){ /* Algorithm line 05 */ + n = jsonbPayloadSize(pTarget, iTarget, &sz); + jsonBlobEdit(pTarget, iTarget+n, sz, 0, 0); + x = pTarget->aBlob[iTarget]; + pTarget->aBlob[iTarget] = (x & 0xf0) | JSONB_OBJECT; } - iRoot = iTarget; - for(i=1; in; i += jsonNodeSize(&pPatch[i+1])+1){ - u32 nKey; - const char *zKey; - assert( pPatch[i].eType==JSON_STRING ); - assert( pPatch[i].jnFlags & JNODE_LABEL ); - assert( pPatch[i].eU==1 ); - nKey = pPatch[i].n; - zKey = pPatch[i].u.zJContent; - for(j=1; jn; j += jsonNodeSize(&pTarget[j+1])+1 ){ - assert( pTarget[j].eType==JSON_STRING ); - assert( pTarget[j].jnFlags & JNODE_LABEL ); - if( jsonSameLabel(&pPatch[i], &pTarget[j]) ){ - if( pTarget[j+1].jnFlags & (JNODE_REMOVE|JNODE_REPLACE) ) break; - if( pPatch[i+1].eType==JSON_NULL ){ - pTarget[j+1].jnFlags |= JNODE_REMOVE; - }else{ - JsonNode *pNew = jsonMergePatch(pParse, iTarget+j+1, &pPatch[i+1]); - if( pNew==0 ) return 0; - if( pNew!=&pParse->aNode[iTarget+j+1] ){ - jsonParseAddSubstNode(pParse, iTarget+j+1); - jsonParseAddNodeArray(pParse, pNew, jsonNodeSize(pNew)); - } - pTarget = &pParse->aNode[iTarget]; - } - break; + n = jsonbPayloadSize(pPatch, iPatch, &sz); + if( NEVER(n==0) ) return JSON_MERGE_BADPATCH; + iPCursor = iPatch+n; + iPEnd = iPCursor+sz; + n = jsonbPayloadSize(pTarget, iTarget, &sz); + if( NEVER(n==0) ) return JSON_MERGE_BADTARGET; + iTStart = iTarget+n; + iTEndBE = iTStart+sz; + + while( iPCursoraBlob[iPCursor] & 0x0f; + if( ePLabelJSONB_TEXTRAW ){ + return JSON_MERGE_BADPATCH; + } + nPLabel = jsonbPayloadSize(pPatch, iPCursor, &szPLabel); + if( nPLabel==0 ) return JSON_MERGE_BADPATCH; + iPValue = iPCursor + nPLabel + szPLabel; + if( iPValue>=iPEnd ) return JSON_MERGE_BADPATCH; + nPValue = jsonbPayloadSize(pPatch, iPValue, &szPValue); + if( nPValue==0 ) return JSON_MERGE_BADPATCH; + iPCursor = iPValue + nPValue + szPValue; + if( iPCursor>iPEnd ) return JSON_MERGE_BADPATCH; + + iTCursor = iTStart; + iTEnd = iTEndBE + pTarget->delta; + while( iTCursoraBlob[iTCursor] & 0x0f; + if( eTLabelJSONB_TEXTRAW ){ + return JSON_MERGE_BADTARGET; + } + nTLabel = jsonbPayloadSize(pTarget, iTCursor, &szTLabel); + if( nTLabel==0 ) return JSON_MERGE_BADTARGET; + iTValue = iTLabel + nTLabel + szTLabel; + if( iTValue>=iTEnd ) return JSON_MERGE_BADTARGET; + nTValue = jsonbPayloadSize(pTarget, iTValue, &szTValue); + if( nTValue==0 ) return JSON_MERGE_BADTARGET; + if( iTValue + nTValue + szTValue > iTEnd ) return JSON_MERGE_BADTARGET; + isEqual = jsonLabelCompare( + (const char*)&pPatch->aBlob[iPLabel+nPLabel], + szPLabel, + (ePLabel==JSONB_TEXT || ePLabel==JSONB_TEXTRAW), + (const char*)&pTarget->aBlob[iTLabel+nTLabel], + szTLabel, + (eTLabel==JSONB_TEXT || eTLabel==JSONB_TEXTRAW)); + if( isEqual ) break; + iTCursor = iTValue + nTValue + szTValue; + } + x = pPatch->aBlob[iPValue] & 0x0f; + if( iTCursoroom) ) return JSON_MERGE_OOM; + }else{ + /* Algorithm line 12 */ + int rc, savedDelta = pTarget->delta; + pTarget->delta = 0; + rc = jsonMergePatch(pTarget, iTValue, pPatch, iPValue); + if( rc ) return rc; + pTarget->delta += savedDelta; + } + }else if( x>0 ){ /* Algorithm line 13 */ + /* No match and patch value is not NULL */ + u32 szNew = szPLabel+nPLabel; + if( (pPatch->aBlob[iPValue] & 0x0f)!=JSONB_OBJECT ){ /* Line 14 */ + jsonBlobEdit(pTarget, iTEnd, 0, 0, szPValue+nPValue+szNew); + if( pTarget->oom ) return JSON_MERGE_OOM; + memcpy(&pTarget->aBlob[iTEnd], &pPatch->aBlob[iPLabel], szNew); + memcpy(&pTarget->aBlob[iTEnd+szNew], + &pPatch->aBlob[iPValue], szPValue+nPValue); + }else{ + int rc, savedDelta; + jsonBlobEdit(pTarget, iTEnd, 0, 0, szNew+1); + if( pTarget->oom ) return JSON_MERGE_OOM; + memcpy(&pTarget->aBlob[iTEnd], &pPatch->aBlob[iPLabel], szNew); + pTarget->aBlob[iTEnd+szNew] = 0x00; + savedDelta = pTarget->delta; + pTarget->delta = 0; + rc = jsonMergePatch(pTarget, iTEnd+szNew,pPatch,iPValue); + if( rc ) return rc; + pTarget->delta += savedDelta; } } - if( j>=pTarget->n && pPatch[i+1].eType!=JSON_NULL ){ - int iStart; - JsonNode *pApnd; - u32 nApnd; - iStart = jsonParseAddNode(pParse, JSON_OBJECT, 0, 0); - jsonParseAddNode(pParse, JSON_STRING, nKey, zKey); - pApnd = &pPatch[i+1]; - if( pApnd->eType==JSON_OBJECT ) jsonRemoveAllNulls(pApnd); - nApnd = jsonNodeSize(pApnd); - jsonParseAddNodeArray(pParse, pApnd, jsonNodeSize(pApnd)); - if( pParse->oom ) return 0; - pParse->aNode[iStart].n = 1+nApnd; - pParse->aNode[iRoot].jnFlags |= JNODE_APPEND; - pParse->aNode[iRoot].u.iAppend = iStart; - VVA( pParse->aNode[iRoot].eU = 2 ); - iRoot = iStart; - pTarget = &pParse->aNode[iTarget]; - } } - return pTarget; + if( pTarget->delta ) jsonAfterEditSizeAdjust(pTarget, iTarget); + return pTarget->oom ? JSON_MERGE_OOM : JSON_MERGE_OK; } + /* ** Implementation of the json_mergepatch(JSON1,JSON2) function. Return a JSON ** object that is the result of running the RFC 7396 MergePatch() algorithm @@ -205252,28 +207131,27 @@ static void jsonPatchFunc( int argc, sqlite3_value **argv ){ - JsonParse *pX; /* The JSON that is being patched */ - JsonParse *pY; /* The patch */ - JsonNode *pResult; /* The result of the merge */ + JsonParse *pTarget; /* The TARGET */ + JsonParse *pPatch; /* The PATCH */ + int rc; /* Result code */ UNUSED_PARAMETER(argc); - pX = jsonParseCached(ctx, argv[0], ctx, 1); - if( pX==0 ) return; - assert( pX->hasMod==0 ); - pX->hasMod = 1; - pY = jsonParseCached(ctx, argv[1], ctx, 1); - if( pY==0 ) return; - pX->useMod = 1; - pY->useMod = 1; - pResult = jsonMergePatch(pX, 0, pY->aNode); - assert( pResult!=0 || pX->oom ); - if( pResult && pX->oom==0 ){ - jsonDebugPrintParse(pX); - jsonDebugPrintNode(pResult); - jsonReturnJson(pX, pResult, ctx, 0); - }else{ - sqlite3_result_error_nomem(ctx); + assert( argc==2 ); + pTarget = jsonParseFuncArg(ctx, argv[0], JSON_EDITABLE); + if( pTarget==0 ) return; + pPatch = jsonParseFuncArg(ctx, argv[1], 0); + if( pPatch ){ + rc = jsonMergePatch(pTarget, 0, pPatch, 0); + if( rc==JSON_MERGE_OK ){ + jsonReturnParse(ctx, pTarget); + }else if( rc==JSON_MERGE_OOM ){ + sqlite3_result_error_nomem(ctx); + }else{ + sqlite3_result_error(ctx, "malformed JSON", -1); + } + jsonParseFree(pPatch); } + jsonParseFree(pTarget); } @@ -205297,23 +207175,23 @@ static void jsonObjectFunc( "of arguments", -1); return; } - jsonInit(&jx, ctx); + jsonStringInit(&jx, ctx); jsonAppendChar(&jx, '{'); for(i=0; i1); - if( pParse==0 ) return; - for(i=1; i<(u32)argc; i++){ + p = jsonParseFuncArg(ctx, argv[0], argc>1 ? JSON_EDITABLE : 0); + if( p==0 ) return; + for(i=1; inErr ) goto remove_done; - if( pNode ){ - pNode->jnFlags |= JNODE_REMOVE; - pParse->hasMod = 1; - pParse->useMod = 1; + if( zPath==0 ){ + goto json_remove_done; } - } - if( (pParse->aNode[0].jnFlags & JNODE_REMOVE)==0 ){ - jsonReturnJson(pParse, pParse->aNode, ctx, 1); - } -remove_done: - jsonDebugPrintParse(p); -} - -/* -** Substitute the value at iNode with the pValue parameter. -*/ -static void jsonReplaceNode( - sqlite3_context *pCtx, - JsonParse *p, - int iNode, - sqlite3_value *pValue -){ - int idx = jsonParseAddSubstNode(p, iNode); - if( idx<=0 ){ - assert( p->oom ); - return; - } - switch( sqlite3_value_type(pValue) ){ - case SQLITE_NULL: { - jsonParseAddNode(p, JSON_NULL, 0, 0); - break; + if( zPath[0]!='$' ){ + goto json_remove_patherror; } - case SQLITE_FLOAT: { - char *z = sqlite3_mprintf("%!0.15g", sqlite3_value_double(pValue)); - int n; - if( z==0 ){ - p->oom = 1; - break; - } - n = sqlite3Strlen30(z); - jsonParseAddNode(p, JSON_REAL, n, z); - jsonParseAddCleanup(p, sqlite3_free, z); - break; + if( zPath[1]==0 ){ + /* json_remove(j,'$') returns NULL */ + goto json_remove_done; } - case SQLITE_INTEGER: { - char *z = sqlite3_mprintf("%lld", sqlite3_value_int64(pValue)); - int n; - if( z==0 ){ - p->oom = 1; - break; - } - n = sqlite3Strlen30(z); - jsonParseAddNode(p, JSON_INT, n, z); - jsonParseAddCleanup(p, sqlite3_free, z); - - break; - } - case SQLITE_TEXT: { - const char *z = (const char*)sqlite3_value_text(pValue); - u32 n = (u32)sqlite3_value_bytes(pValue); - if( z==0 ){ - p->oom = 1; - break; - } - if( sqlite3_value_subtype(pValue)!=JSON_SUBTYPE ){ - char *zCopy = sqlite3_malloc64( n+1 ); - int k; - if( zCopy ){ - memcpy(zCopy, z, n); - zCopy[n] = 0; - jsonParseAddCleanup(p, sqlite3_free, zCopy); - }else{ - p->oom = 1; - sqlite3_result_error_nomem(pCtx); - } - k = jsonParseAddNode(p, JSON_STRING, n, zCopy); - assert( k>0 || p->oom ); - if( p->oom==0 ) p->aNode[k].jnFlags |= JNODE_RAW; + p->eEdit = JEDIT_DEL; + p->delta = 0; + rc = jsonLookupStep(p, 0, zPath+1, 0); + if( JSON_LOOKUP_ISERROR(rc) ){ + if( rc==JSON_LOOKUP_NOTFOUND ){ + continue; /* No-op */ + }else if( rc==JSON_LOOKUP_PATHERROR ){ + jsonBadPathError(ctx, zPath); }else{ - JsonParse *pPatch = jsonParseCached(pCtx, pValue, pCtx, 1); - if( pPatch==0 ){ - p->oom = 1; - break; - } - jsonParseAddNodeArray(p, pPatch->aNode, pPatch->nNode); - /* The nodes copied out of pPatch and into p likely contain - ** u.zJContent pointers into pPatch->zJson. So preserve the - ** content of pPatch until p is destroyed. */ - assert( pPatch->nJPRef>=1 ); - pPatch->nJPRef++; - jsonParseAddCleanup(p, (void(*)(void*))jsonParseFree, pPatch); + sqlite3_result_error(ctx, "malformed JSON", -1); } - break; - } - default: { - jsonParseAddNode(p, JSON_NULL, 0, 0); - sqlite3_result_error(pCtx, "JSON cannot hold BLOB values", -1); - p->nErr++; - break; + goto json_remove_done; } } + jsonReturnParse(ctx, p); + jsonParseFree(p); + return; + +json_remove_patherror: + jsonBadPathError(ctx, zPath); + +json_remove_done: + jsonParseFree(p); + return; } /* @@ -205456,32 +207264,12 @@ static void jsonReplaceFunc( int argc, sqlite3_value **argv ){ - JsonParse *pParse; /* The parse */ - JsonNode *pNode; - const char *zPath; - u32 i; - if( argc<1 ) return; if( (argc&1)==0 ) { jsonWrongNumArgs(ctx, "replace"); return; } - pParse = jsonParseCached(ctx, argv[0], ctx, argc>1); - if( pParse==0 ) return; - pParse->nJPRef++; - for(i=1; i<(u32)argc; i+=2){ - zPath = (const char*)sqlite3_value_text(argv[i]); - pParse->useMod = 1; - pNode = jsonLookup(pParse, zPath, 0, ctx); - if( pParse->nErr ) goto replace_err; - if( pNode ){ - jsonReplaceNode(ctx, pParse, (u32)(pNode - pParse->aNode), argv[i+1]); - } - } - jsonReturnJson(pParse, pParse->aNode, ctx, 1); -replace_err: - jsonDebugPrintParse(pParse); - jsonParseFree(pParse); + jsonInsertIntoBlob(ctx, argc, argv, JEDIT_REPL); } @@ -205502,39 +207290,16 @@ static void jsonSetFunc( int argc, sqlite3_value **argv ){ - JsonParse *pParse; /* The parse */ - JsonNode *pNode; - const char *zPath; - u32 i; - int bApnd; - int bIsSet = sqlite3_user_data(ctx)!=0; + + int flags = SQLITE_PTR_TO_INT(sqlite3_user_data(ctx)); + int bIsSet = (flags&JSON_ISSET)!=0; if( argc<1 ) return; if( (argc&1)==0 ) { jsonWrongNumArgs(ctx, bIsSet ? "set" : "insert"); return; } - pParse = jsonParseCached(ctx, argv[0], ctx, argc>1); - if( pParse==0 ) return; - pParse->nJPRef++; - for(i=1; i<(u32)argc; i+=2){ - zPath = (const char*)sqlite3_value_text(argv[i]); - bApnd = 0; - pParse->useMod = 1; - pNode = jsonLookup(pParse, zPath, &bApnd, ctx); - if( pParse->oom ){ - sqlite3_result_error_nomem(ctx); - goto jsonSetDone; - }else if( pParse->nErr ){ - goto jsonSetDone; - }else if( pNode && (bApnd || bIsSet) ){ - jsonReplaceNode(ctx, pParse, (u32)(pNode - pParse->aNode), argv[i+1]); - } - } - jsonDebugPrintParse(pParse); - jsonReturnJson(pParse, pParse->aNode, ctx, 1); -jsonSetDone: - jsonParseFree(pParse); + jsonInsertIntoBlob(ctx, argc, argv, bIsSet ? JEDIT_SET : JEDIT_INS); } /* @@ -205550,27 +207315,93 @@ static void jsonTypeFunc( sqlite3_value **argv ){ JsonParse *p; /* The parse */ - const char *zPath; - JsonNode *pNode; + const char *zPath = 0; + u32 i; - p = jsonParseCached(ctx, argv[0], ctx, 0); + p = jsonParseFuncArg(ctx, argv[0], 0); if( p==0 ) return; if( argc==2 ){ zPath = (const char*)sqlite3_value_text(argv[1]); - pNode = jsonLookup(p, zPath, 0, ctx); + if( zPath==0 ) goto json_type_done; + if( zPath[0]!='$' ){ + jsonBadPathError(ctx, zPath); + goto json_type_done; + } + i = jsonLookupStep(p, 0, zPath+1, 0); + if( JSON_LOOKUP_ISERROR(i) ){ + if( i==JSON_LOOKUP_NOTFOUND ){ + /* no-op */ + }else if( i==JSON_LOOKUP_PATHERROR ){ + jsonBadPathError(ctx, zPath); + }else{ + sqlite3_result_error(ctx, "malformed JSON", -1); + } + goto json_type_done; + } }else{ - pNode = p->aNode; - } - if( pNode ){ - sqlite3_result_text(ctx, jsonType[pNode->eType], -1, SQLITE_STATIC); + i = 0; } + sqlite3_result_text(ctx, jsonbType[p->aBlob[i]&0x0f], -1, SQLITE_STATIC); +json_type_done: + jsonParseFree(p); } /* ** json_valid(JSON) +** json_valid(JSON, FLAGS) ** -** Return 1 if JSON is a well-formed canonical JSON string according -** to RFC-7159. Return 0 otherwise. +** Check the JSON argument to see if it is well-formed. The FLAGS argument +** encodes the various constraints on what is meant by "well-formed": +** +** 0x01 Canonical RFC-8259 JSON text +** 0x02 JSON text with optional JSON-5 extensions +** 0x04 Superficially appears to be JSONB +** 0x08 Strictly well-formed JSONB +** +** If the FLAGS argument is omitted, it defaults to 1. Useful values for +** FLAGS include: +** +** 1 Strict canonical JSON text +** 2 JSON text perhaps with JSON-5 extensions +** 4 Superficially appears to be JSONB +** 5 Canonical JSON text or superficial JSONB +** 6 JSON-5 text or superficial JSONB +** 8 Strict JSONB +** 9 Canonical JSON text or strict JSONB +** 10 JSON-5 text or strict JSONB +** +** Other flag combinations are redundant. For example, every canonical +** JSON text is also well-formed JSON-5 text, so FLAG values 2 and 3 +** are the same. Similarly, any input that passes a strict JSONB validation +** will also pass the superficial validation so 12 through 15 are the same +** as 8 through 11 respectively. +** +** This routine runs in linear time to validate text and when doing strict +** JSONB validation. Superficial JSONB validation is constant time, +** assuming the BLOB is already in memory. The performance advantage +** of superficial JSONB validation is why that option is provided. +** Application developers can choose to do fast superficial validation or +** slower strict validation, according to their specific needs. +** +** Only the lower four bits of the FLAGS argument are currently used. +** Higher bits are reserved for future expansion. To facilitate +** compatibility, the current implementation raises an error if any bit +** in FLAGS is set other than the lower four bits. +** +** The original circa 2015 implementation of the JSON routines in +** SQLite only supported canonical RFC-8259 JSON text and the json_valid() +** function only accepted one argument. That is why the default value +** for the FLAGS argument is 1, since FLAGS=1 causes this routine to only +** recognize canonical RFC-8259 JSON text as valid. The extra FLAGS +** argument was added when the JSON routines were extended to support +** JSON5-like extensions and binary JSONB stored in BLOBs. +** +** Return Values: +** +** * Raise an error if FLAGS is outside the range of 1 to 15. +** * Return NULL if the input is NULL +** * Return 1 if the input is well-formed. +** * Return 0 if the input is not well-formed. */ static void jsonValidFunc( sqlite3_context *ctx, @@ -205578,79 +207409,125 @@ static void jsonValidFunc( sqlite3_value **argv ){ JsonParse *p; /* The parse */ - UNUSED_PARAMETER(argc); - if( sqlite3_value_type(argv[0])==SQLITE_NULL ){ + u8 flags = 1; + u8 res = 0; + if( argc==2 ){ + i64 f = sqlite3_value_int64(argv[1]); + if( f<1 || f>15 ){ + sqlite3_result_error(ctx, "FLAGS parameter to json_valid() must be" + " between 1 and 15", -1); + return; + } + flags = f & 0x0f; + } + switch( sqlite3_value_type(argv[0]) ){ + case SQLITE_NULL: { #ifdef SQLITE_LEGACY_JSON_VALID - /* Incorrect legacy behavior was to return FALSE for a NULL input */ - sqlite3_result_int(ctx, 0); + /* Incorrect legacy behavior was to return FALSE for a NULL input */ + sqlite3_result_int(ctx, 0); #endif - return; - } - p = jsonParseCached(ctx, argv[0], 0, 0); - if( p==0 || p->oom ){ - sqlite3_result_error_nomem(ctx); - sqlite3_free(p); - }else{ - sqlite3_result_int(ctx, p->nErr==0 && (p->hasNonstd==0 || p->useMod)); - if( p->nErr ) jsonParseFree(p); + return; + } + case SQLITE_BLOB: { + if( (flags & 0x0c)!=0 && jsonFuncArgMightBeBinary(argv[0]) ){ + if( flags & 0x04 ){ + /* Superficial checking only - accomplished by the + ** jsonFuncArgMightBeBinary() call above. */ + res = 1; + }else{ + /* Strict checking. Check by translating BLOB->TEXT->BLOB. If + ** no errors occur, call that a "strict check". */ + JsonParse px; + u32 iErr; + memset(&px, 0, sizeof(px)); + px.aBlob = (u8*)sqlite3_value_blob(argv[0]); + px.nBlob = sqlite3_value_bytes(argv[0]); + iErr = jsonbValidityCheck(&px, 0, px.nBlob, 1); + res = iErr==0; + } + } + break; + } + default: { + JsonParse px; + if( (flags & 0x3)==0 ) break; + memset(&px, 0, sizeof(px)); + + p = jsonParseFuncArg(ctx, argv[0], JSON_KEEPERROR); + if( p ){ + if( p->oom ){ + sqlite3_result_error_nomem(ctx); + }else if( p->nErr ){ + /* no-op */ + }else if( (flags & 0x02)!=0 || p->hasNonstd==0 ){ + res = 1; + } + jsonParseFree(p); + }else{ + sqlite3_result_error_nomem(ctx); + } + break; + } } + sqlite3_result_int(ctx, res); } /* ** json_error_position(JSON) ** -** If the argument is not an interpretable JSON string, then return the 1-based -** character position at which the parser first recognized that the input -** was in error. The left-most character is 1. If the string is valid -** JSON, then return 0. +** If the argument is NULL, return NULL ** -** Note that json_valid() is only true for strictly conforming canonical JSON. -** But this routine returns zero if the input contains extension. Thus: +** If the argument is BLOB, do a full validity check and return non-zero +** if the check fails. The return value is the approximate 1-based offset +** to the byte of the element that contains the first error. ** -** (1) If the input X is strictly conforming canonical JSON: -** -** json_valid(X) returns true -** json_error_position(X) returns 0 -** -** (2) If the input X is JSON but it includes extension (such as JSON5) that -** are not part of RFC-8259: -** -** json_valid(X) returns false -** json_error_position(X) return 0 -** -** (3) If the input X cannot be interpreted as JSON even taking extensions -** into account: -** -** json_valid(X) return false -** json_error_position(X) returns 1 or more +** Otherwise interpret the argument is TEXT (even if it is numeric) and +** return the 1-based character position for where the parser first recognized +** that the input was not valid JSON, or return 0 if the input text looks +** ok. JSON-5 extensions are accepted. */ static void jsonErrorFunc( sqlite3_context *ctx, int argc, sqlite3_value **argv ){ - JsonParse *p; /* The parse */ + i64 iErrPos = 0; /* Error position to be returned */ + JsonParse s; + + assert( argc==1 ); UNUSED_PARAMETER(argc); - if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return; - p = jsonParseCached(ctx, argv[0], 0, 0); - if( p==0 || p->oom ){ - sqlite3_result_error_nomem(ctx); - sqlite3_free(p); - }else if( p->nErr==0 ){ - sqlite3_result_int(ctx, 0); + memset(&s, 0, sizeof(s)); + s.db = sqlite3_context_db_handle(ctx); + if( jsonFuncArgMightBeBinary(argv[0]) ){ + s.aBlob = (u8*)sqlite3_value_blob(argv[0]); + s.nBlob = sqlite3_value_bytes(argv[0]); + iErrPos = (i64)jsonbValidityCheck(&s, 0, s.nBlob, 1); }else{ - int n = 1; - u32 i; - const char *z = (const char*)sqlite3_value_text(argv[0]); - for(i=0; iiErr && ALWAYS(z[i]); i++){ - if( (z[i]&0xc0)!=0x80 ) n++; + s.zJson = (char*)sqlite3_value_text(argv[0]); + if( s.zJson==0 ) return; /* NULL input or OOM */ + s.nJson = sqlite3_value_bytes(argv[0]); + if( jsonConvertTextToBlob(&s,0) ){ + if( s.oom ){ + iErrPos = -1; + }else{ + /* Convert byte-offset s.iErr into a character offset */ + u32 k; + assert( s.zJson!=0 ); /* Because s.oom is false */ + for(k=0; kzBuf==0 ){ - jsonInit(pStr, ctx); + jsonStringInit(pStr, ctx); jsonAppendChar(pStr, '['); }else if( pStr->nUsed>1 ){ jsonAppendChar(pStr, ','); } pStr->pCtx = ctx; - jsonAppendValue(pStr, argv[0]); + jsonAppendSqlValue(pStr, argv[0]); } } static void jsonArrayCompute(sqlite3_context *ctx, int isFinal){ JsonString *pStr; pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0); if( pStr ){ + int flags; pStr->pCtx = ctx; jsonAppendChar(pStr, ']'); - if( pStr->bErr ){ - if( pStr->bErr==1 ) sqlite3_result_error_nomem(ctx); - assert( pStr->bStatic ); + flags = SQLITE_PTR_TO_INT(sqlite3_user_data(ctx)); + if( pStr->eErr ){ + jsonReturnString(pStr, 0, 0); + return; + }else if( flags & JSON_BLOB ){ + jsonReturnStringAsBlob(pStr); + if( isFinal ){ + if( !pStr->bStatic ) sqlite3RCStrUnref(pStr->zBuf); + }else{ + pStr->nUsed--; + } + return; }else if( isFinal ){ sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, pStr->bStatic ? SQLITE_TRANSIENT : @@ -205775,27 +207662,38 @@ static void jsonObjectStep( pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr)); if( pStr ){ if( pStr->zBuf==0 ){ - jsonInit(pStr, ctx); + jsonStringInit(pStr, ctx); jsonAppendChar(pStr, '{'); }else if( pStr->nUsed>1 ){ jsonAppendChar(pStr, ','); } pStr->pCtx = ctx; z = (const char*)sqlite3_value_text(argv[0]); - n = (u32)sqlite3_value_bytes(argv[0]); + n = sqlite3Strlen30(z); jsonAppendString(pStr, z, n); jsonAppendChar(pStr, ':'); - jsonAppendValue(pStr, argv[1]); + jsonAppendSqlValue(pStr, argv[1]); } } static void jsonObjectCompute(sqlite3_context *ctx, int isFinal){ JsonString *pStr; pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0); if( pStr ){ + int flags; jsonAppendChar(pStr, '}'); - if( pStr->bErr ){ - if( pStr->bErr==1 ) sqlite3_result_error_nomem(ctx); - assert( pStr->bStatic ); + pStr->pCtx = ctx; + flags = SQLITE_PTR_TO_INT(sqlite3_user_data(ctx)); + if( pStr->eErr ){ + jsonReturnString(pStr, 0, 0); + return; + }else if( flags & JSON_BLOB ){ + jsonReturnStringAsBlob(pStr); + if( isFinal ){ + if( !pStr->bStatic ) sqlite3RCStrUnref(pStr->zBuf); + }else{ + pStr->nUsed--; + } + return; }else if( isFinal ){ sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, pStr->bStatic ? SQLITE_TRANSIENT : @@ -205823,19 +207721,37 @@ static void jsonObjectFinal(sqlite3_context *ctx){ /**************************************************************************** ** The json_each virtual table ****************************************************************************/ +typedef struct JsonParent JsonParent; +struct JsonParent { + u32 iHead; /* Start of object or array */ + u32 iValue; /* Start of the value */ + u32 iEnd; /* First byte past the end */ + u32 nPath; /* Length of path */ + i64 iKey; /* Key for JSONB_ARRAY */ +}; + typedef struct JsonEachCursor JsonEachCursor; struct JsonEachCursor { sqlite3_vtab_cursor base; /* Base class - must be first */ u32 iRowid; /* The rowid */ - u32 iBegin; /* The first node of the scan */ - u32 i; /* Index in sParse.aNode[] of current row */ + u32 i; /* Index in sParse.aBlob[] of current row */ u32 iEnd; /* EOF when i equals or exceeds this value */ - u8 eType; /* Type of top-level element */ + u32 nRoot; /* Size of the root path in bytes */ + u8 eType; /* Type of the container for element i */ u8 bRecursive; /* True for json_tree(). False for json_each() */ - char *zJson; /* Input JSON */ - char *zRoot; /* Path by which to filter zJson */ + u32 nParent; /* Current nesting depth */ + u32 nParentAlloc; /* Space allocated for aParent[] */ + JsonParent *aParent; /* Parent elements of i */ + sqlite3 *db; /* Database connection */ + JsonString path; /* Current path */ JsonParse sParse; /* Parse of the input JSON */ }; +typedef struct JsonEachConnection JsonEachConnection; +struct JsonEachConnection { + sqlite3_vtab base; /* Base class - must be first */ + sqlite3 *db; /* Database connection */ +}; + /* Constructor for the json_each virtual table */ static int jsonEachConnect( @@ -205845,7 +207761,7 @@ static int jsonEachConnect( sqlite3_vtab **ppVtab, char **pzErr ){ - sqlite3_vtab *pNew; + JsonEachConnection *pNew; int rc; /* Column numbers */ @@ -205871,28 +207787,32 @@ static int jsonEachConnect( "CREATE TABLE x(key,value,type,atom,id,parent,fullkey,path," "json HIDDEN,root HIDDEN)"); if( rc==SQLITE_OK ){ - pNew = *ppVtab = sqlite3_malloc( sizeof(*pNew) ); + pNew = (JsonEachConnection*)sqlite3DbMallocZero(db, sizeof(*pNew)); + *ppVtab = (sqlite3_vtab*)pNew; if( pNew==0 ) return SQLITE_NOMEM; - memset(pNew, 0, sizeof(*pNew)); sqlite3_vtab_config(db, SQLITE_VTAB_INNOCUOUS); + pNew->db = db; } return rc; } /* destructor for json_each virtual table */ static int jsonEachDisconnect(sqlite3_vtab *pVtab){ - sqlite3_free(pVtab); + JsonEachConnection *p = (JsonEachConnection*)pVtab; + sqlite3DbFree(p->db, pVtab); return SQLITE_OK; } /* constructor for a JsonEachCursor object for json_each(). */ static int jsonEachOpenEach(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){ + JsonEachConnection *pVtab = (JsonEachConnection*)p; JsonEachCursor *pCur; UNUSED_PARAMETER(p); - pCur = sqlite3_malloc( sizeof(*pCur) ); + pCur = sqlite3DbMallocZero(pVtab->db, sizeof(*pCur)); if( pCur==0 ) return SQLITE_NOMEM; - memset(pCur, 0, sizeof(*pCur)); + pCur->db = pVtab->db; + jsonStringZero(&pCur->path); *ppCursor = &pCur->base; return SQLITE_OK; } @@ -205910,21 +207830,24 @@ static int jsonEachOpenTree(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){ /* Reset a JsonEachCursor back to its original state. Free any memory ** held. */ static void jsonEachCursorReset(JsonEachCursor *p){ - sqlite3_free(p->zRoot); jsonParseReset(&p->sParse); + jsonStringReset(&p->path); + sqlite3DbFree(p->db, p->aParent); p->iRowid = 0; p->i = 0; + p->aParent = 0; + p->nParent = 0; + p->nParentAlloc = 0; p->iEnd = 0; p->eType = 0; - p->zJson = 0; - p->zRoot = 0; } /* Destructor for a jsonEachCursor object */ static int jsonEachClose(sqlite3_vtab_cursor *cur){ JsonEachCursor *p = (JsonEachCursor*)cur; jsonEachCursorReset(p); - sqlite3_free(cur); + + sqlite3DbFree(p->db, cur); return SQLITE_OK; } @@ -205935,200 +207858,230 @@ static int jsonEachEof(sqlite3_vtab_cursor *cur){ return p->i >= p->iEnd; } -/* Advance the cursor to the next element for json_tree() */ -static int jsonEachNext(sqlite3_vtab_cursor *cur){ - JsonEachCursor *p = (JsonEachCursor*)cur; - if( p->bRecursive ){ - if( p->sParse.aNode[p->i].jnFlags & JNODE_LABEL ) p->i++; - p->i++; - p->iRowid++; - if( p->iiEnd ){ - u32 iUp = p->sParse.aUp[p->i]; - JsonNode *pUp = &p->sParse.aNode[iUp]; - p->eType = pUp->eType; - if( pUp->eType==JSON_ARRAY ){ - assert( pUp->eU==0 || pUp->eU==3 ); - testcase( pUp->eU==3 ); - VVA( pUp->eU = 3 ); - if( iUp==p->i-1 ){ - pUp->u.iKey = 0; - }else{ - pUp->u.iKey++; +/* +** If the cursor is currently pointing at the label of a object entry, +** then return the index of the value. For all other cases, return the +** current pointer position, which is the value. +*/ +static int jsonSkipLabel(JsonEachCursor *p){ + if( p->eType==JSONB_OBJECT ){ + u32 sz = 0; + u32 n = jsonbPayloadSize(&p->sParse, p->i, &sz); + return p->i + n + sz; + }else{ + return p->i; + } +} + +/* +** Append the path name for the current element. +*/ +static void jsonAppendPathName(JsonEachCursor *p){ + assert( p->nParent>0 ); + assert( p->eType==JSONB_ARRAY || p->eType==JSONB_OBJECT ); + if( p->eType==JSONB_ARRAY ){ + jsonPrintf(30, &p->path, "[%lld]", p->aParent[p->nParent-1].iKey); + }else{ + u32 n, sz = 0, k, i; + const char *z; + int needQuote = 0; + n = jsonbPayloadSize(&p->sParse, p->i, &sz); + k = p->i + n; + z = (const char*)&p->sParse.aBlob[k]; + if( sz==0 || !sqlite3Isalpha(z[0]) ){ + needQuote = 1; + }else{ + for(i=0; ipath,".\"%.*s\"", sz, z); + }else{ + jsonPrintf(sz+2,&p->path,".%.*s", sz, z); + } + } +} + +/* Advance the cursor to the next element for json_tree() */ +static int jsonEachNext(sqlite3_vtab_cursor *cur){ + JsonEachCursor *p = (JsonEachCursor*)cur; + int rc = SQLITE_OK; + if( p->bRecursive ){ + u8 x; + u8 levelChange = 0; + u32 n, sz = 0; + u32 i = jsonSkipLabel(p); + x = p->sParse.aBlob[i] & 0x0f; + n = jsonbPayloadSize(&p->sParse, i, &sz); + if( x==JSONB_OBJECT || x==JSONB_ARRAY ){ + JsonParent *pParent; + if( p->nParent>=p->nParentAlloc ){ + JsonParent *pNew; + u64 nNew; + nNew = p->nParentAlloc*2 + 3; + pNew = sqlite3DbRealloc(p->db, p->aParent, sizeof(JsonParent)*nNew); + if( pNew==0 ) return SQLITE_NOMEM; + p->nParentAlloc = (u32)nNew; + p->aParent = pNew; + } + levelChange = 1; + pParent = &p->aParent[p->nParent]; + pParent->iHead = p->i; + pParent->iValue = i; + pParent->iEnd = i + n + sz; + pParent->iKey = -1; + pParent->nPath = (u32)p->path.nUsed; + if( p->eType && p->nParent ){ + jsonAppendPathName(p); + if( p->path.eErr ) rc = SQLITE_NOMEM; + } + p->nParent++; + p->i = i + n; + }else{ + p->i = i + n + sz; + } + while( p->nParent>0 && p->i >= p->aParent[p->nParent-1].iEnd ){ + p->nParent--; + p->path.nUsed = p->aParent[p->nParent].nPath; + levelChange = 1; + } + if( levelChange ){ + if( p->nParent>0 ){ + JsonParent *pParent = &p->aParent[p->nParent-1]; + u32 iVal = pParent->iValue; + p->eType = p->sParse.aBlob[iVal] & 0x0f; + }else{ + p->eType = 0; + } + } }else{ - switch( p->eType ){ - case JSON_ARRAY: { - p->i += jsonNodeSize(&p->sParse.aNode[p->i]); - p->iRowid++; - break; - } - case JSON_OBJECT: { - p->i += 1 + jsonNodeSize(&p->sParse.aNode[p->i+1]); - p->iRowid++; - break; - } - default: { - p->i = p->iEnd; - break; + u32 n, sz = 0; + u32 i = jsonSkipLabel(p); + n = jsonbPayloadSize(&p->sParse, i, &sz); + p->i = i + n + sz; + } + if( p->eType==JSONB_ARRAY && p->nParent ){ + p->aParent[p->nParent-1].iKey++; + } + p->iRowid++; + return rc; +} + +/* Length of the path for rowid==0 in bRecursive mode. +*/ +static int jsonEachPathLength(JsonEachCursor *p){ + u32 n = p->path.nUsed; + char *z = p->path.zBuf; + if( p->iRowid==0 && p->bRecursive && n>=2 ){ + while( n>1 ){ + n--; + if( z[n]=='[' || z[n]=='.' ){ + u32 x, sz = 0; + char cSaved = z[n]; + z[n] = 0; + assert( p->sParse.eEdit==0 ); + x = jsonLookupStep(&p->sParse, 0, z+1, 0); + z[n] = cSaved; + if( JSON_LOOKUP_ISERROR(x) ) continue; + if( x + jsonbPayloadSize(&p->sParse, x, &sz) == p->i ) break; } } } - return SQLITE_OK; -} - -/* Append an object label to the JSON Path being constructed -** in pStr. -*/ -static void jsonAppendObjectPathElement( - JsonString *pStr, - JsonNode *pNode -){ - int jj, nn; - const char *z; - assert( pNode->eType==JSON_STRING ); - assert( pNode->jnFlags & JNODE_LABEL ); - assert( pNode->eU==1 ); - z = pNode->u.zJContent; - nn = pNode->n; - if( (pNode->jnFlags & JNODE_RAW)==0 ){ - assert( nn>=2 ); - assert( z[0]=='"' || z[0]=='\'' ); - assert( z[nn-1]=='"' || z[0]=='\'' ); - if( nn>2 && sqlite3Isalpha(z[1]) ){ - for(jj=2; jjsParse.aUp[i]; - jsonEachComputePath(p, pStr, iUp); - pNode = &p->sParse.aNode[i]; - pUp = &p->sParse.aNode[iUp]; - if( pUp->eType==JSON_ARRAY ){ - assert( pUp->eU==3 || (pUp->eU==0 && pUp->u.iKey==0) ); - testcase( pUp->eU==0 ); - jsonPrintf(30, pStr, "[%d]", pUp->u.iKey); - }else{ - assert( pUp->eType==JSON_OBJECT ); - if( (pNode->jnFlags & JNODE_LABEL)==0 ) pNode--; - jsonAppendObjectPathElement(pStr, pNode); - } + return n; } /* Return the value of a column */ static int jsonEachColumn( sqlite3_vtab_cursor *cur, /* The cursor */ sqlite3_context *ctx, /* First argument to sqlite3_result_...() */ - int i /* Which column to return */ + int iColumn /* Which column to return */ ){ JsonEachCursor *p = (JsonEachCursor*)cur; - JsonNode *pThis = &p->sParse.aNode[p->i]; - switch( i ){ + switch( iColumn ){ case JEACH_KEY: { - if( p->i==0 ) break; - if( p->eType==JSON_OBJECT ){ - jsonReturn(&p->sParse, pThis, ctx); - }else if( p->eType==JSON_ARRAY ){ - u32 iKey; - if( p->bRecursive ){ - if( p->iRowid==0 ) break; - assert( p->sParse.aNode[p->sParse.aUp[p->i]].eU==3 ); - iKey = p->sParse.aNode[p->sParse.aUp[p->i]].u.iKey; + if( p->nParent==0 ){ + u32 n, j; + if( p->nRoot==1 ) break; + j = jsonEachPathLength(p); + n = p->nRoot - j; + if( n==0 ){ + break; + }else if( p->path.zBuf[j]=='[' ){ + i64 x; + sqlite3Atoi64(&p->path.zBuf[j+1], &x, n-1, SQLITE_UTF8); + sqlite3_result_int64(ctx, x); + }else if( p->path.zBuf[j+1]=='"' ){ + sqlite3_result_text(ctx, &p->path.zBuf[j+2], n-3, SQLITE_TRANSIENT); }else{ - iKey = p->iRowid; + sqlite3_result_text(ctx, &p->path.zBuf[j+1], n-1, SQLITE_TRANSIENT); } - sqlite3_result_int64(ctx, (sqlite3_int64)iKey); + break; + } + if( p->eType==JSONB_OBJECT ){ + jsonReturnFromBlob(&p->sParse, p->i, ctx, 1); + }else{ + assert( p->eType==JSONB_ARRAY ); + sqlite3_result_int64(ctx, p->aParent[p->nParent-1].iKey); } break; } case JEACH_VALUE: { - if( pThis->jnFlags & JNODE_LABEL ) pThis++; - jsonReturn(&p->sParse, pThis, ctx); + u32 i = jsonSkipLabel(p); + jsonReturnFromBlob(&p->sParse, i, ctx, 1); break; } case JEACH_TYPE: { - if( pThis->jnFlags & JNODE_LABEL ) pThis++; - sqlite3_result_text(ctx, jsonType[pThis->eType], -1, SQLITE_STATIC); + u32 i = jsonSkipLabel(p); + u8 eType = p->sParse.aBlob[i] & 0x0f; + sqlite3_result_text(ctx, jsonbType[eType], -1, SQLITE_STATIC); break; } case JEACH_ATOM: { - if( pThis->jnFlags & JNODE_LABEL ) pThis++; - if( pThis->eType>=JSON_ARRAY ) break; - jsonReturn(&p->sParse, pThis, ctx); + u32 i = jsonSkipLabel(p); + if( (p->sParse.aBlob[i] & 0x0f)sParse, i, ctx, 1); + } break; } case JEACH_ID: { - sqlite3_result_int64(ctx, - (sqlite3_int64)p->i + ((pThis->jnFlags & JNODE_LABEL)!=0)); + sqlite3_result_int64(ctx, (sqlite3_int64)p->i); break; } case JEACH_PARENT: { - if( p->i>p->iBegin && p->bRecursive ){ - sqlite3_result_int64(ctx, (sqlite3_int64)p->sParse.aUp[p->i]); + if( p->nParent>0 && p->bRecursive ){ + sqlite3_result_int64(ctx, p->aParent[p->nParent-1].iHead); } break; } case JEACH_FULLKEY: { - JsonString x; - jsonInit(&x, ctx); - if( p->bRecursive ){ - jsonEachComputePath(p, &x, p->i); - }else{ - if( p->zRoot ){ - jsonAppendRaw(&x, p->zRoot, (int)strlen(p->zRoot)); - }else{ - jsonAppendChar(&x, '$'); - } - if( p->eType==JSON_ARRAY ){ - jsonPrintf(30, &x, "[%d]", p->iRowid); - }else if( p->eType==JSON_OBJECT ){ - jsonAppendObjectPathElement(&x, pThis); - } - } - jsonResult(&x); + u64 nBase = p->path.nUsed; + if( p->nParent ) jsonAppendPathName(p); + sqlite3_result_text64(ctx, p->path.zBuf, p->path.nUsed, + SQLITE_TRANSIENT, SQLITE_UTF8); + p->path.nUsed = nBase; break; } case JEACH_PATH: { - if( p->bRecursive ){ - JsonString x; - jsonInit(&x, ctx); - jsonEachComputePath(p, &x, p->sParse.aUp[p->i]); - jsonResult(&x); - break; - } - /* For json_each() path and root are the same so fall through - ** into the root case */ - /* no break */ deliberate_fall_through + u32 n = jsonEachPathLength(p); + sqlite3_result_text64(ctx, p->path.zBuf, n, + SQLITE_TRANSIENT, SQLITE_UTF8); + break; } default: { - const char *zRoot = p->zRoot; - if( zRoot==0 ) zRoot = "$"; - sqlite3_result_text(ctx, zRoot, -1, SQLITE_STATIC); + sqlite3_result_text(ctx, p->path.zBuf, p->nRoot, SQLITE_STATIC); break; } case JEACH_JSON: { - assert( i==JEACH_JSON ); - sqlite3_result_text(ctx, p->sParse.zJson, -1, SQLITE_STATIC); + if( p->sParse.zJson==0 ){ + sqlite3_result_blob(ctx, p->sParse.aBlob, p->sParse.nBlob, + SQLITE_STATIC); + }else{ + sqlite3_result_text(ctx, p->sParse.zJson, -1, SQLITE_STATIC); + } break; } } @@ -206219,86 +208172,101 @@ static int jsonEachFilter( int argc, sqlite3_value **argv ){ JsonEachCursor *p = (JsonEachCursor*)cur; - const char *z; const char *zRoot = 0; - sqlite3_int64 n; + u32 i, n, sz; UNUSED_PARAMETER(idxStr); UNUSED_PARAMETER(argc); jsonEachCursorReset(p); if( idxNum==0 ) return SQLITE_OK; - z = (const char*)sqlite3_value_text(argv[0]); - if( z==0 ) return SQLITE_OK; memset(&p->sParse, 0, sizeof(p->sParse)); p->sParse.nJPRef = 1; - if( sqlite3ValueIsOfClass(argv[0], sqlite3RCStrUnref) ){ - p->sParse.zJson = sqlite3RCStrRef((char*)z); - }else{ - n = sqlite3_value_bytes(argv[0]); - p->sParse.zJson = sqlite3RCStrNew( n+1 ); - if( p->sParse.zJson==0 ) return SQLITE_NOMEM; - memcpy(p->sParse.zJson, z, (size_t)n+1); - } - p->sParse.bJsonIsRCStr = 1; - p->zJson = p->sParse.zJson; - if( jsonParse(&p->sParse, 0) ){ - int rc = SQLITE_NOMEM; - if( p->sParse.oom==0 ){ - sqlite3_free(cur->pVtab->zErrMsg); - cur->pVtab->zErrMsg = sqlite3_mprintf("malformed JSON"); - if( cur->pVtab->zErrMsg ) rc = SQLITE_ERROR; + p->sParse.db = p->db; + if( sqlite3_value_type(argv[0])==SQLITE_BLOB ){ + if( jsonFuncArgMightBeBinary(argv[0]) ){ + p->sParse.nBlob = sqlite3_value_bytes(argv[0]); + p->sParse.aBlob = (u8*)sqlite3_value_blob(argv[0]); + }else{ + goto json_each_malformed_input; } - jsonEachCursorReset(p); - return rc; - }else if( p->bRecursive && jsonParseFindParents(&p->sParse) ){ - jsonEachCursorReset(p); - return SQLITE_NOMEM; }else{ - JsonNode *pNode = 0; - if( idxNum==3 ){ - const char *zErr = 0; - zRoot = (const char*)sqlite3_value_text(argv[1]); - if( zRoot==0 ) return SQLITE_OK; - n = sqlite3_value_bytes(argv[1]); - p->zRoot = sqlite3_malloc64( n+1 ); - if( p->zRoot==0 ) return SQLITE_NOMEM; - memcpy(p->zRoot, zRoot, (size_t)n+1); - if( zRoot[0]!='$' ){ - zErr = zRoot; - }else{ - pNode = jsonLookupStep(&p->sParse, 0, p->zRoot+1, 0, &zErr); + p->sParse.zJson = (char*)sqlite3_value_text(argv[0]); + p->sParse.nJson = sqlite3_value_bytes(argv[0]); + if( p->sParse.zJson==0 ){ + p->i = p->iEnd = 0; + return SQLITE_OK; + } + if( jsonConvertTextToBlob(&p->sParse, 0) ){ + if( p->sParse.oom ){ + return SQLITE_NOMEM; } - if( zErr ){ + goto json_each_malformed_input; + } + } + if( idxNum==3 ){ + zRoot = (const char*)sqlite3_value_text(argv[1]); + if( zRoot==0 ) return SQLITE_OK; + if( zRoot[0]!='$' ){ + sqlite3_free(cur->pVtab->zErrMsg); + cur->pVtab->zErrMsg = jsonBadPathError(0, zRoot); + jsonEachCursorReset(p); + return cur->pVtab->zErrMsg ? SQLITE_ERROR : SQLITE_NOMEM; + } + p->nRoot = sqlite3Strlen30(zRoot); + if( zRoot[1]==0 ){ + i = p->i = 0; + p->eType = 0; + }else{ + i = jsonLookupStep(&p->sParse, 0, zRoot+1, 0); + if( JSON_LOOKUP_ISERROR(i) ){ + if( i==JSON_LOOKUP_NOTFOUND ){ + p->i = 0; + p->eType = 0; + p->iEnd = 0; + return SQLITE_OK; + } sqlite3_free(cur->pVtab->zErrMsg); - cur->pVtab->zErrMsg = jsonPathSyntaxError(zErr); + cur->pVtab->zErrMsg = jsonBadPathError(0, zRoot); jsonEachCursorReset(p); return cur->pVtab->zErrMsg ? SQLITE_ERROR : SQLITE_NOMEM; - }else if( pNode==0 ){ - return SQLITE_OK; } - }else{ - pNode = p->sParse.aNode; - } - p->iBegin = p->i = (int)(pNode - p->sParse.aNode); - p->eType = pNode->eType; - if( p->eType>=JSON_ARRAY ){ - assert( pNode->eU==0 ); - VVA( pNode->eU = 3 ); - pNode->u.iKey = 0; - p->iEnd = p->i + pNode->n + 1; - if( p->bRecursive ){ - p->eType = p->sParse.aNode[p->sParse.aUp[p->i]].eType; - if( p->i>0 && (p->sParse.aNode[p->i-1].jnFlags & JNODE_LABEL)!=0 ){ - p->i--; - } + if( p->sParse.iLabel ){ + p->i = p->sParse.iLabel; + p->eType = JSONB_OBJECT; }else{ - p->i++; + p->i = i; + p->eType = JSONB_ARRAY; } - }else{ - p->iEnd = p->i+1; } + jsonAppendRaw(&p->path, zRoot, p->nRoot); + }else{ + i = p->i = 0; + p->eType = 0; + p->nRoot = 1; + jsonAppendRaw(&p->path, "$", 1); + } + p->nParent = 0; + n = jsonbPayloadSize(&p->sParse, i, &sz); + p->iEnd = i+n+sz; + if( (p->sParse.aBlob[i] & 0x0f)>=JSONB_ARRAY && !p->bRecursive ){ + p->i = i + n; + p->eType = p->sParse.aBlob[i] & 0x0f; + p->aParent = sqlite3DbMallocZero(p->db, sizeof(JsonParent)); + if( p->aParent==0 ) return SQLITE_NOMEM; + p->nParent = 1; + p->nParentAlloc = 1; + p->aParent[0].iKey = 0; + p->aParent[0].iEnd = p->iEnd; + p->aParent[0].iHead = p->i; + p->aParent[0].iValue = i; } return SQLITE_OK; + +json_each_malformed_input: + sqlite3_free(cur->pVtab->zErrMsg); + cur->pVtab->zErrMsg = sqlite3_mprintf("malformed JSON"); + jsonEachCursorReset(p); + return cur->pVtab->zErrMsg ? SQLITE_ERROR : SQLITE_NOMEM; } /* The methods of the json_each virtual table */ @@ -206367,34 +208335,57 @@ static sqlite3_module jsonTreeModule = { SQLITE_PRIVATE void sqlite3RegisterJsonFunctions(void){ #ifndef SQLITE_OMIT_JSON static FuncDef aJsonFunc[] = { - JFUNCTION(json, 1, 0, jsonRemoveFunc), - JFUNCTION(json_array, -1, 0, jsonArrayFunc), - JFUNCTION(json_array_length, 1, 0, jsonArrayLengthFunc), - JFUNCTION(json_array_length, 2, 0, jsonArrayLengthFunc), - JFUNCTION(json_error_position,1, 0, jsonErrorFunc), - JFUNCTION(json_extract, -1, 0, jsonExtractFunc), - JFUNCTION(->, 2, JSON_JSON, jsonExtractFunc), - JFUNCTION(->>, 2, JSON_SQL, jsonExtractFunc), - JFUNCTION(json_insert, -1, 0, jsonSetFunc), - JFUNCTION(json_object, -1, 0, jsonObjectFunc), - JFUNCTION(json_patch, 2, 0, jsonPatchFunc), - JFUNCTION(json_quote, 1, 0, jsonQuoteFunc), - JFUNCTION(json_remove, -1, 0, jsonRemoveFunc), - JFUNCTION(json_replace, -1, 0, jsonReplaceFunc), - JFUNCTION(json_set, -1, JSON_ISSET, jsonSetFunc), - JFUNCTION(json_type, 1, 0, jsonTypeFunc), - JFUNCTION(json_type, 2, 0, jsonTypeFunc), - JFUNCTION(json_valid, 1, 0, jsonValidFunc), + /* sqlite3_result_subtype() ----, ,--- sqlite3_value_subtype() */ + /* | | */ + /* Uses cache ------, | | ,---- Returns JSONB */ + /* | | | | */ + /* Number of arguments ---, | | | | ,--- Flags */ + /* | | | | | | */ + JFUNCTION(json, 1,1,1, 0,0,0, jsonRemoveFunc), + JFUNCTION(jsonb, 1,1,0, 0,1,0, jsonRemoveFunc), + JFUNCTION(json_array, -1,0,1, 1,0,0, jsonArrayFunc), + JFUNCTION(jsonb_array, -1,0,1, 1,1,0, jsonArrayFunc), + JFUNCTION(json_array_length, 1,1,0, 0,0,0, jsonArrayLengthFunc), + JFUNCTION(json_array_length, 2,1,0, 0,0,0, jsonArrayLengthFunc), + JFUNCTION(json_error_position,1,1,0, 0,0,0, jsonErrorFunc), + JFUNCTION(json_extract, -1,1,1, 0,0,0, jsonExtractFunc), + JFUNCTION(jsonb_extract, -1,1,0, 0,1,0, jsonExtractFunc), + JFUNCTION(->, 2,1,1, 0,0,JSON_JSON, jsonExtractFunc), + JFUNCTION(->>, 2,1,0, 0,0,JSON_SQL, jsonExtractFunc), + JFUNCTION(json_insert, -1,1,1, 1,0,0, jsonSetFunc), + JFUNCTION(jsonb_insert, -1,1,0, 1,1,0, jsonSetFunc), + JFUNCTION(json_object, -1,0,1, 1,0,0, jsonObjectFunc), + JFUNCTION(jsonb_object, -1,0,1, 1,1,0, jsonObjectFunc), + JFUNCTION(json_patch, 2,1,1, 0,0,0, jsonPatchFunc), + JFUNCTION(jsonb_patch, 2,1,0, 0,1,0, jsonPatchFunc), + JFUNCTION(json_quote, 1,0,1, 1,0,0, jsonQuoteFunc), + JFUNCTION(json_remove, -1,1,1, 0,0,0, jsonRemoveFunc), + JFUNCTION(jsonb_remove, -1,1,0, 0,1,0, jsonRemoveFunc), + JFUNCTION(json_replace, -1,1,1, 1,0,0, jsonReplaceFunc), + JFUNCTION(jsonb_replace, -1,1,0, 1,1,0, jsonReplaceFunc), + JFUNCTION(json_set, -1,1,1, 1,0,JSON_ISSET, jsonSetFunc), + JFUNCTION(jsonb_set, -1,1,0, 1,1,JSON_ISSET, jsonSetFunc), + JFUNCTION(json_type, 1,1,0, 0,0,0, jsonTypeFunc), + JFUNCTION(json_type, 2,1,0, 0,0,0, jsonTypeFunc), + JFUNCTION(json_valid, 1,1,0, 0,0,0, jsonValidFunc), + JFUNCTION(json_valid, 2,1,0, 0,0,0, jsonValidFunc), #if SQLITE_DEBUG - JFUNCTION(json_parse, 1, 0, jsonParseFunc), - JFUNCTION(json_test1, 1, 0, jsonTest1Func), + JFUNCTION(json_parse, 1,1,0, 0,0,0, jsonParseFunc), #endif WAGGREGATE(json_group_array, 1, 0, 0, jsonArrayStep, jsonArrayFinal, jsonArrayValue, jsonGroupInverse, - SQLITE_SUBTYPE|SQLITE_UTF8|SQLITE_DETERMINISTIC), + SQLITE_SUBTYPE|SQLITE_RESULT_SUBTYPE|SQLITE_UTF8| + SQLITE_DETERMINISTIC), + WAGGREGATE(jsonb_group_array, 1, JSON_BLOB, 0, + jsonArrayStep, jsonArrayFinal, jsonArrayValue, jsonGroupInverse, + SQLITE_SUBTYPE|SQLITE_RESULT_SUBTYPE|SQLITE_UTF8|SQLITE_DETERMINISTIC), WAGGREGATE(json_group_object, 2, 0, 0, jsonObjectStep, jsonObjectFinal, jsonObjectValue, jsonGroupInverse, - SQLITE_SUBTYPE|SQLITE_UTF8|SQLITE_DETERMINISTIC) + SQLITE_SUBTYPE|SQLITE_RESULT_SUBTYPE|SQLITE_UTF8|SQLITE_DETERMINISTIC), + WAGGREGATE(jsonb_group_object,2, JSON_BLOB, 0, + jsonObjectStep, jsonObjectFinal, jsonObjectValue, jsonGroupInverse, + SQLITE_SUBTYPE|SQLITE_RESULT_SUBTYPE|SQLITE_UTF8| + SQLITE_DETERMINISTIC) }; sqlite3InsertBuiltinFuncs(aJsonFunc, ArraySize(aJsonFunc)); #endif @@ -207142,7 +209133,7 @@ static int nodeAcquire( ** increase its reference count and return it. */ if( (pNode = nodeHashLookup(pRtree, iNode))!=0 ){ - if( pParent && pParent!=pNode->pParent ){ + if( pParent && ALWAYS(pParent!=pNode->pParent) ){ RTREE_IS_CORRUPT(pRtree); return SQLITE_CORRUPT_VTAB; } @@ -209877,7 +211868,7 @@ static int rtreeSqlInit( } sqlite3_free(zSql); } - if( pRtree->nAux ){ + if( pRtree->nAux && rc!=SQLITE_NOMEM ){ pRtree->zReadAuxSql = sqlite3_mprintf( "SELECT * FROM \"%w\".\"%w_rowid\" WHERE rowid=?1", zDb, zPrefix); @@ -210566,15 +212557,13 @@ static int rtreeCheckTable( check.zTab = zTab; /* Find the number of auxiliary columns */ - if( check.rc==SQLITE_OK ){ - pStmt = rtreeCheckPrepare(&check, "SELECT * FROM %Q.'%q_rowid'", zDb, zTab); - if( pStmt ){ - nAux = sqlite3_column_count(pStmt) - 2; - sqlite3_finalize(pStmt); - }else - if( check.rc!=SQLITE_NOMEM ){ - check.rc = SQLITE_OK; - } + pStmt = rtreeCheckPrepare(&check, "SELECT * FROM %Q.'%q_rowid'", zDb, zTab); + if( pStmt ){ + nAux = sqlite3_column_count(pStmt) - 2; + sqlite3_finalize(pStmt); + }else + if( check.rc!=SQLITE_NOMEM ){ + check.rc = SQLITE_OK; } /* Find number of dimensions in the rtree table. */ @@ -210629,6 +212618,7 @@ static int rtreeIntegrity( if( rc==SQLITE_OK && *pzErr ){ *pzErr = sqlite3_mprintf("In RTree %s.%s:\n%z", pRtree->zDb, pRtree->zName, *pzErr); + if( (*pzErr)==0 ) rc = SQLITE_NOMEM; } return rc; } @@ -223299,9 +225289,7 @@ SQLITE_API void sqlite3session_delete(sqlite3_session *pSession){ ** associated hash-tables. */ sessionDeleteTable(pSession, pSession->pTable); - /* Assert that all allocations have been freed and then free the - ** session object itself. */ - // assert( pSession->nMalloc==0 ); + /* Free the session object. */ sqlite3_free(pSession); } @@ -227514,8 +229502,11 @@ struct Fts5PhraseIter { ** created with the "columnsize=0" option. ** ** xColumnText: -** This function attempts to retrieve the text of column iCol of the -** current document. If successful, (*pz) is set to point to a buffer +** If parameter iCol is less than zero, or greater than or equal to the +** number of columns in the table, SQLITE_RANGE is returned. +** +** Otherwise, this function attempts to retrieve the text of column iCol of +** the current document. If successful, (*pz) is set to point to a buffer ** containing the text in utf-8 encoding, (*pn) is set to the size in bytes ** (not characters) of the buffer and SQLITE_OK is returned. Otherwise, ** if an error occurs, an SQLite error code is returned and the final values @@ -227525,8 +229516,10 @@ struct Fts5PhraseIter { ** Returns the number of phrases in the current query expression. ** ** xPhraseSize: -** Returns the number of tokens in phrase iPhrase of the query. Phrases -** are numbered starting from zero. +** If parameter iCol is less than zero, or greater than or equal to the +** number of phrases in the current query, as returned by xPhraseCount, +** 0 is returned. Otherwise, this function returns the number of tokens in +** phrase iPhrase of the query. Phrases are numbered starting from zero. ** ** xInstCount: ** Set *pnInst to the total number of occurrences of all phrases within @@ -227542,12 +229535,13 @@ struct Fts5PhraseIter { ** Query for the details of phrase match iIdx within the current row. ** Phrase matches are numbered starting from zero, so the iIdx argument ** should be greater than or equal to zero and smaller than the value -** output by xInstCount(). +** output by xInstCount(). If iIdx is less than zero or greater than +** or equal to the value returned by xInstCount(), SQLITE_RANGE is returned. ** -** Usually, output parameter *piPhrase is set to the phrase number, *piCol +** Otherwise, output parameter *piPhrase is set to the phrase number, *piCol ** to the column in which it occurs and *piOff the token offset of the -** first token of the phrase. Returns SQLITE_OK if successful, or an error -** code (i.e. SQLITE_NOMEM) if an error occurs. +** first token of the phrase. SQLITE_OK is returned if successful, or an +** error code (i.e. SQLITE_NOMEM) if an error occurs. ** ** This API can be quite slow if used with an FTS5 table created with the ** "detail=none" or "detail=column" option. @@ -227573,6 +229567,10 @@ struct Fts5PhraseIter { ** Invoking Api.xUserData() returns a copy of the pointer passed as ** the third argument to pUserData. ** +** If parameter iPhrase is less than zero, or greater than or equal to +** the number of phrases in the query, as returned by xPhraseCount(), +** this function returns SQLITE_RANGE. +** ** If the callback function returns any value other than SQLITE_OK, the ** query is abandoned and the xQueryPhrase function returns immediately. ** If the returned value is SQLITE_DONE, xQueryPhrase returns SQLITE_OK. @@ -227687,9 +229685,42 @@ struct Fts5PhraseIter { ** ** xPhraseNextColumn() ** See xPhraseFirstColumn above. +** +** xQueryToken(pFts5, iPhrase, iToken, ppToken, pnToken) +** This is used to access token iToken of phrase iPhrase of the current +** query. Before returning, output parameter *ppToken is set to point +** to a buffer containing the requested token, and *pnToken to the +** size of this buffer in bytes. +** +** If iPhrase or iToken are less than zero, or if iPhrase is greater than +** or equal to the number of phrases in the query as reported by +** xPhraseCount(), or if iToken is equal to or greater than the number of +** tokens in the phrase, SQLITE_RANGE is returned and *ppToken and *pnToken + are both zeroed. +** +** The output text is not a copy of the query text that specified the +** token. It is the output of the tokenizer module. For tokendata=1 +** tables, this includes any embedded 0x00 and trailing data. +** +** xInstToken(pFts5, iIdx, iToken, ppToken, pnToken) +** This is used to access token iToken of phrase hit iIdx within the +** current row. If iIdx is less than zero or greater than or equal to the +** value returned by xInstCount(), SQLITE_RANGE is returned. Otherwise, +** output variable (*ppToken) is set to point to a buffer containing the +** matching document token, and (*pnToken) to the size of that buffer in +** bytes. This API is not available if the specified token matches a +** prefix query term. In that case both output variables are always set +** to 0. +** +** The output text is not a copy of the document text that was tokenized. +** It is the output of the tokenizer module. For tokendata=1 tables, this +** includes any embedded 0x00 and trailing data. +** +** This API can be quite slow if used with an FTS5 table created with the +** "detail=none" or "detail=column" option. */ struct Fts5ExtensionApi { - int iVersion; /* Currently always set to 2 */ + int iVersion; /* Currently always set to 3 */ void *(*xUserData)(Fts5Context*); @@ -227724,6 +229755,13 @@ struct Fts5ExtensionApi { int (*xPhraseFirstColumn)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*); void (*xPhraseNextColumn)(Fts5Context*, Fts5PhraseIter*, int *piCol); + + /* Below this point are iVersion>=3 only */ + int (*xQueryToken)(Fts5Context*, + int iPhrase, int iToken, + const char **ppToken, int *pnToken + ); + int (*xInstToken)(Fts5Context*, int iIdx, int iToken, const char**, int*); }; /* @@ -228198,6 +230236,7 @@ struct Fts5Config { char *zContent; /* content table */ char *zContentRowid; /* "content_rowid=" option value */ int bColumnsize; /* "columnsize=" option value (dflt==1) */ + int bTokendata; /* "tokendata=" option value (dflt==0) */ int eDetail; /* FTS5_DETAIL_XXX value */ char *zContentExprlist; Fts5Tokenizer *pTok; @@ -228386,17 +230425,19 @@ struct Fts5IndexIter { /* ** Values used as part of the flags argument passed to IndexQuery(). */ -#define FTS5INDEX_QUERY_PREFIX 0x0001 /* Prefix query */ -#define FTS5INDEX_QUERY_DESC 0x0002 /* Docs in descending rowid order */ -#define FTS5INDEX_QUERY_TEST_NOIDX 0x0004 /* Do not use prefix index */ -#define FTS5INDEX_QUERY_SCAN 0x0008 /* Scan query (fts5vocab) */ +#define FTS5INDEX_QUERY_PREFIX 0x0001 /* Prefix query */ +#define FTS5INDEX_QUERY_DESC 0x0002 /* Docs in descending rowid order */ +#define FTS5INDEX_QUERY_TEST_NOIDX 0x0004 /* Do not use prefix index */ +#define FTS5INDEX_QUERY_SCAN 0x0008 /* Scan query (fts5vocab) */ /* The following are used internally by the fts5_index.c module. They are ** defined here only to make it easier to avoid clashes with the flags ** above. */ -#define FTS5INDEX_QUERY_SKIPEMPTY 0x0010 -#define FTS5INDEX_QUERY_NOOUTPUT 0x0020 -#define FTS5INDEX_QUERY_SKIPHASH 0x0040 +#define FTS5INDEX_QUERY_SKIPEMPTY 0x0010 +#define FTS5INDEX_QUERY_NOOUTPUT 0x0020 +#define FTS5INDEX_QUERY_SKIPHASH 0x0040 +#define FTS5INDEX_QUERY_NOTOKENDATA 0x0080 +#define FTS5INDEX_QUERY_SCANONETERM 0x0100 /* ** Create/destroy an Fts5Index object. @@ -228465,6 +230506,10 @@ static void *sqlite3Fts5StructureRef(Fts5Index*); static void sqlite3Fts5StructureRelease(void*); static int sqlite3Fts5StructureTest(Fts5Index*, void*); +/* +** Used by xInstToken(): +*/ +static int sqlite3Fts5IterToken(Fts5IndexIter*, i64, int, int, const char**, int*); /* ** Insert or remove data to or from the index. Each time a document is @@ -228542,6 +230587,13 @@ static int sqlite3Fts5IndexLoadConfig(Fts5Index *p); static int sqlite3Fts5IndexGetOrigin(Fts5Index *p, i64 *piOrigin); static int sqlite3Fts5IndexContentlessDelete(Fts5Index *p, i64 iOrigin, i64 iRowid); +static void sqlite3Fts5IndexIterClearTokendata(Fts5IndexIter*); + +/* Used to populate hash tables for xInstToken in detail=none/column mode. */ +static int sqlite3Fts5IndexIterWriteTokendata( + Fts5IndexIter*, const char*, int, i64 iRowid, int iCol, int iOff +); + /* ** End of interface to code in fts5_index.c. **************************************************************************/ @@ -228647,6 +230699,7 @@ static void sqlite3Fts5HashScanNext(Fts5Hash*); static int sqlite3Fts5HashScanEof(Fts5Hash*); static void sqlite3Fts5HashScanEntry(Fts5Hash *, const char **pzTerm, /* OUT: term (nul-terminated) */ + int *pnTerm, /* OUT: Size of term in bytes */ const u8 **ppDoclist, /* OUT: pointer to doclist */ int *pnDoclist /* OUT: size of doclist in bytes */ ); @@ -228773,6 +230826,10 @@ static int sqlite3Fts5ExprClonePhrase(Fts5Expr*, int, Fts5Expr**); static int sqlite3Fts5ExprPhraseCollist(Fts5Expr *, int, const u8 **, int *); +static int sqlite3Fts5ExprQueryToken(Fts5Expr*, int, int, const char**, int*); +static int sqlite3Fts5ExprInstToken(Fts5Expr*, i64, int, int, int, int, const char**, int*); +static void sqlite3Fts5ExprClearTokens(Fts5Expr*); + /******************************************* ** The fts5_expr.c API above this point is used by the other hand-written ** C code in this module. The interfaces below this point are called by @@ -230588,6 +232645,14 @@ static int fts5HighlightCb( } if( iPos==p->iRangeEnd ){ + if( p->bOpen ){ + if( p->iter.iStart>=0 && iPos>=p->iter.iStart ){ + fts5HighlightAppend(&rc, p, &p->zIn[p->iOff], iEndOff - p->iOff); + p->iOff = iEndOff; + } + fts5HighlightAppend(&rc, p, p->zClose, -1); + p->bOpen = 0; + } fts5HighlightAppend(&rc, p, &p->zIn[p->iOff], iEndOff - p->iOff); p->iOff = iEndOff; } @@ -230621,8 +232686,10 @@ static void fts5HighlightFunction( ctx.zClose = (const char*)sqlite3_value_text(apVal[2]); ctx.iRangeEnd = -1; rc = pApi->xColumnText(pFts, iCol, &ctx.zIn, &ctx.nIn); - - if( ctx.zIn ){ + if( rc==SQLITE_RANGE ){ + sqlite3_result_text(pCtx, "", -1, SQLITE_STATIC); + rc = SQLITE_OK; + }else if( ctx.zIn ){ if( rc==SQLITE_OK ){ rc = fts5CInstIterInit(pApi, pFts, iCol, &ctx.iter); } @@ -231189,6 +233256,7 @@ static void sqlite3Fts5BufferAppendBlob( ){ if( nData ){ if( fts5BufferGrow(pRc, pBuf, nData) ) return; + assert( pBuf->p!=0 ); memcpy(&pBuf->p[pBuf->n], pData, nData); pBuf->n += nData; } @@ -231290,6 +233358,7 @@ static int sqlite3Fts5PoslistNext64( i64 *piOff /* IN/OUT: Current offset */ ){ int i = *pi; + assert( a!=0 || i==0 ); if( i>=n ){ /* EOF */ *piOff = -1; @@ -231297,6 +233366,7 @@ static int sqlite3Fts5PoslistNext64( }else{ i64 iOff = *piOff; u32 iVal; + assert( a!=0 ); fts5FastGetVarint32(a, i, iVal); if( iVal<=1 ){ if( iVal==0 ){ @@ -231928,6 +233998,16 @@ static int fts5ConfigParseSpecial( return rc; } + if( sqlite3_strnicmp("tokendata", zCmd, nCmd)==0 ){ + if( (zArg[0]!='0' && zArg[0]!='1') || zArg[1]!='\0' ){ + *pzErr = sqlite3_mprintf("malformed tokendata=... directive"); + rc = SQLITE_ERROR; + }else{ + pConfig->bTokendata = (zArg[0]=='1'); + } + return rc; + } + *pzErr = sqlite3_mprintf("unrecognized option: \"%.*s\"", nCmd, zCmd); return SQLITE_ERROR; } @@ -232661,7 +234741,9 @@ struct Fts5ExprNode { struct Fts5ExprTerm { u8 bPrefix; /* True for a prefix term */ u8 bFirst; /* True if token must be first in column */ - char *zTerm; /* nul-terminated term */ + char *pTerm; /* Term data */ + int nQueryTerm; /* Effective size of term in bytes */ + int nFullTerm; /* Size of term in bytes incl. tokendata */ Fts5IndexIter *pIter; /* Iterator for this term */ Fts5ExprTerm *pSynonym; /* Pointer to first in list of synonyms */ }; @@ -233528,7 +235610,7 @@ static int fts5ExprNearInitAll( p->pIter = 0; } rc = sqlite3Fts5IndexQuery( - pExpr->pIndex, p->zTerm, (int)strlen(p->zTerm), + pExpr->pIndex, p->pTerm, p->nQueryTerm, (pTerm->bPrefix ? FTS5INDEX_QUERY_PREFIX : 0) | (pExpr->bDesc ? FTS5INDEX_QUERY_DESC : 0), pNear->pColset, @@ -234165,7 +236247,7 @@ static void fts5ExprPhraseFree(Fts5ExprPhrase *pPhrase){ Fts5ExprTerm *pSyn; Fts5ExprTerm *pNext; Fts5ExprTerm *pTerm = &pPhrase->aTerm[i]; - sqlite3_free(pTerm->zTerm); + sqlite3_free(pTerm->pTerm); sqlite3Fts5IterClose(pTerm->pIter); for(pSyn=pTerm->pSynonym; pSyn; pSyn=pNext){ pNext = pSyn->pSynonym; @@ -234263,6 +236345,7 @@ static Fts5ExprNearset *sqlite3Fts5ParseNearset( typedef struct TokenCtx TokenCtx; struct TokenCtx { Fts5ExprPhrase *pPhrase; + Fts5Config *pConfig; int rc; }; @@ -234296,8 +236379,12 @@ static int fts5ParseTokenize( rc = SQLITE_NOMEM; }else{ memset(pSyn, 0, (size_t)nByte); - pSyn->zTerm = ((char*)pSyn) + sizeof(Fts5ExprTerm) + sizeof(Fts5Buffer); - memcpy(pSyn->zTerm, pToken, nToken); + pSyn->pTerm = ((char*)pSyn) + sizeof(Fts5ExprTerm) + sizeof(Fts5Buffer); + pSyn->nFullTerm = pSyn->nQueryTerm = nToken; + if( pCtx->pConfig->bTokendata ){ + pSyn->nQueryTerm = (int)strlen(pSyn->pTerm); + } + memcpy(pSyn->pTerm, pToken, nToken); pSyn->pSynonym = pPhrase->aTerm[pPhrase->nTerm-1].pSynonym; pPhrase->aTerm[pPhrase->nTerm-1].pSynonym = pSyn; } @@ -234322,7 +236409,11 @@ static int fts5ParseTokenize( if( rc==SQLITE_OK ){ pTerm = &pPhrase->aTerm[pPhrase->nTerm++]; memset(pTerm, 0, sizeof(Fts5ExprTerm)); - pTerm->zTerm = sqlite3Fts5Strndup(&rc, pToken, nToken); + pTerm->pTerm = sqlite3Fts5Strndup(&rc, pToken, nToken); + pTerm->nFullTerm = pTerm->nQueryTerm = nToken; + if( pCtx->pConfig->bTokendata && rc==SQLITE_OK ){ + pTerm->nQueryTerm = (int)strlen(pTerm->pTerm); + } } } @@ -234389,6 +236480,7 @@ static Fts5ExprPhrase *sqlite3Fts5ParseTerm( memset(&sCtx, 0, sizeof(TokenCtx)); sCtx.pPhrase = pAppend; + sCtx.pConfig = pConfig; rc = fts5ParseStringFromToken(pToken, &z); if( rc==SQLITE_OK ){ @@ -234436,12 +236528,15 @@ static int sqlite3Fts5ExprClonePhrase( Fts5Expr **ppNew ){ int rc = SQLITE_OK; /* Return code */ - Fts5ExprPhrase *pOrig; /* The phrase extracted from pExpr */ + Fts5ExprPhrase *pOrig = 0; /* The phrase extracted from pExpr */ Fts5Expr *pNew = 0; /* Expression to return via *ppNew */ - TokenCtx sCtx = {0,0}; /* Context object for fts5ParseTokenize */ - - pOrig = pExpr->apExprPhrase[iPhrase]; - pNew = (Fts5Expr*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5Expr)); + TokenCtx sCtx = {0,0,0}; /* Context object for fts5ParseTokenize */ + if( iPhrase<0 || iPhrase>=pExpr->nPhrase ){ + rc = SQLITE_RANGE; + }else{ + pOrig = pExpr->apExprPhrase[iPhrase]; + pNew = (Fts5Expr*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5Expr)); + } if( rc==SQLITE_OK ){ pNew->apExprPhrase = (Fts5ExprPhrase**)sqlite3Fts5MallocZero(&rc, sizeof(Fts5ExprPhrase*)); @@ -234454,7 +236549,7 @@ static int sqlite3Fts5ExprClonePhrase( pNew->pRoot->pNear = (Fts5ExprNearset*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5ExprNearset) + sizeof(Fts5ExprPhrase*)); } - if( rc==SQLITE_OK ){ + if( rc==SQLITE_OK && ALWAYS(pOrig!=0) ){ Fts5Colset *pColsetOrig = pOrig->pNode->pNear->pColset; if( pColsetOrig ){ sqlite3_int64 nByte; @@ -234468,26 +236563,27 @@ static int sqlite3Fts5ExprClonePhrase( } } - if( pOrig->nTerm ){ - int i; /* Used to iterate through phrase terms */ - for(i=0; rc==SQLITE_OK && inTerm; i++){ - int tflags = 0; - Fts5ExprTerm *p; - for(p=&pOrig->aTerm[i]; p && rc==SQLITE_OK; p=p->pSynonym){ - const char *zTerm = p->zTerm; - rc = fts5ParseTokenize((void*)&sCtx, tflags, zTerm, (int)strlen(zTerm), - 0, 0); - tflags = FTS5_TOKEN_COLOCATED; - } - if( rc==SQLITE_OK ){ - sCtx.pPhrase->aTerm[i].bPrefix = pOrig->aTerm[i].bPrefix; - sCtx.pPhrase->aTerm[i].bFirst = pOrig->aTerm[i].bFirst; + if( rc==SQLITE_OK ){ + if( pOrig->nTerm ){ + int i; /* Used to iterate through phrase terms */ + sCtx.pConfig = pExpr->pConfig; + for(i=0; rc==SQLITE_OK && inTerm; i++){ + int tflags = 0; + Fts5ExprTerm *p; + for(p=&pOrig->aTerm[i]; p && rc==SQLITE_OK; p=p->pSynonym){ + rc = fts5ParseTokenize((void*)&sCtx,tflags,p->pTerm,p->nFullTerm,0,0); + tflags = FTS5_TOKEN_COLOCATED; + } + if( rc==SQLITE_OK ){ + sCtx.pPhrase->aTerm[i].bPrefix = pOrig->aTerm[i].bPrefix; + sCtx.pPhrase->aTerm[i].bFirst = pOrig->aTerm[i].bFirst; + } } + }else{ + /* This happens when parsing a token or quoted phrase that contains + ** no token characters at all. (e.g ... MATCH '""'). */ + sCtx.pPhrase = sqlite3Fts5MallocZero(&rc, sizeof(Fts5ExprPhrase)); } - }else{ - /* This happens when parsing a token or quoted phrase that contains - ** no token characters at all. (e.g ... MATCH '""'). */ - sCtx.pPhrase = sqlite3Fts5MallocZero(&rc, sizeof(Fts5ExprPhrase)); } if( rc==SQLITE_OK && ALWAYS(sCtx.pPhrase) ){ @@ -234857,11 +236953,13 @@ static Fts5ExprNode *fts5ParsePhraseToAnd( if( parseGrowPhraseArray(pParse) ){ fts5ExprPhraseFree(pPhrase); }else{ + Fts5ExprTerm *p = &pNear->apPhrase[0]->aTerm[ii]; + Fts5ExprTerm *pTo = &pPhrase->aTerm[0]; pParse->apPhrase[pParse->nPhrase++] = pPhrase; pPhrase->nTerm = 1; - pPhrase->aTerm[0].zTerm = sqlite3Fts5Strndup( - &pParse->rc, pNear->apPhrase[0]->aTerm[ii].zTerm, -1 - ); + pTo->pTerm = sqlite3Fts5Strndup(&pParse->rc, p->pTerm, p->nFullTerm); + pTo->nQueryTerm = p->nQueryTerm; + pTo->nFullTerm = p->nFullTerm; pRet->apChild[ii] = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, sqlite3Fts5ParseNearset(pParse, 0, pPhrase) ); @@ -235046,16 +237144,17 @@ static char *fts5ExprTermPrint(Fts5ExprTerm *pTerm){ /* Determine the maximum amount of space required. */ for(p=pTerm; p; p=p->pSynonym){ - nByte += (int)strlen(pTerm->zTerm) * 2 + 3 + 2; + nByte += pTerm->nQueryTerm * 2 + 3 + 2; } zQuoted = sqlite3_malloc64(nByte); if( zQuoted ){ int i = 0; for(p=pTerm; p; p=p->pSynonym){ - char *zIn = p->zTerm; + char *zIn = p->pTerm; + char *zEnd = &zIn[p->nQueryTerm]; zQuoted[i++] = '"'; - while( *zIn ){ + while( zInnTerm; iTerm++){ - char *zTerm = pPhrase->aTerm[iTerm].zTerm; - zRet = fts5PrintfAppend(zRet, "%s%s", iTerm==0?"":" ", zTerm); + Fts5ExprTerm *p = &pPhrase->aTerm[iTerm]; + zRet = fts5PrintfAppend(zRet, "%s%.*s", iTerm==0?"":" ", + p->nQueryTerm, p->pTerm + ); if( pPhrase->aTerm[iTerm].bPrefix ){ zRet = fts5PrintfAppend(zRet, "*"); } @@ -235535,6 +237636,17 @@ static int fts5ExprColsetTest(Fts5Colset *pColset, int iCol){ return 0; } +/* +** pToken is a buffer nToken bytes in size that may or may not contain +** an embedded 0x00 byte. If it does, return the number of bytes in +** the buffer before the 0x00. If it does not, return nToken. +*/ +static int fts5QueryTerm(const char *pToken, int nToken){ + int ii; + for(ii=0; iipExpr; int i; + int nQuery = nToken; + i64 iRowid = pExpr->pRoot->iRowid; UNUSED_PARAM2(iUnused1, iUnused2); - if( nToken>FTS5_MAX_TOKEN_SIZE ) nToken = FTS5_MAX_TOKEN_SIZE; + if( nQuery>FTS5_MAX_TOKEN_SIZE ) nQuery = FTS5_MAX_TOKEN_SIZE; + if( pExpr->pConfig->bTokendata ){ + nQuery = fts5QueryTerm(pToken, nQuery); + } if( (tflags & FTS5_TOKEN_COLOCATED)==0 ) p->iOff++; for(i=0; inPhrase; i++){ - Fts5ExprTerm *pTerm; + Fts5ExprTerm *pT; if( p->aPopulator[i].bOk==0 ) continue; - for(pTerm=&pExpr->apExprPhrase[i]->aTerm[0]; pTerm; pTerm=pTerm->pSynonym){ - int nTerm = (int)strlen(pTerm->zTerm); - if( (nTerm==nToken || (nTermbPrefix)) - && memcmp(pTerm->zTerm, pToken, nTerm)==0 + for(pT=&pExpr->apExprPhrase[i]->aTerm[0]; pT; pT=pT->pSynonym){ + if( (pT->nQueryTerm==nQuery || (pT->nQueryTermbPrefix)) + && memcmp(pT->pTerm, pToken, pT->nQueryTerm)==0 ){ int rc = sqlite3Fts5PoslistWriterAppend( &pExpr->apExprPhrase[i]->poslist, &p->aPopulator[i].writer, p->iOff ); + if( rc==SQLITE_OK && pExpr->pConfig->bTokendata && !pT->bPrefix ){ + int iCol = p->iOff>>32; + int iTokOff = p->iOff & 0x7FFFFFFF; + rc = sqlite3Fts5IndexIterWriteTokendata( + pT->pIter, pToken, nToken, iRowid, iCol, iTokOff + ); + } if( rc ) return rc; break; } @@ -235697,6 +237820,83 @@ static int sqlite3Fts5ExprPhraseCollist( return rc; } +/* +** Does the work of the fts5_api.xQueryToken() API method. +*/ +static int sqlite3Fts5ExprQueryToken( + Fts5Expr *pExpr, + int iPhrase, + int iToken, + const char **ppOut, + int *pnOut +){ + Fts5ExprPhrase *pPhrase = 0; + + if( iPhrase<0 || iPhrase>=pExpr->nPhrase ){ + return SQLITE_RANGE; + } + pPhrase = pExpr->apExprPhrase[iPhrase]; + if( iToken<0 || iToken>=pPhrase->nTerm ){ + return SQLITE_RANGE; + } + + *ppOut = pPhrase->aTerm[iToken].pTerm; + *pnOut = pPhrase->aTerm[iToken].nFullTerm; + return SQLITE_OK; +} + +/* +** Does the work of the fts5_api.xInstToken() API method. +*/ +static int sqlite3Fts5ExprInstToken( + Fts5Expr *pExpr, + i64 iRowid, + int iPhrase, + int iCol, + int iOff, + int iToken, + const char **ppOut, + int *pnOut +){ + Fts5ExprPhrase *pPhrase = 0; + Fts5ExprTerm *pTerm = 0; + int rc = SQLITE_OK; + + if( iPhrase<0 || iPhrase>=pExpr->nPhrase ){ + return SQLITE_RANGE; + } + pPhrase = pExpr->apExprPhrase[iPhrase]; + if( iToken<0 || iToken>=pPhrase->nTerm ){ + return SQLITE_RANGE; + } + pTerm = &pPhrase->aTerm[iToken]; + if( pTerm->bPrefix==0 ){ + if( pExpr->pConfig->bTokendata ){ + rc = sqlite3Fts5IterToken( + pTerm->pIter, iRowid, iCol, iOff+iToken, ppOut, pnOut + ); + }else{ + *ppOut = pTerm->pTerm; + *pnOut = pTerm->nFullTerm; + } + } + return rc; +} + +/* +** Clear the token mappings for all Fts5IndexIter objects mannaged by +** the expression passed as the only argument. +*/ +static void sqlite3Fts5ExprClearTokens(Fts5Expr *pExpr){ + int ii; + for(ii=0; iinPhrase; ii++){ + Fts5ExprTerm *pT; + for(pT=&pExpr->apExprPhrase[ii]->aTerm[0]; pT; pT=pT->pSynonym){ + sqlite3Fts5IndexIterClearTokendata(pT->pIter); + } + } +} + /* ** 2014 August 11 ** @@ -235735,10 +237935,15 @@ struct Fts5Hash { /* ** Each entry in the hash table is represented by an object of the -** following type. Each object, its key (a nul-terminated string) and -** its current data are stored in a single memory allocation. The -** key immediately follows the object in memory. The position list -** data immediately follows the key data in memory. +** following type. Each object, its key, and its current data are stored +** in a single memory allocation. The key immediately follows the object +** in memory. The position list data immediately follows the key data +** in memory. +** +** The key is Fts5HashEntry.nKey bytes in size. It consists of a single +** byte identifying the index (either the main term index or a prefix-index), +** followed by the term data. For example: "0token". There is no +** nul-terminator - in this case nKey=6. ** ** The data that follows the key is in a similar, but not identical format ** to the doclist data stored in the database. It is: @@ -235873,8 +238078,7 @@ static int fts5HashResize(Fts5Hash *pHash){ unsigned int iHash; Fts5HashEntry *p = apOld[i]; apOld[i] = p->pHashNext; - iHash = fts5HashKey(nNew, (u8*)fts5EntryKey(p), - (int)strlen(fts5EntryKey(p))); + iHash = fts5HashKey(nNew, (u8*)fts5EntryKey(p), p->nKey); p->pHashNext = apNew[iHash]; apNew[iHash] = p; } @@ -235958,7 +238162,7 @@ static int sqlite3Fts5HashWrite( for(p=pHash->aSlot[iHash]; p; p=p->pHashNext){ char *zKey = fts5EntryKey(p); if( zKey[0]==bByte - && p->nKey==nToken + && p->nKey==nToken+1 && memcmp(&zKey[1], pToken, nToken)==0 ){ break; @@ -235988,9 +238192,9 @@ static int sqlite3Fts5HashWrite( zKey[0] = bByte; memcpy(&zKey[1], pToken, nToken); assert( iHash==fts5HashKey(pHash->nSlot, (u8*)zKey, nToken+1) ); - p->nKey = nToken; + p->nKey = nToken+1; zKey[nToken+1] = '\0'; - p->nData = nToken+1 + 1 + sizeof(Fts5HashEntry); + p->nData = nToken+1 + sizeof(Fts5HashEntry); p->pHashNext = pHash->aSlot[iHash]; pHash->aSlot[iHash] = p; pHash->nEntry++; @@ -236107,12 +238311,17 @@ static Fts5HashEntry *fts5HashEntryMerge( *ppOut = p1; p1 = 0; }else{ - int i = 0; char *zKey1 = fts5EntryKey(p1); char *zKey2 = fts5EntryKey(p2); - while( zKey1[i]==zKey2[i] ) i++; + int nMin = MIN(p1->nKey, p2->nKey); - if( ((u8)zKey1[i])>((u8)zKey2[i]) ){ + int cmp = memcmp(zKey1, zKey2, nMin); + if( cmp==0 ){ + cmp = p1->nKey - p2->nKey; + } + assert( cmp!=0 ); + + if( cmp>0 ){ /* p2 is smaller */ *ppOut = p2; ppOut = &p2->pScanNext; @@ -236131,10 +238340,8 @@ static Fts5HashEntry *fts5HashEntryMerge( } /* -** Extract all tokens from hash table iHash and link them into a list -** in sorted order. The hash table is cleared before returning. It is -** the responsibility of the caller to free the elements of the returned -** list. +** Link all tokens from hash table iHash into a list in sorted order. The +** tokens are not removed from the hash table. */ static int fts5HashEntrySort( Fts5Hash *pHash, @@ -236156,7 +238363,7 @@ static int fts5HashEntrySort( Fts5HashEntry *pIter; for(pIter=pHash->aSlot[iSlot]; pIter; pIter=pIter->pHashNext){ if( pTerm==0 - || (pIter->nKey+1>=nTerm && 0==memcmp(fts5EntryKey(pIter), pTerm, nTerm)) + || (pIter->nKey>=nTerm && 0==memcmp(fts5EntryKey(pIter), pTerm, nTerm)) ){ Fts5HashEntry *pEntry = pIter; pEntry->pScanNext = 0; @@ -236195,12 +238402,11 @@ static int sqlite3Fts5HashQuery( for(p=pHash->aSlot[iHash]; p; p=p->pHashNext){ zKey = fts5EntryKey(p); - assert( p->nKey+1==(int)strlen(zKey) ); - if( nTerm==p->nKey+1 && memcmp(zKey, pTerm, nTerm)==0 ) break; + if( nTerm==p->nKey && memcmp(zKey, pTerm, nTerm)==0 ) break; } if( p ){ - int nHashPre = sizeof(Fts5HashEntry) + nTerm + 1; + int nHashPre = sizeof(Fts5HashEntry) + nTerm; int nList = p->nData - nHashPre; u8 *pRet = (u8*)(*ppOut = sqlite3_malloc64(nPre + nList + 10)); if( pRet ){ @@ -236261,19 +238467,22 @@ static int sqlite3Fts5HashScanEof(Fts5Hash *p){ static void sqlite3Fts5HashScanEntry( Fts5Hash *pHash, const char **pzTerm, /* OUT: term (nul-terminated) */ + int *pnTerm, /* OUT: Size of term in bytes */ const u8 **ppDoclist, /* OUT: pointer to doclist */ int *pnDoclist /* OUT: size of doclist in bytes */ ){ Fts5HashEntry *p; if( (p = pHash->pScan) ){ char *zKey = fts5EntryKey(p); - int nTerm = (int)strlen(zKey); + int nTerm = p->nKey; fts5HashAddPoslistSize(pHash, p, 0); *pzTerm = zKey; - *ppDoclist = (const u8*)&zKey[nTerm+1]; - *pnDoclist = p->nData - (sizeof(Fts5HashEntry) + nTerm + 1); + *pnTerm = nTerm; + *ppDoclist = (const u8*)&zKey[nTerm]; + *pnDoclist = p->nData - (sizeof(Fts5HashEntry) + nTerm); }else{ *pzTerm = 0; + *pnTerm = 0; *ppDoclist = 0; *pnDoclist = 0; } @@ -236604,6 +238813,9 @@ typedef struct Fts5SegWriter Fts5SegWriter; typedef struct Fts5Structure Fts5Structure; typedef struct Fts5StructureLevel Fts5StructureLevel; typedef struct Fts5StructureSegment Fts5StructureSegment; +typedef struct Fts5TokenDataIter Fts5TokenDataIter; +typedef struct Fts5TokenDataMap Fts5TokenDataMap; +typedef struct Fts5TombstoneArray Fts5TombstoneArray; struct Fts5Data { u8 *p; /* Pointer to buffer containing record */ @@ -236638,6 +238850,7 @@ struct Fts5Index { /* Error state. */ int rc; /* Current error code */ + int flushRc; /* State used by the fts5DataXXX() functions. */ sqlite3_blob *pReader; /* RO incr-blob open on %_data table */ @@ -236646,6 +238859,7 @@ struct Fts5Index { sqlite3_stmt *pIdxWriter; /* "INSERT ... %_idx VALUES(?,?,?,?)" */ sqlite3_stmt *pIdxDeleter; /* "DELETE FROM %_idx WHERE segid=?" */ sqlite3_stmt *pIdxSelect; + sqlite3_stmt *pIdxNextSelect; int nRead; /* Total number of blocks read */ sqlite3_stmt *pDeleteFromIdx; @@ -236799,8 +239013,7 @@ struct Fts5SegIter { Fts5Data *pLeaf; /* Current leaf data */ Fts5Data *pNextLeaf; /* Leaf page (iLeafPgno+1) */ i64 iLeafOffset; /* Byte offset within current leaf */ - Fts5Data **apTombstone; /* Array of tombstone pages */ - int nTombstone; + Fts5TombstoneArray *pTombArray; /* Array of tombstone pages */ /* Next method */ void (*xNext)(Fts5Index*, Fts5SegIter*, int*); @@ -236827,6 +239040,15 @@ struct Fts5SegIter { u8 bDel; /* True if the delete flag is set */ }; +/* +** Array of tombstone pages. Reference counted. +*/ +struct Fts5TombstoneArray { + int nRef; /* Number of pointers to this object */ + int nTombstone; + Fts5Data *apTombstone[1]; /* Array of tombstone pages */ +}; + /* ** Argument is a pointer to an Fts5Data structure that contains a ** leaf page. @@ -236871,9 +239093,16 @@ struct Fts5SegIter { ** poslist: ** Used by sqlite3Fts5IterPoslist() when the poslist needs to be buffered. ** There is no way to tell if this is populated or not. +** +** pColset: +** If not NULL, points to an object containing a set of column indices. +** Only matches that occur in one of these columns will be returned. +** The Fts5Iter does not own the Fts5Colset object, and so it is not +** freed when the iterator is closed - it is owned by the upper layer. */ struct Fts5Iter { Fts5IndexIter base; /* Base class containing output vars */ + Fts5TokenDataIter *pTokenDataIter; Fts5Index *pIndex; /* Index that owns this iterator */ Fts5Buffer poslist; /* Buffer containing current poslist */ @@ -236891,7 +239120,6 @@ struct Fts5Iter { Fts5SegIter aSeg[1]; /* Array of segment iterators */ }; - /* ** An instance of the following type is used to iterate through the contents ** of a doclist-index record. @@ -237809,9 +240037,9 @@ static int fts5DlidxLvlNext(Fts5DlidxLvl *pLvl){ } if( iOffnn ){ - i64 iVal; + u64 iVal; pLvl->iLeafPgno += (iOff - pLvl->iOff) + 1; - iOff += fts5GetVarint(&pData->p[iOff], (u64*)&iVal); + iOff += fts5GetVarint(&pData->p[iOff], &iVal); pLvl->iRowid += iVal; pLvl->iOff = iOff; }else{ @@ -238190,18 +240418,20 @@ static void fts5SegIterSetNext(Fts5Index *p, Fts5SegIter *pIter){ } /* -** Allocate a tombstone hash page array (pIter->apTombstone) for the -** iterator passed as the second argument. If an OOM error occurs, leave -** an error in the Fts5Index object. +** Allocate a tombstone hash page array object (pIter->pTombArray) for +** the iterator passed as the second argument. If an OOM error occurs, +** leave an error in the Fts5Index object. */ static void fts5SegIterAllocTombstone(Fts5Index *p, Fts5SegIter *pIter){ const int nTomb = pIter->pSeg->nPgTombstone; if( nTomb>0 ){ - Fts5Data **apTomb = 0; - apTomb = (Fts5Data**)sqlite3Fts5MallocZero(&p->rc, sizeof(Fts5Data)*nTomb); - if( apTomb ){ - pIter->apTombstone = apTomb; - pIter->nTombstone = nTomb; + int nByte = nTomb * sizeof(Fts5Data*) + sizeof(Fts5TombstoneArray); + Fts5TombstoneArray *pNew; + pNew = (Fts5TombstoneArray*)sqlite3Fts5MallocZero(&p->rc, nByte); + if( pNew ){ + pNew->nTombstone = nTomb; + pNew->nRef = 1; + pIter->pTombArray = pNew; } } } @@ -238458,15 +240688,16 @@ static void fts5SegIterNext_None( }else{ const u8 *pList = 0; const char *zTerm = 0; + int nTerm = 0; int nList; sqlite3Fts5HashScanNext(p->pHash); - sqlite3Fts5HashScanEntry(p->pHash, &zTerm, &pList, &nList); + sqlite3Fts5HashScanEntry(p->pHash, &zTerm, &nTerm, &pList, &nList); if( pList==0 ) goto next_none_eof; pIter->pLeaf->p = (u8*)pList; pIter->pLeaf->nn = nList; pIter->pLeaf->szLeaf = nList; pIter->iEndofDoclist = nList; - sqlite3Fts5BufferSet(&p->rc,&pIter->term, (int)strlen(zTerm), (u8*)zTerm); + sqlite3Fts5BufferSet(&p->rc,&pIter->term, nTerm, (u8*)zTerm); pIter->iLeafOffset = fts5GetVarint(pList, (u64*)&pIter->iRowid); } @@ -238532,11 +240763,12 @@ static void fts5SegIterNext( }else if( pIter->pSeg==0 ){ const u8 *pList = 0; const char *zTerm = 0; + int nTerm = 0; int nList = 0; assert( (pIter->flags & FTS5_SEGITER_ONETERM) || pbNewTerm ); if( 0==(pIter->flags & FTS5_SEGITER_ONETERM) ){ sqlite3Fts5HashScanNext(p->pHash); - sqlite3Fts5HashScanEntry(p->pHash, &zTerm, &pList, &nList); + sqlite3Fts5HashScanEntry(p->pHash, &zTerm, &nTerm, &pList, &nList); } if( pList==0 ){ fts5DataRelease(pIter->pLeaf); @@ -238546,8 +240778,7 @@ static void fts5SegIterNext( pIter->pLeaf->nn = nList; pIter->pLeaf->szLeaf = nList; pIter->iEndofDoclist = nList+1; - sqlite3Fts5BufferSet(&p->rc, &pIter->term, (int)strlen(zTerm), - (u8*)zTerm); + sqlite3Fts5BufferSet(&p->rc, &pIter->term, nTerm, (u8*)zTerm); pIter->iLeafOffset = fts5GetVarint(pList, (u64*)&pIter->iRowid); *pbNewTerm = 1; } @@ -238933,7 +241164,7 @@ static void fts5SegIterSeekInit( fts5LeafSeek(p, bGe, pIter, pTerm, nTerm); } - if( p->rc==SQLITE_OK && bGe==0 ){ + if( p->rc==SQLITE_OK && (bGe==0 || (flags & FTS5INDEX_QUERY_SCANONETERM)) ){ pIter->flags |= FTS5_SEGITER_ONETERM; if( pIter->pLeaf ){ if( flags & FTS5INDEX_QUERY_DESC ){ @@ -238949,7 +241180,9 @@ static void fts5SegIterSeekInit( } fts5SegIterSetNext(p, pIter); - fts5SegIterAllocTombstone(p, pIter); + if( 0==(flags & FTS5INDEX_QUERY_SCANONETERM) ){ + fts5SegIterAllocTombstone(p, pIter); + } /* Either: ** @@ -238966,6 +241199,79 @@ static void fts5SegIterSeekInit( ); } + +/* +** SQL used by fts5SegIterNextInit() to find the page to open. +*/ +static sqlite3_stmt *fts5IdxNextStmt(Fts5Index *p){ + if( p->pIdxNextSelect==0 ){ + Fts5Config *pConfig = p->pConfig; + fts5IndexPrepareStmt(p, &p->pIdxNextSelect, sqlite3_mprintf( + "SELECT pgno FROM '%q'.'%q_idx' WHERE " + "segid=? AND term>? ORDER BY term ASC LIMIT 1", + pConfig->zDb, pConfig->zName + )); + + } + return p->pIdxNextSelect; +} + +/* +** This is similar to fts5SegIterSeekInit(), except that it initializes +** the segment iterator to point to the first term following the page +** with pToken/nToken on it. +*/ +static void fts5SegIterNextInit( + Fts5Index *p, + const char *pTerm, int nTerm, + Fts5StructureSegment *pSeg, /* Description of segment */ + Fts5SegIter *pIter /* Object to populate */ +){ + int iPg = -1; /* Page of segment to open */ + int bDlidx = 0; + sqlite3_stmt *pSel = 0; /* SELECT to find iPg */ + + pSel = fts5IdxNextStmt(p); + if( pSel ){ + assert( p->rc==SQLITE_OK ); + sqlite3_bind_int(pSel, 1, pSeg->iSegid); + sqlite3_bind_blob(pSel, 2, pTerm, nTerm, SQLITE_STATIC); + + if( sqlite3_step(pSel)==SQLITE_ROW ){ + i64 val = sqlite3_column_int64(pSel, 0); + iPg = (int)(val>>1); + bDlidx = (val & 0x0001); + } + p->rc = sqlite3_reset(pSel); + sqlite3_bind_null(pSel, 2); + if( p->rc ) return; + } + + memset(pIter, 0, sizeof(*pIter)); + pIter->pSeg = pSeg; + pIter->flags |= FTS5_SEGITER_ONETERM; + if( iPg>=0 ){ + pIter->iLeafPgno = iPg - 1; + fts5SegIterNextPage(p, pIter); + fts5SegIterSetNext(p, pIter); + } + if( pIter->pLeaf ){ + const u8 *a = pIter->pLeaf->p; + int iTermOff = 0; + + pIter->iPgidxOff = pIter->pLeaf->szLeaf; + pIter->iPgidxOff += fts5GetVarint32(&a[pIter->iPgidxOff], iTermOff); + pIter->iLeafOffset = iTermOff; + fts5SegIterLoadTerm(p, pIter, 0); + fts5SegIterLoadNPos(p, pIter); + if( bDlidx ) fts5SegIterLoadDlidx(p, pIter); + + assert( p->rc!=SQLITE_OK || + fts5BufferCompareBlob(&pIter->term, (const u8*)pTerm, nTerm)>0 + ); + } +} + /* ** Initialize the object pIter to point to term pTerm/nTerm within the ** in-memory hash table. If there is no such term in the hash-table, the @@ -238992,14 +241298,21 @@ static void fts5SegIterHashInit( const u8 *pList = 0; p->rc = sqlite3Fts5HashScanInit(p->pHash, (const char*)pTerm, nTerm); - sqlite3Fts5HashScanEntry(p->pHash, (const char**)&z, &pList, &nList); - n = (z ? (int)strlen((const char*)z) : 0); + sqlite3Fts5HashScanEntry(p->pHash, (const char**)&z, &n, &pList, &nList); if( pList ){ pLeaf = fts5IdxMalloc(p, sizeof(Fts5Data)); if( pLeaf ){ pLeaf->p = (u8*)pList; } } + + /* The call to sqlite3Fts5HashScanInit() causes the hash table to + ** fill the size field of all existing position lists. This means they + ** can no longer be appended to. Since the only scenario in which they + ** can be appended to is if the previous operation on this table was + ** a DELETE, by clearing the Fts5Index.bDelete flag we can avoid this + ** possibility altogether. */ + p->bDelete = 0; }else{ p->rc = sqlite3Fts5HashQuery(p->pHash, sizeof(Fts5Data), (const char*)pTerm, nTerm, (void**)&pLeaf, &nList @@ -239044,6 +241357,23 @@ static void fts5IndexFreeArray(Fts5Data **ap, int n){ } } +/* +** Decrement the ref-count of the object passed as the only argument. If it +** reaches 0, free it and its contents. +*/ +static void fts5TombstoneArrayDelete(Fts5TombstoneArray *p){ + if( p ){ + p->nRef--; + if( p->nRef<=0 ){ + int ii; + for(ii=0; iinTombstone; ii++){ + fts5DataRelease(p->apTombstone[ii]); + } + sqlite3_free(p); + } + } +} + /* ** Zero the iterator passed as the only argument. */ @@ -239051,7 +241381,7 @@ static void fts5SegIterClear(Fts5SegIter *pIter){ fts5BufferFree(&pIter->term); fts5DataRelease(pIter->pLeaf); fts5DataRelease(pIter->pNextLeaf); - fts5IndexFreeArray(pIter->apTombstone, pIter->nTombstone); + fts5TombstoneArrayDelete(pIter->pTombArray); fts5DlidxIterFree(pIter->pDlidx); sqlite3_free(pIter->aRowidOffset); memset(pIter, 0, sizeof(Fts5SegIter)); @@ -239296,7 +241626,6 @@ static void fts5SegIterNextFrom( }while( p->rc==SQLITE_OK ); } - /* ** Free the iterator object passed as the second argument. */ @@ -239441,24 +241770,25 @@ static int fts5IndexTombstoneQuery( static int fts5MultiIterIsDeleted(Fts5Iter *pIter){ int iFirst = pIter->aFirst[1].iFirst; Fts5SegIter *pSeg = &pIter->aSeg[iFirst]; + Fts5TombstoneArray *pArray = pSeg->pTombArray; - if( pSeg->pLeaf && pSeg->nTombstone ){ + if( pSeg->pLeaf && pArray ){ /* Figure out which page the rowid might be present on. */ - int iPg = ((u64)pSeg->iRowid) % pSeg->nTombstone; + int iPg = ((u64)pSeg->iRowid) % pArray->nTombstone; assert( iPg>=0 ); /* If tombstone hash page iPg has not yet been loaded from the ** database, load it now. */ - if( pSeg->apTombstone[iPg]==0 ){ - pSeg->apTombstone[iPg] = fts5DataRead(pIter->pIndex, + if( pArray->apTombstone[iPg]==0 ){ + pArray->apTombstone[iPg] = fts5DataRead(pIter->pIndex, FTS5_TOMBSTONE_ROWID(pSeg->pSeg->iSegid, iPg) ); - if( pSeg->apTombstone[iPg]==0 ) return 0; + if( pArray->apTombstone[iPg]==0 ) return 0; } return fts5IndexTombstoneQuery( - pSeg->apTombstone[iPg], - pSeg->nTombstone, + pArray->apTombstone[iPg], + pArray->nTombstone, pSeg->iRowid ); } @@ -239997,6 +242327,32 @@ static void fts5IterSetOutputCb(int *pRc, Fts5Iter *pIter){ } } +/* +** All the component segment-iterators of pIter have been set up. This +** functions finishes setup for iterator pIter itself. +*/ +static void fts5MultiIterFinishSetup(Fts5Index *p, Fts5Iter *pIter){ + int iIter; + for(iIter=pIter->nSeg-1; iIter>0; iIter--){ + int iEq; + if( (iEq = fts5MultiIterDoCompare(pIter, iIter)) ){ + Fts5SegIter *pSeg = &pIter->aSeg[iEq]; + if( p->rc==SQLITE_OK ) pSeg->xNext(p, pSeg, 0); + fts5MultiIterAdvanced(p, pIter, iEq, iIter); + } + } + fts5MultiIterSetEof(pIter); + fts5AssertMultiIterSetup(p, pIter); + + if( (pIter->bSkipEmpty && fts5MultiIterIsEmpty(p, pIter)) + || fts5MultiIterIsDeleted(pIter) + ){ + fts5MultiIterNext(p, pIter, 0, 0); + }else if( pIter->base.bEof==0 ){ + Fts5SegIter *pSeg = &pIter->aSeg[pIter->aFirst[1].iFirst]; + pIter->xSetOutputs(pIter, pSeg); + } +} /* ** Allocate a new Fts5Iter object. @@ -240078,31 +242434,12 @@ static void fts5MultiIterNew( assert( iIter==nSeg ); } - /* If the above was successful, each component iterators now points + /* If the above was successful, each component iterator now points ** to the first entry in its segment. In this case initialize the ** aFirst[] array. Or, if an error has occurred, free the iterator ** object and set the output variable to NULL. */ if( p->rc==SQLITE_OK ){ - for(iIter=pNew->nSeg-1; iIter>0; iIter--){ - int iEq; - if( (iEq = fts5MultiIterDoCompare(pNew, iIter)) ){ - Fts5SegIter *pSeg = &pNew->aSeg[iEq]; - if( p->rc==SQLITE_OK ) pSeg->xNext(p, pSeg, 0); - fts5MultiIterAdvanced(p, pNew, iEq, iIter); - } - } - fts5MultiIterSetEof(pNew); - fts5AssertMultiIterSetup(p, pNew); - - if( (pNew->bSkipEmpty && fts5MultiIterIsEmpty(p, pNew)) - || fts5MultiIterIsDeleted(pNew) - ){ - fts5MultiIterNext(p, pNew, 0, 0); - }else if( pNew->base.bEof==0 ){ - Fts5SegIter *pSeg = &pNew->aSeg[pNew->aFirst[1].iFirst]; - pNew->xSetOutputs(pNew, pSeg); - } - + fts5MultiIterFinishSetup(p, pNew); }else{ fts5MultiIterFree(pNew); *ppOut = 0; @@ -240127,7 +242464,6 @@ static void fts5MultiIterNew2( pNew = fts5MultiIterAlloc(p, 2); if( pNew ){ Fts5SegIter *pIter = &pNew->aSeg[1]; - pIter->flags = FTS5_SEGITER_ONETERM; if( pData->szLeaf>0 ){ pIter->pLeaf = pData; @@ -240275,6 +242611,7 @@ static void fts5IndexDiscardData(Fts5Index *p){ sqlite3Fts5HashClear(p->pHash); p->nPendingData = 0; p->nPendingRow = 0; + p->flushRc = SQLITE_OK; } p->nContentlessDelete = 0; } @@ -240490,7 +242827,7 @@ static void fts5WriteDlidxAppend( } if( pDlidx->bPrevValid ){ - iVal = iRowid - pDlidx->iPrev; + iVal = (u64)iRowid - (u64)pDlidx->iPrev; }else{ i64 iPgno = (i==0 ? pWriter->writer.pgno : pDlidx[-1].pgno); assert( pDlidx->buf.n==0 ); @@ -240677,7 +243014,7 @@ static void fts5WriteAppendPoslistData( const u8 *a = aData; int n = nData; - assert( p->pConfig->pgsz>0 ); + assert( p->pConfig->pgsz>0 || p->rc!=SQLITE_OK ); while( p->rc==SQLITE_OK && (pPage->buf.n + pPage->pgidx.n + n)>=p->pConfig->pgsz ){ @@ -241410,18 +243747,24 @@ static void fts5DoSecureDelete( iOff = iStart; - /* Set variable bLastInDoclist to true if this entry happens to be - ** the last rowid in the doclist for its term. */ + /* If the position-list for the entry being removed flows over past + ** the end of this page, delete the portion of the position-list on the + ** next page and beyond. + ** + ** Set variable bLastInDoclist to true if this entry happens + ** to be the last rowid in the doclist for its term. */ + if( iNextOff>=iPgIdx ){ + int pgno = pSeg->iLeafPgno+1; + fts5SecureDeleteOverflow(p, pSeg->pSeg, pgno, &bLastInDoclist); + iNextOff = iPgIdx; + } + if( pSeg->bDel==0 ){ - if( iNextOff>=iPgIdx ){ - int pgno = pSeg->iLeafPgno+1; - fts5SecureDeleteOverflow(p, pSeg->pSeg, pgno, &bLastInDoclist); - iNextOff = iPgIdx; - }else{ + if( iNextOff!=iPgIdx ){ /* Loop through the page-footer. If iNextOff (offset of the ** entry following the one we are removing) is equal to the ** offset of a key on this page, then the entry is the last - ** in its doclist. */ + ** in its doclist. */ int iKeyOff = 0; for(iIdx=0; iIdxrc!=SQLITE_OK ) break; @@ -241715,7 +244057,7 @@ static void fts5FlushOneHash(Fts5Index *p){ if( bSecureDelete ){ if( eDetail==FTS5_DETAIL_NONE ){ if( iOffrc!=SQLITE_OK || pDoclist[iOff]==0x01 ){ iOff++; continue; @@ -241851,6 +244193,10 @@ static void fts5FlushOneHash(Fts5Index *p){ */ static void fts5IndexFlush(Fts5Index *p){ /* Unless it is empty, flush the hash table to disk */ + if( p->flushRc ){ + p->rc = p->flushRc; + return; + } if( p->nPendingData || p->nContentlessDelete ){ assert( p->pHash ); fts5FlushOneHash(p); @@ -241859,6 +244205,8 @@ static void fts5IndexFlush(Fts5Index *p){ p->nPendingData = 0; p->nPendingRow = 0; p->nContentlessDelete = 0; + }else if( p->nPendingData || p->nContentlessDelete ){ + p->flushRc = p->rc; } } } @@ -241937,8 +244285,9 @@ static int sqlite3Fts5IndexOptimize(Fts5Index *p){ assert( p->rc==SQLITE_OK ); fts5IndexFlush(p); - assert( p->nContentlessDelete==0 ); + assert( p->rc!=SQLITE_OK || p->nContentlessDelete==0 ); pStruct = fts5StructureRead(p); + assert( p->rc!=SQLITE_OK || pStruct!=0 ); fts5StructureInvalidate(p); if( pStruct ){ @@ -242344,7 +244693,7 @@ static void fts5SetupPrefixIter( u8 *pToken, /* Buffer containing prefix to match */ int nToken, /* Size of buffer pToken in bytes */ Fts5Colset *pColset, /* Restrict matches to these columns */ - Fts5Iter **ppIter /* OUT: New iterator */ + Fts5Iter **ppIter /* OUT: New iterator */ ){ Fts5Structure *pStruct; Fts5Buffer *aBuf; @@ -242365,8 +244714,9 @@ static void fts5SetupPrefixIter( aBuf = (Fts5Buffer*)fts5IdxMalloc(p, sizeof(Fts5Buffer)*nBuf); pStruct = fts5StructureRead(p); + assert( p->rc!=SQLITE_OK || (aBuf && pStruct) ); - if( aBuf && pStruct ){ + if( p->rc==SQLITE_OK ){ const int flags = FTS5INDEX_QUERY_SCAN | FTS5INDEX_QUERY_SKIPEMPTY | FTS5INDEX_QUERY_NOOUTPUT; @@ -242378,6 +244728,12 @@ static void fts5SetupPrefixIter( int bNewTerm = 1; memset(&doclist, 0, sizeof(doclist)); + + /* If iIdx is non-zero, then it is the number of a prefix-index for + ** prefixes 1 character longer than the prefix being queried for. That + ** index contains all the doclists required, except for the one + ** corresponding to the prefix itself. That one is extracted from the + ** main term index here. */ if( iIdx!=0 ){ int dummy = 0; const int f2 = FTS5INDEX_QUERY_SKIPEMPTY|FTS5INDEX_QUERY_NOOUTPUT; @@ -242401,6 +244757,7 @@ static void fts5SetupPrefixIter( pToken[0] = FTS5_MAIN_PREFIX + iIdx; fts5MultiIterNew(p, pStruct, flags, pColset, pToken, nToken, -1, 0, &p1); fts5IterSetOutputCb(&p->rc, p1); + for( /* no-op */ ; fts5MultiIterEof(p, p1)==0; fts5MultiIterNext2(p, p1, &bNewTerm) @@ -242416,7 +244773,6 @@ static void fts5SetupPrefixIter( } if( p1->base.nData==0 ) continue; - if( p1->base.iRowid<=iLastRowid && doclist.n>0 ){ for(i=0; p->rc==SQLITE_OK && doclist.n; i++){ int i1 = i*nMerge; @@ -242455,7 +244811,7 @@ static void fts5SetupPrefixIter( } fts5MultiIterFree(p1); - pData = fts5IdxMalloc(p, sizeof(Fts5Data)+doclist.n+FTS5_DATA_ZERO_PADDING); + pData = fts5IdxMalloc(p, sizeof(*pData)+doclist.n+FTS5_DATA_ZERO_PADDING); if( pData ){ pData->p = (u8*)&pData[1]; pData->nn = pData->szLeaf = doclist.n; @@ -242598,6 +244954,7 @@ static int sqlite3Fts5IndexClose(Fts5Index *p){ sqlite3_finalize(p->pIdxWriter); sqlite3_finalize(p->pIdxDeleter); sqlite3_finalize(p->pIdxSelect); + sqlite3_finalize(p->pIdxNextSelect); sqlite3_finalize(p->pDataVersion); sqlite3_finalize(p->pDeleteFromIdx); sqlite3Fts5HashFree(p->pHash); @@ -242693,6 +245050,454 @@ static int sqlite3Fts5IndexWrite( return rc; } +/* +** pToken points to a buffer of size nToken bytes containing a search +** term, including the index number at the start, used on a tokendata=1 +** table. This function returns true if the term in buffer pBuf matches +** token pToken/nToken. +*/ +static int fts5IsTokendataPrefix( + Fts5Buffer *pBuf, + const u8 *pToken, + int nToken +){ + return ( + pBuf->n>=nToken + && 0==memcmp(pBuf->p, pToken, nToken) + && (pBuf->n==nToken || pBuf->p[nToken]==0x00) + ); +} + +/* +** Ensure the segment-iterator passed as the only argument points to EOF. +*/ +static void fts5SegIterSetEOF(Fts5SegIter *pSeg){ + fts5DataRelease(pSeg->pLeaf); + pSeg->pLeaf = 0; +} + +/* +** Usually, a tokendata=1 iterator (struct Fts5TokenDataIter) accumulates an +** array of these for each row it visits. Or, for an iterator used by an +** "ORDER BY rank" query, it accumulates an array of these for the entire +** query. +** +** Each instance in the array indicates the iterator (and therefore term) +** associated with position iPos of rowid iRowid. This is used by the +** xInstToken() API. +*/ +struct Fts5TokenDataMap { + i64 iRowid; /* Row this token is located in */ + i64 iPos; /* Position of token */ + int iIter; /* Iterator token was read from */ +}; + +/* +** An object used to supplement Fts5Iter for tokendata=1 iterators. +*/ +struct Fts5TokenDataIter { + int nIter; + int nIterAlloc; + + int nMap; + int nMapAlloc; + Fts5TokenDataMap *aMap; + + Fts5PoslistReader *aPoslistReader; + int *aPoslistToIter; + Fts5Iter *apIter[1]; +}; + +/* +** This function appends iterator pAppend to Fts5TokenDataIter pIn and +** returns the result. +*/ +static Fts5TokenDataIter *fts5AppendTokendataIter( + Fts5Index *p, /* Index object (for error code) */ + Fts5TokenDataIter *pIn, /* Current Fts5TokenDataIter struct */ + Fts5Iter *pAppend /* Append this iterator */ +){ + Fts5TokenDataIter *pRet = pIn; + + if( p->rc==SQLITE_OK ){ + if( pIn==0 || pIn->nIter==pIn->nIterAlloc ){ + int nAlloc = pIn ? pIn->nIterAlloc*2 : 16; + int nByte = nAlloc * sizeof(Fts5Iter*) + sizeof(Fts5TokenDataIter); + Fts5TokenDataIter *pNew = (Fts5TokenDataIter*)sqlite3_realloc(pIn, nByte); + + if( pNew==0 ){ + p->rc = SQLITE_NOMEM; + }else{ + if( pIn==0 ) memset(pNew, 0, nByte); + pRet = pNew; + pNew->nIterAlloc = nAlloc; + } + } + } + if( p->rc ){ + sqlite3Fts5IterClose((Fts5IndexIter*)pAppend); + }else{ + pRet->apIter[pRet->nIter++] = pAppend; + } + assert( pRet==0 || pRet->nIter<=pRet->nIterAlloc ); + + return pRet; +} + +/* +** Delete an Fts5TokenDataIter structure and its contents. +*/ +static void fts5TokendataIterDelete(Fts5TokenDataIter *pSet){ + if( pSet ){ + int ii; + for(ii=0; iinIter; ii++){ + fts5MultiIterFree(pSet->apIter[ii]); + } + sqlite3_free(pSet->aPoslistReader); + sqlite3_free(pSet->aMap); + sqlite3_free(pSet); + } +} + +/* +** Append a mapping to the token-map belonging to object pT. +*/ +static void fts5TokendataIterAppendMap( + Fts5Index *p, + Fts5TokenDataIter *pT, + int iIter, + i64 iRowid, + i64 iPos +){ + if( p->rc==SQLITE_OK ){ + if( pT->nMap==pT->nMapAlloc ){ + int nNew = pT->nMapAlloc ? pT->nMapAlloc*2 : 64; + int nByte = nNew * sizeof(Fts5TokenDataMap); + Fts5TokenDataMap *aNew; + + aNew = (Fts5TokenDataMap*)sqlite3_realloc(pT->aMap, nByte); + if( aNew==0 ){ + p->rc = SQLITE_NOMEM; + return; + } + + pT->aMap = aNew; + pT->nMapAlloc = nNew; + } + + pT->aMap[pT->nMap].iRowid = iRowid; + pT->aMap[pT->nMap].iPos = iPos; + pT->aMap[pT->nMap].iIter = iIter; + pT->nMap++; + } +} + +/* +** The iterator passed as the only argument must be a tokendata=1 iterator +** (pIter->pTokenDataIter!=0). This function sets the iterator output +** variables (pIter->base.*) according to the contents of the current +** row. +*/ +static void fts5IterSetOutputsTokendata(Fts5Iter *pIter){ + int ii; + int nHit = 0; + i64 iRowid = SMALLEST_INT64; + int iMin = 0; + + Fts5TokenDataIter *pT = pIter->pTokenDataIter; + + pIter->base.nData = 0; + pIter->base.pData = 0; + + for(ii=0; iinIter; ii++){ + Fts5Iter *p = pT->apIter[ii]; + if( p->base.bEof==0 ){ + if( nHit==0 || p->base.iRowidbase.iRowid; + nHit = 1; + pIter->base.pData = p->base.pData; + pIter->base.nData = p->base.nData; + iMin = ii; + }else if( p->base.iRowid==iRowid ){ + nHit++; + } + } + } + + if( nHit==0 ){ + pIter->base.bEof = 1; + }else{ + int eDetail = pIter->pIndex->pConfig->eDetail; + pIter->base.bEof = 0; + pIter->base.iRowid = iRowid; + + if( nHit==1 && eDetail==FTS5_DETAIL_FULL ){ + fts5TokendataIterAppendMap(pIter->pIndex, pT, iMin, iRowid, -1); + }else + if( nHit>1 && eDetail!=FTS5_DETAIL_NONE ){ + int nReader = 0; + int nByte = 0; + i64 iPrev = 0; + + /* Allocate array of iterators if they are not already allocated. */ + if( pT->aPoslistReader==0 ){ + pT->aPoslistReader = (Fts5PoslistReader*)sqlite3Fts5MallocZero( + &pIter->pIndex->rc, + pT->nIter * (sizeof(Fts5PoslistReader) + sizeof(int)) + ); + if( pT->aPoslistReader==0 ) return; + pT->aPoslistToIter = (int*)&pT->aPoslistReader[pT->nIter]; + } + + /* Populate an iterator for each poslist that will be merged */ + for(ii=0; iinIter; ii++){ + Fts5Iter *p = pT->apIter[ii]; + if( iRowid==p->base.iRowid ){ + pT->aPoslistToIter[nReader] = ii; + sqlite3Fts5PoslistReaderInit( + p->base.pData, p->base.nData, &pT->aPoslistReader[nReader++] + ); + nByte += p->base.nData; + } + } + + /* Ensure the output buffer is large enough */ + if( fts5BufferGrow(&pIter->pIndex->rc, &pIter->poslist, nByte+nHit*10) ){ + return; + } + + /* Ensure the token-mapping is large enough */ + if( eDetail==FTS5_DETAIL_FULL && pT->nMapAlloc<(pT->nMap + nByte) ){ + int nNew = (pT->nMapAlloc + nByte) * 2; + Fts5TokenDataMap *aNew = (Fts5TokenDataMap*)sqlite3_realloc( + pT->aMap, nNew*sizeof(Fts5TokenDataMap) + ); + if( aNew==0 ){ + pIter->pIndex->rc = SQLITE_NOMEM; + return; + } + pT->aMap = aNew; + pT->nMapAlloc = nNew; + } + + pIter->poslist.n = 0; + + while( 1 ){ + i64 iMinPos = LARGEST_INT64; + + /* Find smallest position */ + iMin = 0; + for(ii=0; iiaPoslistReader[ii]; + if( pReader->bEof==0 ){ + if( pReader->iPosiPos; + iMin = ii; + } + } + } + + /* If all readers were at EOF, break out of the loop. */ + if( iMinPos==LARGEST_INT64 ) break; + + sqlite3Fts5PoslistSafeAppend(&pIter->poslist, &iPrev, iMinPos); + sqlite3Fts5PoslistReaderNext(&pT->aPoslistReader[iMin]); + + if( eDetail==FTS5_DETAIL_FULL ){ + pT->aMap[pT->nMap].iPos = iMinPos; + pT->aMap[pT->nMap].iIter = pT->aPoslistToIter[iMin]; + pT->aMap[pT->nMap].iRowid = iRowid; + pT->nMap++; + } + } + + pIter->base.pData = pIter->poslist.p; + pIter->base.nData = pIter->poslist.n; + } + } +} + +/* +** The iterator passed as the only argument must be a tokendata=1 iterator +** (pIter->pTokenDataIter!=0). This function advances the iterator. If +** argument bFrom is false, then the iterator is advanced to the next +** entry. Or, if bFrom is true, it is advanced to the first entry with +** a rowid of iFrom or greater. +*/ +static void fts5TokendataIterNext(Fts5Iter *pIter, int bFrom, i64 iFrom){ + int ii; + Fts5TokenDataIter *pT = pIter->pTokenDataIter; + + for(ii=0; iinIter; ii++){ + Fts5Iter *p = pT->apIter[ii]; + if( p->base.bEof==0 + && (p->base.iRowid==pIter->base.iRowid || (bFrom && p->base.iRowidpIndex, p, bFrom, iFrom); + while( bFrom && p->base.bEof==0 + && p->base.iRowidpIndex->rc==SQLITE_OK + ){ + fts5MultiIterNext(p->pIndex, p, 0, 0); + } + } + } + + fts5IterSetOutputsTokendata(pIter); +} + +/* +** If the segment-iterator passed as the first argument is at EOF, then +** set pIter->term to a copy of buffer pTerm. +*/ +static void fts5TokendataSetTermIfEof(Fts5Iter *pIter, Fts5Buffer *pTerm){ + if( pIter && pIter->aSeg[0].pLeaf==0 ){ + fts5BufferSet(&pIter->pIndex->rc, &pIter->aSeg[0].term, pTerm->n, pTerm->p); + } +} + +/* +** This function sets up an iterator to use for a non-prefix query on a +** tokendata=1 table. +*/ +static Fts5Iter *fts5SetupTokendataIter( + Fts5Index *p, /* FTS index to query */ + const u8 *pToken, /* Buffer containing query term */ + int nToken, /* Size of buffer pToken in bytes */ + Fts5Colset *pColset /* Colset to filter on */ +){ + Fts5Iter *pRet = 0; + Fts5TokenDataIter *pSet = 0; + Fts5Structure *pStruct = 0; + const int flags = FTS5INDEX_QUERY_SCANONETERM | FTS5INDEX_QUERY_SCAN; + + Fts5Buffer bSeek = {0, 0, 0}; + Fts5Buffer *pSmall = 0; + + fts5IndexFlush(p); + pStruct = fts5StructureRead(p); + + while( p->rc==SQLITE_OK ){ + Fts5Iter *pPrev = pSet ? pSet->apIter[pSet->nIter-1] : 0; + Fts5Iter *pNew = 0; + Fts5SegIter *pNewIter = 0; + Fts5SegIter *pPrevIter = 0; + + int iLvl, iSeg, ii; + + pNew = fts5MultiIterAlloc(p, pStruct->nSegment); + if( pSmall ){ + fts5BufferSet(&p->rc, &bSeek, pSmall->n, pSmall->p); + fts5BufferAppendBlob(&p->rc, &bSeek, 1, (const u8*)"\0"); + }else{ + fts5BufferSet(&p->rc, &bSeek, nToken, pToken); + } + if( p->rc ){ + sqlite3Fts5IterClose((Fts5IndexIter*)pNew); + break; + } + + pNewIter = &pNew->aSeg[0]; + pPrevIter = (pPrev ? &pPrev->aSeg[0] : 0); + for(iLvl=0; iLvlnLevel; iLvl++){ + for(iSeg=pStruct->aLevel[iLvl].nSeg-1; iSeg>=0; iSeg--){ + Fts5StructureSegment *pSeg = &pStruct->aLevel[iLvl].aSeg[iSeg]; + int bDone = 0; + + if( pPrevIter ){ + if( fts5BufferCompare(pSmall, &pPrevIter->term) ){ + memcpy(pNewIter, pPrevIter, sizeof(Fts5SegIter)); + memset(pPrevIter, 0, sizeof(Fts5SegIter)); + bDone = 1; + }else if( pPrevIter->iEndofDoclist>pPrevIter->pLeaf->szLeaf ){ + fts5SegIterNextInit(p,(const char*)bSeek.p,bSeek.n-1,pSeg,pNewIter); + bDone = 1; + } + } + + if( bDone==0 ){ + fts5SegIterSeekInit(p, bSeek.p, bSeek.n, flags, pSeg, pNewIter); + } + + if( pPrevIter ){ + if( pPrevIter->pTombArray ){ + pNewIter->pTombArray = pPrevIter->pTombArray; + pNewIter->pTombArray->nRef++; + } + }else{ + fts5SegIterAllocTombstone(p, pNewIter); + } + + pNewIter++; + if( pPrevIter ) pPrevIter++; + if( p->rc ) break; + } + } + fts5TokendataSetTermIfEof(pPrev, pSmall); + + pNew->bSkipEmpty = 1; + pNew->pColset = pColset; + fts5IterSetOutputCb(&p->rc, pNew); + + /* Loop through all segments in the new iterator. Find the smallest + ** term that any segment-iterator points to. Iterator pNew will be + ** used for this term. Also, set any iterator that points to a term that + ** does not match pToken/nToken to point to EOF */ + pSmall = 0; + for(ii=0; iinSeg; ii++){ + Fts5SegIter *pII = &pNew->aSeg[ii]; + if( 0==fts5IsTokendataPrefix(&pII->term, pToken, nToken) ){ + fts5SegIterSetEOF(pII); + } + if( pII->pLeaf && (!pSmall || fts5BufferCompare(pSmall, &pII->term)>0) ){ + pSmall = &pII->term; + } + } + + /* If pSmall is still NULL at this point, then the new iterator does + ** not point to any terms that match the query. So delete it and break + ** out of the loop - all required iterators have been collected. */ + if( pSmall==0 ){ + sqlite3Fts5IterClose((Fts5IndexIter*)pNew); + break; + } + + /* Append this iterator to the set and continue. */ + pSet = fts5AppendTokendataIter(p, pSet, pNew); + } + + if( p->rc==SQLITE_OK && pSet ){ + int ii; + for(ii=0; iinIter; ii++){ + Fts5Iter *pIter = pSet->apIter[ii]; + int iSeg; + for(iSeg=0; iSegnSeg; iSeg++){ + pIter->aSeg[iSeg].flags |= FTS5_SEGITER_ONETERM; + } + fts5MultiIterFinishSetup(p, pIter); + } + } + + if( p->rc==SQLITE_OK ){ + pRet = fts5MultiIterAlloc(p, 0); + } + if( pRet ){ + pRet->pTokenDataIter = pSet; + if( pSet ){ + fts5IterSetOutputsTokendata(pRet); + }else{ + pRet->base.bEof = 1; + } + }else{ + fts5TokendataIterDelete(pSet); + } + + fts5StructureRelease(pStruct); + fts5BufferFree(&bSeek); + return pRet; +} + + /* ** Open a new iterator to iterate though all rowid that match the ** specified token or token prefix. @@ -242714,8 +245519,13 @@ static int sqlite3Fts5IndexQuery( if( sqlite3Fts5BufferSize(&p->rc, &buf, nToken+1)==0 ){ int iIdx = 0; /* Index to search */ int iPrefixIdx = 0; /* +1 prefix index */ + int bTokendata = pConfig->bTokendata; if( nToken>0 ) memcpy(&buf.p[1], pToken, nToken); + if( flags & (FTS5INDEX_QUERY_NOTOKENDATA|FTS5INDEX_QUERY_SCAN) ){ + bTokendata = 0; + } + /* Figure out which index to search and set iIdx accordingly. If this ** is a prefix query for which there is no prefix index, set iIdx to ** greater than pConfig->nPrefix to indicate that the query will be @@ -242741,7 +245551,10 @@ static int sqlite3Fts5IndexQuery( } } - if( iIdx<=pConfig->nPrefix ){ + if( bTokendata && iIdx==0 ){ + buf.p[0] = '0'; + pRet = fts5SetupTokendataIter(p, buf.p, nToken+1, pColset); + }else if( iIdx<=pConfig->nPrefix ){ /* Straight index lookup */ Fts5Structure *pStruct = fts5StructureRead(p); buf.p[0] = (u8)(FTS5_MAIN_PREFIX + iIdx); @@ -242788,7 +245601,11 @@ static int sqlite3Fts5IndexQuery( static int sqlite3Fts5IterNext(Fts5IndexIter *pIndexIter){ Fts5Iter *pIter = (Fts5Iter*)pIndexIter; assert( pIter->pIndex->rc==SQLITE_OK ); - fts5MultiIterNext(pIter->pIndex, pIter, 0, 0); + if( pIter->pTokenDataIter ){ + fts5TokendataIterNext(pIter, 0, 0); + }else{ + fts5MultiIterNext(pIter->pIndex, pIter, 0, 0); + } return fts5IndexReturn(pIter->pIndex); } @@ -242821,7 +245638,11 @@ static int sqlite3Fts5IterNextScan(Fts5IndexIter *pIndexIter){ */ static int sqlite3Fts5IterNextFrom(Fts5IndexIter *pIndexIter, i64 iMatch){ Fts5Iter *pIter = (Fts5Iter*)pIndexIter; - fts5MultiIterNextFrom(pIter->pIndex, pIter, iMatch); + if( pIter->pTokenDataIter ){ + fts5TokendataIterNext(pIter, 1, iMatch); + }else{ + fts5MultiIterNextFrom(pIter->pIndex, pIter, iMatch); + } return fts5IndexReturn(pIter->pIndex); } @@ -242836,6 +245657,99 @@ static const char *sqlite3Fts5IterTerm(Fts5IndexIter *pIndexIter, int *pn){ return (z ? &z[1] : 0); } +/* +** This is used by xInstToken() to access the token at offset iOff, column +** iCol of row iRowid. The token is returned via output variables *ppOut +** and *pnOut. The iterator passed as the first argument must be a tokendata=1 +** iterator (pIter->pTokenDataIter!=0). +*/ +static int sqlite3Fts5IterToken( + Fts5IndexIter *pIndexIter, + i64 iRowid, + int iCol, + int iOff, + const char **ppOut, int *pnOut +){ + Fts5Iter *pIter = (Fts5Iter*)pIndexIter; + Fts5TokenDataIter *pT = pIter->pTokenDataIter; + Fts5TokenDataMap *aMap = pT->aMap; + i64 iPos = (((i64)iCol)<<32) + iOff; + + int i1 = 0; + int i2 = pT->nMap; + int iTest = 0; + + while( i2>i1 ){ + iTest = (i1 + i2) / 2; + + if( aMap[iTest].iRowidiRowid ){ + i2 = iTest; + }else{ + if( aMap[iTest].iPosiPos ){ + i2 = iTest; + }else{ + break; + } + } + } + + if( i2>i1 ){ + Fts5Iter *pMap = pT->apIter[aMap[iTest].iIter]; + *ppOut = (const char*)pMap->aSeg[0].term.p+1; + *pnOut = pMap->aSeg[0].term.n-1; + } + + return SQLITE_OK; +} + +/* +** Clear any existing entries from the token-map associated with the +** iterator passed as the only argument. +*/ +static void sqlite3Fts5IndexIterClearTokendata(Fts5IndexIter *pIndexIter){ + Fts5Iter *pIter = (Fts5Iter*)pIndexIter; + if( pIter && pIter->pTokenDataIter ){ + pIter->pTokenDataIter->nMap = 0; + } +} + +/* +** Set a token-mapping for the iterator passed as the first argument. This +** is used in detail=column or detail=none mode when a token is requested +** using the xInstToken() API. In this case the caller tokenizers the +** current row and configures the token-mapping via multiple calls to this +** function. +*/ +static int sqlite3Fts5IndexIterWriteTokendata( + Fts5IndexIter *pIndexIter, + const char *pToken, int nToken, + i64 iRowid, int iCol, int iOff +){ + Fts5Iter *pIter = (Fts5Iter*)pIndexIter; + Fts5TokenDataIter *pT = pIter->pTokenDataIter; + Fts5Index *p = pIter->pIndex; + int ii; + + assert( p->pConfig->eDetail!=FTS5_DETAIL_FULL ); + assert( pIter->pTokenDataIter ); + + for(ii=0; iinIter; ii++){ + Fts5Buffer *pTerm = &pT->apIter[ii]->aSeg[0].term; + if( nToken==pTerm->n-1 && memcmp(pToken, pTerm->p+1, nToken)==0 ) break; + } + if( iinIter ){ + fts5TokendataIterAppendMap(p, pT, ii, iRowid, (((i64)iCol)<<32) + iOff); + } + return fts5IndexReturn(p); +} + /* ** Close an iterator opened by an earlier call to sqlite3Fts5IndexQuery(). */ @@ -242843,6 +245757,7 @@ static void sqlite3Fts5IterClose(Fts5IndexIter *pIndexIter){ if( pIndexIter ){ Fts5Iter *pIter = (Fts5Iter*)pIndexIter; Fts5Index *pIndex = pIter->pIndex; + fts5TokendataIterDelete(pIter->pTokenDataIter); fts5MultiIterFree(pIter); sqlite3Fts5IndexCloseReader(pIndex); } @@ -243350,7 +246265,9 @@ static int fts5QueryCksum( int eDetail = p->pConfig->eDetail; u64 cksum = *pCksum; Fts5IndexIter *pIter = 0; - int rc = sqlite3Fts5IndexQuery(p, z, n, flags, 0, &pIter); + int rc = sqlite3Fts5IndexQuery( + p, z, n, (flags | FTS5INDEX_QUERY_NOTOKENDATA), 0, &pIter + ); while( rc==SQLITE_OK && ALWAYS(pIter!=0) && 0==sqlite3Fts5IterEof(pIter) ){ i64 rowid = pIter->iRowid; @@ -243517,7 +246434,7 @@ static void fts5IndexIntegrityCheckEmpty( } static void fts5IntegrityCheckPgidx(Fts5Index *p, Fts5Data *pLeaf){ - int iTermOff = 0; + i64 iTermOff = 0; int ii; Fts5Buffer buf1 = {0,0,0}; @@ -243526,7 +246443,7 @@ static void fts5IntegrityCheckPgidx(Fts5Index *p, Fts5Data *pLeaf){ ii = pLeaf->szLeaf; while( iinn && p->rc==SQLITE_OK ){ int res; - int iOff; + i64 iOff; int nIncr; ii += fts5GetVarint32(&pLeaf->p[ii], nIncr); @@ -244048,6 +246965,24 @@ static void fts5DecodeRowidList( } #endif /* SQLITE_TEST || SQLITE_FTS5_DEBUG */ +#if defined(SQLITE_TEST) || defined(SQLITE_FTS5_DEBUG) +static void fts5BufferAppendTerm(int *pRc, Fts5Buffer *pBuf, Fts5Buffer *pTerm){ + int ii; + fts5BufferGrow(pRc, pBuf, pTerm->n*2 + 1); + if( *pRc==SQLITE_OK ){ + for(ii=0; iin; ii++){ + if( pTerm->p[ii]==0x00 ){ + pBuf->p[pBuf->n++] = '\\'; + pBuf->p[pBuf->n++] = '0'; + }else{ + pBuf->p[pBuf->n++] = pTerm->p[ii]; + } + } + pBuf->p[pBuf->n] = 0x00; + } +} +#endif /* SQLITE_TEST || SQLITE_FTS5_DEBUG */ + #if defined(SQLITE_TEST) || defined(SQLITE_FTS5_DEBUG) /* ** The implementation of user-defined scalar function fts5_decode(). @@ -244155,9 +247090,8 @@ static void fts5DecodeFunction( iOff += fts5GetVarint32(&a[iOff], nAppend); term.n = nKeep; fts5BufferAppendBlob(&rc, &term, nAppend, &a[iOff]); - sqlite3Fts5BufferAppendPrintf( - &rc, &s, " term=%.*s", term.n, (const char*)term.p - ); + sqlite3Fts5BufferAppendPrintf(&rc, &s, " term="); + fts5BufferAppendTerm(&rc, &s, &term); iOff += nAppend; /* Figure out where the doclist for this term ends */ @@ -244265,9 +247199,8 @@ static void fts5DecodeFunction( fts5BufferAppendBlob(&rc, &term, nByte, &a[iOff]); iOff += nByte; - sqlite3Fts5BufferAppendPrintf( - &rc, &s, " term=%.*s", term.n, (const char*)term.p - ); + sqlite3Fts5BufferAppendPrintf(&rc, &s, " term="); + fts5BufferAppendTerm(&rc, &s, &term); iOff += fts5DecodeDoclist(&rc, &s, &a[iOff], iEnd-iOff); } @@ -244742,7 +247675,7 @@ struct Fts5FullTable { Fts5Global *pGlobal; /* Global (connection wide) data */ Fts5Cursor *pSortCsr; /* Sort data from this cursor */ int iSavepoint; /* Successful xSavepoint()+1 */ - int bInSavepoint; + #ifdef SQLITE_DEBUG struct Fts5TransactionState ts; #endif @@ -245280,12 +248213,15 @@ static int fts5BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){ } idxStr[iIdxStr] = '\0'; - /* Set idxFlags flags for the ORDER BY clause */ + /* Set idxFlags flags for the ORDER BY clause + ** + ** Note that tokendata=1 tables cannot currently handle "ORDER BY rowid DESC". + */ if( pInfo->nOrderBy==1 ){ int iSort = pInfo->aOrderBy[0].iColumn; if( iSort==(pConfig->nCol+1) && bSeenMatch ){ idxFlags |= FTS5_BI_ORDER_RANK; - }else if( iSort==-1 ){ + }else if( iSort==-1 && (!pInfo->aOrderBy[0].desc || !pConfig->bTokendata) ){ idxFlags |= FTS5_BI_ORDER_ROWID; } if( BitFlagTest(idxFlags, FTS5_BI_ORDER_RANK|FTS5_BI_ORDER_ROWID) ){ @@ -245537,6 +248473,16 @@ static int fts5NextMethod(sqlite3_vtab_cursor *pCursor){ ); assert( !CsrFlagTest(pCsr, FTS5CSR_EOF) ); + /* If this cursor uses FTS5_PLAN_MATCH and this is a tokendata=1 table, + ** clear any token mappings accumulated at the fts5_index.c level. In + ** other cases, specifically FTS5_PLAN_SOURCE and FTS5_PLAN_SORTED_MATCH, + ** we need to retain the mappings for the entire query. */ + if( pCsr->ePlan==FTS5_PLAN_MATCH + && ((Fts5Table*)pCursor->pVtab)->pConfig->bTokendata + ){ + sqlite3Fts5ExprClearTokens(pCsr->pExpr); + } + if( pCsr->ePlan<3 ){ int bSkip = 0; if( (rc = fts5CursorReseek(pCsr, &bSkip)) || bSkip ) return rc; @@ -246197,7 +249143,10 @@ static int fts5SpecialInsert( }else if( 0==sqlite3_stricmp("flush", zCmd) ){ rc = sqlite3Fts5FlushToDisk(&pTab->p); }else{ - rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex); + rc = sqlite3Fts5FlushToDisk(&pTab->p); + if( rc==SQLITE_OK ){ + rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex); + } if( rc==SQLITE_OK ){ rc = sqlite3Fts5ConfigSetValue(pTab->p.pConfig, zCmd, pVal, &bError); } @@ -246522,7 +249471,10 @@ static int fts5ApiColumnText( ){ int rc = SQLITE_OK; Fts5Cursor *pCsr = (Fts5Cursor*)pCtx; - if( fts5IsContentless((Fts5FullTable*)(pCsr->base.pVtab)) + Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab); + if( iCol<0 || iCol>=pTab->pConfig->nCol ){ + rc = SQLITE_RANGE; + }else if( fts5IsContentless((Fts5FullTable*)(pCsr->base.pVtab)) || pCsr->ePlan==FTS5_PLAN_SPECIAL ){ *pz = 0; @@ -246547,8 +249499,9 @@ static int fts5CsrPoslist( int rc = SQLITE_OK; int bLive = (pCsr->pSorter==0); - if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_POSLIST) ){ - + if( iPhrase<0 || iPhrase>=sqlite3Fts5ExprPhraseCount(pCsr->pExpr) ){ + rc = SQLITE_RANGE; + }else if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_POSLIST) ){ if( pConfig->eDetail!=FTS5_DETAIL_FULL ){ Fts5PoslistPopulator *aPopulator; int i; @@ -246572,15 +249525,21 @@ static int fts5CsrPoslist( CsrFlagClear(pCsr, FTS5CSR_REQUIRE_POSLIST); } - if( pCsr->pSorter && pConfig->eDetail==FTS5_DETAIL_FULL ){ - Fts5Sorter *pSorter = pCsr->pSorter; - int i1 = (iPhrase==0 ? 0 : pSorter->aIdx[iPhrase-1]); - *pn = pSorter->aIdx[iPhrase] - i1; - *pa = &pSorter->aPoslist[i1]; + if( rc==SQLITE_OK ){ + if( pCsr->pSorter && pConfig->eDetail==FTS5_DETAIL_FULL ){ + Fts5Sorter *pSorter = pCsr->pSorter; + int i1 = (iPhrase==0 ? 0 : pSorter->aIdx[iPhrase-1]); + *pn = pSorter->aIdx[iPhrase] - i1; + *pa = &pSorter->aPoslist[i1]; + }else{ + *pn = sqlite3Fts5ExprPoslist(pCsr->pExpr, iPhrase, pa); + } }else{ - *pn = sqlite3Fts5ExprPoslist(pCsr->pExpr, iPhrase, pa); + *pa = 0; + *pn = 0; } + return rc; } @@ -246687,12 +249646,6 @@ static int fts5ApiInst( ){ if( iIdx<0 || iIdx>=pCsr->nInstCount ){ rc = SQLITE_RANGE; -#if 0 - }else if( fts5IsOffsetless((Fts5Table*)pCsr->base.pVtab) ){ - *piPhrase = pCsr->aInst[iIdx*3]; - *piCol = pCsr->aInst[iIdx*3 + 2]; - *piOff = -1; -#endif }else{ *piPhrase = pCsr->aInst[iIdx*3]; *piCol = pCsr->aInst[iIdx*3 + 1]; @@ -246947,13 +249900,56 @@ static int fts5ApiPhraseFirstColumn( return rc; } +/* +** xQueryToken() API implemenetation. +*/ +static int fts5ApiQueryToken( + Fts5Context* pCtx, + int iPhrase, + int iToken, + const char **ppOut, + int *pnOut +){ + Fts5Cursor *pCsr = (Fts5Cursor*)pCtx; + return sqlite3Fts5ExprQueryToken(pCsr->pExpr, iPhrase, iToken, ppOut, pnOut); +} + +/* +** xInstToken() API implemenetation. +*/ +static int fts5ApiInstToken( + Fts5Context *pCtx, + int iIdx, + int iToken, + const char **ppOut, int *pnOut +){ + Fts5Cursor *pCsr = (Fts5Cursor*)pCtx; + int rc = SQLITE_OK; + if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_INST)==0 + || SQLITE_OK==(rc = fts5CacheInstArray(pCsr)) + ){ + if( iIdx<0 || iIdx>=pCsr->nInstCount ){ + rc = SQLITE_RANGE; + }else{ + int iPhrase = pCsr->aInst[iIdx*3]; + int iCol = pCsr->aInst[iIdx*3 + 1]; + int iOff = pCsr->aInst[iIdx*3 + 2]; + i64 iRowid = fts5CursorRowid(pCsr); + rc = sqlite3Fts5ExprInstToken( + pCsr->pExpr, iRowid, iPhrase, iCol, iOff, iToken, ppOut, pnOut + ); + } + } + return rc; +} + static int fts5ApiQueryPhrase(Fts5Context*, int, void*, int(*)(const Fts5ExtensionApi*, Fts5Context*, void*) ); static const Fts5ExtensionApi sFts5Api = { - 2, /* iVersion */ + 3, /* iVersion */ fts5ApiUserData, fts5ApiColumnCount, fts5ApiRowCount, @@ -246973,6 +249969,8 @@ static const Fts5ExtensionApi sFts5Api = { fts5ApiPhraseNext, fts5ApiPhraseFirstColumn, fts5ApiPhraseNextColumn, + fts5ApiQueryToken, + fts5ApiInstToken }; /* @@ -247239,9 +250237,7 @@ static int fts5RenameMethod( ){ int rc; Fts5FullTable *pTab = (Fts5FullTable*)pVtab; - pTab->bInSavepoint = 1; rc = sqlite3Fts5StorageRename(pTab->pStorage, zName); - pTab->bInSavepoint = 0; return rc; } @@ -247258,26 +250254,12 @@ static int sqlite3Fts5FlushToDisk(Fts5Table *pTab){ static int fts5SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){ Fts5FullTable *pTab = (Fts5FullTable*)pVtab; int rc = SQLITE_OK; - char *zSql = 0; + fts5CheckTransactionState(pTab, FTS5_SAVEPOINT, iSavepoint); - - if( pTab->bInSavepoint==0 ){ - zSql = sqlite3_mprintf("INSERT INTO %Q.%Q(%Q) VALUES('flush')", - pTab->p.pConfig->zDb, pTab->p.pConfig->zName, pTab->p.pConfig->zName - ); - if( zSql ){ - pTab->bInSavepoint = 1; - rc = sqlite3_exec(pTab->p.pConfig->db, zSql, 0, 0, 0); - pTab->bInSavepoint = 0; - sqlite3_free(zSql); - }else{ - rc = SQLITE_NOMEM; - } - if( rc==SQLITE_OK ){ - pTab->iSavepoint = iSavepoint+1; - } + rc = sqlite3Fts5FlushToDisk((Fts5Table*)pVtab); + if( rc==SQLITE_OK ){ + pTab->iSavepoint = iSavepoint+1; } - return rc; } @@ -247309,8 +250291,8 @@ static int fts5RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){ int rc = SQLITE_OK; fts5CheckTransactionState(pTab, FTS5_ROLLBACKTO, iSavepoint); fts5TripCursors(pTab); - pTab->p.pConfig->pgsz = 0; if( (iSavepoint+1)<=pTab->iSavepoint ){ + pTab->p.pConfig->pgsz = 0; rc = sqlite3Fts5StorageRollback(pTab->pStorage); } return rc; @@ -247515,7 +250497,7 @@ static void fts5SourceIdFunc( ){ assert( nArg==0 ); UNUSED_PARAM2(nArg, apUnused); - sqlite3_result_text(pCtx, "fts5: 2023-11-01 11:23:50 17129ba1ff7f0daf37100ee82d507aef7827cf38de1866e2633096ae6ad81301", -1, SQLITE_TRANSIENT); + sqlite3_result_text(pCtx, "fts5: 2024-01-15 17:01:13 1066602b2b1976fe58b5150777cced894af17c803e068f5918390d6915b46e1d", -1, SQLITE_TRANSIENT); } /* @@ -247538,7 +250520,7 @@ static int fts5ShadowName(const char *zName){ ** if anything is found amiss. Return a NULL pointer if everything is ** OK. */ -static int fts5Integrity( +static int fts5IntegrityMethod( sqlite3_vtab *pVtab, /* the FTS5 virtual table to check */ const char *zSchema, /* Name of schema in which this table lives */ const char *zTabname, /* Name of the table itself */ @@ -247596,7 +250578,7 @@ static int fts5Init(sqlite3 *db){ /* xRelease */ fts5ReleaseMethod, /* xRollbackTo */ fts5RollbackToMethod, /* xShadowName */ fts5ShadowName, - /* xIntegrity */ fts5Integrity + /* xIntegrity */ fts5IntegrityMethod }; int rc; @@ -248362,7 +251344,7 @@ static int sqlite3Fts5StorageRebuild(Fts5Storage *p){ } if( rc==SQLITE_OK ){ - rc = fts5StorageGetStmt(p, FTS5_STMT_SCAN, &pScan, 0); + rc = fts5StorageGetStmt(p, FTS5_STMT_SCAN, &pScan, pConfig->pzErrmsg); } while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pScan) ){ @@ -249149,6 +252131,12 @@ static const unsigned char sqlite3Utf8Trans1[] = { #endif /* ifndef SQLITE_AMALGAMATION */ +#define FTS5_SKIP_UTF8(zIn) { \ + if( ((unsigned char)(*(zIn++)))>=0xc0 ){ \ + while( (((unsigned char)*zIn) & 0xc0)==0x80 ){ zIn++; } \ + } \ +} + typedef struct Unicode61Tokenizer Unicode61Tokenizer; struct Unicode61Tokenizer { unsigned char aTokenChar[128]; /* ASCII range token characters */ @@ -250184,6 +253172,7 @@ static int fts5PorterTokenize( typedef struct TrigramTokenizer TrigramTokenizer; struct TrigramTokenizer { int bFold; /* True to fold to lower-case */ + int iFoldParam; /* Parameter to pass to Fts5UnicodeFold() */ }; /* @@ -250210,6 +253199,7 @@ static int fts5TriCreate( }else{ int i; pNew->bFold = 1; + pNew->iFoldParam = 0; for(i=0; rc==SQLITE_OK && ibFold = (zArg[0]=='0'); } + }else if( 0==sqlite3_stricmp(azArg[i], "remove_diacritics") ){ + if( (zArg[0]!='0' && zArg[0]!='1' && zArg[0]!='2') || zArg[1] ){ + rc = SQLITE_ERROR; + }else{ + pNew->iFoldParam = (zArg[0]!='0') ? 2 : 0; + } }else{ rc = SQLITE_ERROR; } } + + if( pNew->iFoldParam!=0 && pNew->bFold==0 ){ + rc = SQLITE_ERROR; + } + if( rc!=SQLITE_OK ){ fts5TriDelete((Fts5Tokenizer*)pNew); pNew = 0; @@ -250244,40 +253245,62 @@ static int fts5TriTokenize( TrigramTokenizer *p = (TrigramTokenizer*)pTok; int rc = SQLITE_OK; char aBuf[32]; + char *zOut = aBuf; + int ii; const unsigned char *zIn = (const unsigned char*)pText; const unsigned char *zEof = &zIn[nText]; u32 iCode; + int aStart[3]; /* Input offset of each character in aBuf[] */ UNUSED_PARAM(unusedFlags); - while( 1 ){ - char *zOut = aBuf; - int iStart = zIn - (const unsigned char*)pText; - const unsigned char *zNext; - READ_UTF8(zIn, zEof, iCode); - if( iCode==0 ) break; - zNext = zIn; - if( zInbFold ) iCode = sqlite3Fts5UnicodeFold(iCode, 0); - WRITE_UTF8(zOut, iCode); + /* Populate aBuf[] with the characters for the first trigram. */ + for(ii=0; ii<3; ii++){ + do { + aStart[ii] = zIn - (const unsigned char*)pText; + READ_UTF8(zIn, zEof, iCode); + if( iCode==0 ) return SQLITE_OK; + if( p->bFold ) iCode = sqlite3Fts5UnicodeFold(iCode, p->iFoldParam); + }while( iCode==0 ); + WRITE_UTF8(zOut, iCode); + } + + /* At the start of each iteration of this loop: + ** + ** aBuf: Contains 3 characters. The 3 characters of the next trigram. + ** zOut: Points to the byte following the last character in aBuf. + ** aStart[3]: Contains the byte offset in the input text corresponding + ** to the start of each of the three characters in the buffer. + */ + assert( zIn<=zEof ); + while( 1 ){ + int iNext; /* Start of character following current tri */ + const char *z1; + + /* Read characters from the input up until the first non-diacritic */ + do { + iNext = zIn - (const unsigned char*)pText; READ_UTF8(zIn, zEof, iCode); if( iCode==0 ) break; - }else{ - break; - } - if( zInbFold ) iCode = sqlite3Fts5UnicodeFold(iCode, 0); - WRITE_UTF8(zOut, iCode); - READ_UTF8(zIn, zEof, iCode); - if( iCode==0 ) break; - if( p->bFold ) iCode = sqlite3Fts5UnicodeFold(iCode, 0); - WRITE_UTF8(zOut, iCode); - }else{ - break; - } - rc = xToken(pCtx, 0, aBuf, zOut-aBuf, iStart, iStart + zOut-aBuf); - if( rc!=SQLITE_OK ) break; - zIn = zNext; + if( p->bFold ) iCode = sqlite3Fts5UnicodeFold(iCode, p->iFoldParam); + }while( iCode==0 ); + + /* Pass the current trigram back to fts5 */ + rc = xToken(pCtx, 0, aBuf, zOut-aBuf, aStart[0], iNext); + if( iCode==0 || rc!=SQLITE_OK ) break; + + /* Remove the first character from buffer aBuf[]. Append the character + ** with codepoint iCode. */ + z1 = aBuf; + FTS5_SKIP_UTF8(z1); + memmove(aBuf, z1, zOut - z1); + zOut -= (z1 - aBuf); + WRITE_UTF8(zOut, iCode); + + /* Update the aStart[] array */ + aStart[0] = aStart[1]; + aStart[1] = aStart[2]; + aStart[2] = iNext; } return rc; @@ -250300,7 +253323,9 @@ static int sqlite3Fts5TokenizerPattern( ){ if( xCreate==fts5TriCreate ){ TrigramTokenizer *p = (TrigramTokenizer*)pTok; - return p->bFold ? FTS5_PATTERN_LIKE : FTS5_PATTERN_GLOB; + if( p->iFoldParam==0 ){ + return p->bFold ? FTS5_PATTERN_LIKE : FTS5_PATTERN_GLOB; + } } return FTS5_PATTERN_NONE; } @@ -252089,7 +255114,7 @@ static int fts5VocabFilterMethod( if( pEq ){ zTerm = (const char *)sqlite3_value_text(pEq); nTerm = sqlite3_value_bytes(pEq); - f = 0; + f = FTS5INDEX_QUERY_NOTOKENDATA; }else{ if( pGe ){ zTerm = (const char *)sqlite3_value_text(pGe); diff --git a/libsqlite3-sys/sqlite3/sqlite3.h b/libsqlite3-sys/sqlite3/sqlite3.h index d4f1c81..c2d2456 100644 --- a/libsqlite3-sys/sqlite3/sqlite3.h +++ b/libsqlite3-sys/sqlite3/sqlite3.h @@ -146,9 +146,9 @@ extern "C" { ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ -#define SQLITE_VERSION "3.44.0" -#define SQLITE_VERSION_NUMBER 3044000 -#define SQLITE_SOURCE_ID "2023-11-01 11:23:50 17129ba1ff7f0daf37100ee82d507aef7827cf38de1866e2633096ae6ad81301" +#define SQLITE_VERSION "3.45.0" +#define SQLITE_VERSION_NUMBER 3045000 +#define SQLITE_SOURCE_ID "2024-01-15 17:01:13 1066602b2b1976fe58b5150777cced894af17c803e068f5918390d6915b46e1d" /* ** CAPI3REF: Run-Time Library Version Numbers @@ -3954,15 +3954,17 @@ SQLITE_API void sqlite3_free_filename(sqlite3_filename); ** ** ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language -** text that describes the error, as either UTF-8 or UTF-16 respectively. +** text that describes the error, as either UTF-8 or UTF-16 respectively, +** or NULL if no error message is available. ** (See how SQLite handles [invalid UTF] for exceptions to this rule.) ** ^(Memory to hold the error message string is managed internally. ** The application does not need to worry about freeing the result. ** However, the error string might be overwritten or deallocated by ** subsequent calls to other SQLite interface functions.)^ ** -** ^The sqlite3_errstr() interface returns the English-language text -** that describes the [result code], as UTF-8. +** ^The sqlite3_errstr(E) interface returns the English-language text +** that describes the [result code] E, as UTF-8, or NULL if E is not an +** result code for which a text error message is available. ** ^(Memory to hold the error message string is managed internally ** and must not be freed by the application)^. ** @@ -5573,13 +5575,27 @@ SQLITE_API int sqlite3_create_window_function( ** ** ** [[SQLITE_SUBTYPE]]
      SQLITE_SUBTYPE
      -** The SQLITE_SUBTYPE flag indicates to SQLite that a function may call +** The SQLITE_SUBTYPE flag indicates to SQLite that a function might call ** [sqlite3_value_subtype()] to inspect the sub-types of its arguments. -** Specifying this flag makes no difference for scalar or aggregate user -** functions. However, if it is not specified for a user-defined window -** function, then any sub-types belonging to arguments passed to the window -** function may be discarded before the window function is called (i.e. -** sqlite3_value_subtype() will always return 0). +** This flag instructs SQLite to omit some corner-case optimizations that +** might disrupt the operation of the [sqlite3_value_subtype()] function, +** causing it to return zero rather than the correct subtype(). +** SQL functions that invokes [sqlite3_value_subtype()] should have this +** property. If the SQLITE_SUBTYPE property is omitted, then the return +** value from [sqlite3_value_subtype()] might sometimes be zero even though +** a non-zero subtype was specified by the function argument expression. +** +** [[SQLITE_RESULT_SUBTYPE]]
      SQLITE_RESULT_SUBTYPE
      +** The SQLITE_RESULT_SUBTYPE flag indicates to SQLite that a function might call +** [sqlite3_result_subtype()] to cause a sub-type to be associated with its +** result. +** Every function that invokes [sqlite3_result_subtype()] should have this +** property. If it does not, then the call to [sqlite3_result_subtype()] +** might become a no-op if the function is used as term in an +** [expression index]. On the other hand, SQL functions that never invoke +** [sqlite3_result_subtype()] should avoid setting this property, as the +** purpose of this property is to disable certain optimizations that are +** incompatible with subtypes. **
      ** */ @@ -5587,6 +5603,7 @@ SQLITE_API int sqlite3_create_window_function( #define SQLITE_DIRECTONLY 0x000080000 #define SQLITE_SUBTYPE 0x000100000 #define SQLITE_INNOCUOUS 0x000200000 +#define SQLITE_RESULT_SUBTYPE 0x001000000 /* ** CAPI3REF: Deprecated Functions @@ -5783,6 +5800,12 @@ SQLITE_API int sqlite3_value_encoding(sqlite3_value*); ** information can be used to pass a limited amount of context from ** one SQL function to another. Use the [sqlite3_result_subtype()] ** routine to set the subtype for the return value of an SQL function. +** +** Every [application-defined SQL function] that invoke this interface +** should include the [SQLITE_SUBTYPE] property in the text +** encoding argument when the function is [sqlite3_create_function|registered]. +** If the [SQLITE_SUBTYPE] property is omitted, then sqlite3_value_subtype() +** might return zero instead of the upstream subtype in some corner cases. */ SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value*); @@ -5913,14 +5936,22 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*); **
    7. ^(when sqlite3_set_auxdata() is invoked again on the same ** parameter)^, or **
    8. ^(during the original sqlite3_set_auxdata() call when a memory -** allocation error occurs.)^ +** allocation error occurs.)^ +**
    9. ^(during the original sqlite3_set_auxdata() call if the function +** is evaluated during query planning instead of during query execution, +** as sometimes happens with [SQLITE_ENABLE_STAT4].)^ ** -** Note the last bullet in particular. The destructor X in +** Note the last two bullets in particular. The destructor X in ** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the ** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata() ** should be called near the end of the function implementation and the ** function implementation should not make any use of P after -** sqlite3_set_auxdata() has been called. +** sqlite3_set_auxdata() has been called. Furthermore, a call to +** sqlite3_get_auxdata() that occurs immediately after a corresponding call +** to sqlite3_set_auxdata() might still return NULL if an out-of-memory +** condition occurred during the sqlite3_set_auxdata() call or if the +** function is being evaluated during query planning rather than during +** query execution. ** ** ^(In practice, auxiliary data is preserved between function calls for ** function parameters that are compile-time constants, including literal @@ -6194,6 +6225,20 @@ SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n); ** higher order bits are discarded. ** The number of subtype bytes preserved by SQLite might increase ** in future releases of SQLite. +** +** Every [application-defined SQL function] that invokes this interface +** should include the [SQLITE_RESULT_SUBTYPE] property in its +** text encoding argument when the SQL function is +** [sqlite3_create_function|registered]. If the [SQLITE_RESULT_SUBTYPE] +** property is omitted from the function that invokes sqlite3_result_subtype(), +** then in some cases the sqlite3_result_subtype() might fail to set +** the result subtype. +** +** If SQLite is compiled with -DSQLITE_STRICT_SUBTYPE=1, then any +** SQL function that invokes the sqlite3_result_subtype() interface +** and that does not have the SQLITE_RESULT_SUBTYPE property will raise +** an error. Future versions of SQLite might enable -DSQLITE_STRICT_SUBTYPE=1 +** by default. */ SQLITE_API void sqlite3_result_subtype(sqlite3_context*,unsigned int); @@ -7994,9 +8039,11 @@ SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*); ** ** ^(Some systems (for example, Windows 95) do not support the operation ** implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try() -** will always return SQLITE_BUSY. The SQLite core only ever uses -** sqlite3_mutex_try() as an optimization so this is acceptable -** behavior.)^ +** will always return SQLITE_BUSY. In most cases the SQLite core only uses +** sqlite3_mutex_try() as an optimization, so this is acceptable +** behavior. The exceptions are unix builds that set the +** SQLITE_ENABLE_SETLK_TIMEOUT build option. In that case a working +** sqlite3_mutex_try() is required.)^ ** ** ^The sqlite3_mutex_leave() routine exits a mutex that was ** previously entered by the same thread. The behavior @@ -8255,6 +8302,7 @@ SQLITE_API int sqlite3_test_control(int op, ...); #define SQLITE_TESTCTRL_ASSERT 12 #define SQLITE_TESTCTRL_ALWAYS 13 #define SQLITE_TESTCTRL_RESERVE 14 /* NOT USED */ +#define SQLITE_TESTCTRL_JSON_SELFCHECK 14 #define SQLITE_TESTCTRL_OPTIMIZATIONS 15 #define SQLITE_TESTCTRL_ISKEYWORD 16 /* NOT USED */ #define SQLITE_TESTCTRL_SCRATCHMALLOC 17 /* NOT USED */ @@ -12768,8 +12816,11 @@ struct Fts5PhraseIter { ** created with the "columnsize=0" option. ** ** xColumnText: -** This function attempts to retrieve the text of column iCol of the -** current document. If successful, (*pz) is set to point to a buffer +** If parameter iCol is less than zero, or greater than or equal to the +** number of columns in the table, SQLITE_RANGE is returned. +** +** Otherwise, this function attempts to retrieve the text of column iCol of +** the current document. If successful, (*pz) is set to point to a buffer ** containing the text in utf-8 encoding, (*pn) is set to the size in bytes ** (not characters) of the buffer and SQLITE_OK is returned. Otherwise, ** if an error occurs, an SQLite error code is returned and the final values @@ -12779,8 +12830,10 @@ struct Fts5PhraseIter { ** Returns the number of phrases in the current query expression. ** ** xPhraseSize: -** Returns the number of tokens in phrase iPhrase of the query. Phrases -** are numbered starting from zero. +** If parameter iCol is less than zero, or greater than or equal to the +** number of phrases in the current query, as returned by xPhraseCount, +** 0 is returned. Otherwise, this function returns the number of tokens in +** phrase iPhrase of the query. Phrases are numbered starting from zero. ** ** xInstCount: ** Set *pnInst to the total number of occurrences of all phrases within @@ -12796,12 +12849,13 @@ struct Fts5PhraseIter { ** Query for the details of phrase match iIdx within the current row. ** Phrase matches are numbered starting from zero, so the iIdx argument ** should be greater than or equal to zero and smaller than the value -** output by xInstCount(). +** output by xInstCount(). If iIdx is less than zero or greater than +** or equal to the value returned by xInstCount(), SQLITE_RANGE is returned. ** -** Usually, output parameter *piPhrase is set to the phrase number, *piCol +** Otherwise, output parameter *piPhrase is set to the phrase number, *piCol ** to the column in which it occurs and *piOff the token offset of the -** first token of the phrase. Returns SQLITE_OK if successful, or an error -** code (i.e. SQLITE_NOMEM) if an error occurs. +** first token of the phrase. SQLITE_OK is returned if successful, or an +** error code (i.e. SQLITE_NOMEM) if an error occurs. ** ** This API can be quite slow if used with an FTS5 table created with the ** "detail=none" or "detail=column" option. @@ -12827,6 +12881,10 @@ struct Fts5PhraseIter { ** Invoking Api.xUserData() returns a copy of the pointer passed as ** the third argument to pUserData. ** +** If parameter iPhrase is less than zero, or greater than or equal to +** the number of phrases in the query, as returned by xPhraseCount(), +** this function returns SQLITE_RANGE. +** ** If the callback function returns any value other than SQLITE_OK, the ** query is abandoned and the xQueryPhrase function returns immediately. ** If the returned value is SQLITE_DONE, xQueryPhrase returns SQLITE_OK. @@ -12941,9 +12999,42 @@ struct Fts5PhraseIter { ** ** xPhraseNextColumn() ** See xPhraseFirstColumn above. +** +** xQueryToken(pFts5, iPhrase, iToken, ppToken, pnToken) +** This is used to access token iToken of phrase iPhrase of the current +** query. Before returning, output parameter *ppToken is set to point +** to a buffer containing the requested token, and *pnToken to the +** size of this buffer in bytes. +** +** If iPhrase or iToken are less than zero, or if iPhrase is greater than +** or equal to the number of phrases in the query as reported by +** xPhraseCount(), or if iToken is equal to or greater than the number of +** tokens in the phrase, SQLITE_RANGE is returned and *ppToken and *pnToken + are both zeroed. +** +** The output text is not a copy of the query text that specified the +** token. It is the output of the tokenizer module. For tokendata=1 +** tables, this includes any embedded 0x00 and trailing data. +** +** xInstToken(pFts5, iIdx, iToken, ppToken, pnToken) +** This is used to access token iToken of phrase hit iIdx within the +** current row. If iIdx is less than zero or greater than or equal to the +** value returned by xInstCount(), SQLITE_RANGE is returned. Otherwise, +** output variable (*ppToken) is set to point to a buffer containing the +** matching document token, and (*pnToken) to the size of that buffer in +** bytes. This API is not available if the specified token matches a +** prefix query term. In that case both output variables are always set +** to 0. +** +** The output text is not a copy of the document text that was tokenized. +** It is the output of the tokenizer module. For tokendata=1 tables, this +** includes any embedded 0x00 and trailing data. +** +** This API can be quite slow if used with an FTS5 table created with the +** "detail=none" or "detail=column" option. */ struct Fts5ExtensionApi { - int iVersion; /* Currently always set to 2 */ + int iVersion; /* Currently always set to 3 */ void *(*xUserData)(Fts5Context*); @@ -12978,6 +13069,13 @@ struct Fts5ExtensionApi { int (*xPhraseFirstColumn)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*); void (*xPhraseNextColumn)(Fts5Context*, Fts5PhraseIter*, int *piCol); + + /* Below this point are iVersion>=3 only */ + int (*xQueryToken)(Fts5Context*, + int iPhrase, int iToken, + const char **ppToken, int *pnToken + ); + int (*xInstToken)(Fts5Context*, int iIdx, int iToken, const char**, int*); }; /* diff --git a/libsqlite3-sys/upgrade.sh b/libsqlite3-sys/upgrade.sh index 6c50da6..020b98f 100755 --- a/libsqlite3-sys/upgrade.sh +++ b/libsqlite3-sys/upgrade.sh @@ -9,8 +9,8 @@ export SQLITE3_LIB_DIR="$SCRIPT_DIR/sqlite3" mkdir -p "$TARGET_DIR" "$SQLITE3_LIB_DIR" # Download and extract amalgamation -SQLITE=sqlite-amalgamation-3440000 -curl -O https://sqlite.org/2023/$SQLITE.zip +SQLITE=sqlite-amalgamation-3450000 +curl -O https://sqlite.org/2024/$SQLITE.zip unzip -p "$SQLITE.zip" "$SQLITE/sqlite3.c" > "$SQLITE3_LIB_DIR/sqlite3.c" unzip -p "$SQLITE.zip" "$SQLITE/sqlite3.h" > "$SQLITE3_LIB_DIR/sqlite3.h" unzip -p "$SQLITE.zip" "$SQLITE/sqlite3ext.h" > "$SQLITE3_LIB_DIR/sqlite3ext.h"