diff --git a/.github/workflows/rust.yaml b/.github/workflows/rust.yaml index fd239581..2b6f4245 100644 --- a/.github/workflows/rust.yaml +++ b/.github/workflows/rust.yaml @@ -64,7 +64,7 @@ jobs: with: # Intentionally omit time feature until we're on time 0.3, at which # point it should be added to `bundled-full`. - args: '--features "buildtime_bindgen modern-full vtab-full" --avoid-cfg-tarpaulin' # TODO restore to normal (https://github.com/xd009642/tarpaulin/issues/756#issuecomment-838769320) + args: '--features "buildtime_bindgen modern-full vtab-full vtab-loadable" --avoid-cfg-tarpaulin' # TODO restore to normal (https://github.com/xd009642/tarpaulin/issues/756#issuecomment-838769320) version: 0.22.0 env: DUCKDB_LIB_DIR: ${{ github.workspace }}/libduckdb @@ -90,12 +90,16 @@ jobs: value: $env:PATH;${{ github.workspace }}/libduckdb - name: Run cargo-test if: matrix.os == 'windows-latest' - run: cargo test --features "modern-full vtab-full" + run: cargo test --features "modern-full vtab-full vtab-loadable" env: DUCKDB_LIB_DIR: ${{ github.workspace }}/libduckdb DUCKDB_INCLUDE_DIR: ${{ github.workspace }}/libduckdb - name: Build loadable extension - run: cargo build --example hello-ext --features="vtab-loadable bundled" + run: cargo build --example hello-ext --features="vtab-loadable" + env: + DUCKDB_LIB_DIR: ${{ github.workspace }}/libduckdb + DUCKDB_INCLUDE_DIR: ${{ github.workspace }}/libduckdb + LD_LIBRARY_PATH: ${{ github.workspace }}/libduckdb Windows: name: Windows build from source diff --git a/Cargo.toml b/Cargo.toml index a43b2256..8c4cb480 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -96,4 +96,4 @@ all-features = false [[example]] name = "hello-ext" crate-type = ["cdylib"] -required-features = ["vtab-loadable", "bundled"] \ No newline at end of file +required-features = ["vtab-loadable"] \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 894c503c..de82258b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -668,6 +668,16 @@ mod test { let _ = checked_memory_handle(); } + #[test] + fn test_open_from_raw() { + let con = Connection::open_in_memory(); + assert!(con.is_ok()); + let inner_con: InnerConnection = con.unwrap().db.into_inner(); + unsafe { + assert!(Connection::open_from_raw(inner_con.db).is_ok()); + } + } + #[test] fn test_open_failure() -> Result<()> { let filename = "no_such_file.db"; diff --git a/src/vtab/mod.rs b/src/vtab/mod.rs index 5336334e..ee5ce9df 100644 --- a/src/vtab/mod.rs +++ b/src/vtab/mod.rs @@ -250,4 +250,17 @@ mod test { assert_eq!(val, ("Hello duckdb".to_string(),)); Ok(()) } + + #[cfg(feature = "vtab-loadable")] + use duckdb_loadable_macros::duckdb_entrypoint; + + // this function is never called, but is still type checked + // Exposes a extern C function named "libhello_ext_init" in the compiled dynamic library, + // the "entrypoint" that duckdb will use to load the extension. + #[cfg(feature = "vtab-loadable")] + #[duckdb_entrypoint] + fn libhello_ext_init(conn: Connection) -> Result<(), Box> { + conn.register_table_function::("hello")?; + Ok(()) + } }