diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml
index dae70e6..9e13152 100644
--- a/.github/workflows/rust.yml
+++ b/.github/workflows/rust.yml
@@ -22,5 +22,9 @@ jobs:
sudo ldconfig
- name: Build
run: cargo build --verbose
+ env:
+ RUST_BACKTRACE: full
- name: Run tests
- run: cargo run
+ run: cargo run --example basic
+ env:
+ RUST_BACKTRACE: full
diff --git a/README.md b/README.md
index 623b5e1..7e0fb27 100644
--- a/README.md
+++ b/README.md
@@ -1,21 +1,17 @@
-
-
-
+
[](https://github.com/chdb-io/chdb-rust/actions/workflows/rust.yml)
# chdb-rust
-Experimental [chDB](https://github.com/auxten/chdb) FFI bindings for Rust
+Experimental [chDB](https://github.com/chdb-io/chdb) FFI bindings for Rust
### Status
-- experimental, unstable, subject to changes
-- requires [`libchdb`](https://github.com/chdb-io/chdb) on the system
-- ffi hack for testing. not a proper library or crate!
+- Experimental, unstable, subject to changes
+- Requires [`libchdb`](https://github.com/chdb-io/chdb) on the system
#### Build binding
```bash
-cargo build
-cargo run
+./update_libchdb.sh
+RUST_BACKTRACE=full cargo build --verbose
+cargo run --example basic
```
-
-:wave: _Rust developer? Jump in and help us evolve this example into a stable crate!_
diff --git a/src/bindings.rs b/src/bindings.rs
index fbd9127..77ad7d4 100644
--- a/src/bindings.rs
+++ b/src/bindings.rs
@@ -1,13 +1,15 @@
/* automatically generated by rust-bindgen 0.65.1 */
pub const __WORDSIZE: u32 = 64;
-pub const __DARWIN_ONLY_64_BIT_INO_T: u32 = 1;
+pub const __DARWIN_ONLY_64_BIT_INO_T: u32 = 0;
pub const __DARWIN_ONLY_UNIX_CONFORMANCE: u32 = 1;
-pub const __DARWIN_ONLY_VERS_1050: u32 = 1;
+pub const __DARWIN_ONLY_VERS_1050: u32 = 0;
pub const __DARWIN_UNIX03: u32 = 1;
pub const __DARWIN_64_BIT_INO_T: u32 = 1;
pub const __DARWIN_VERS_1050: u32 = 1;
pub const __DARWIN_NON_CANCELABLE: u32 = 0;
+pub const __DARWIN_SUF_64_BIT_INO_T: &[u8; 9usize] = b"$INODE64\0";
+pub const __DARWIN_SUF_1050: &[u8; 6usize] = b"$1050\0";
pub const __DARWIN_SUF_EXTSN: &[u8; 14usize] = b"$DARWIN_EXTSN\0";
pub const __DARWIN_C_ANSI: u32 = 4096;
pub const __DARWIN_C_FULL: u32 = 900000;
@@ -15,8 +17,6 @@ pub const __DARWIN_C_LEVEL: u32 = 900000;
pub const __STDC_WANT_LIB_EXT1__: u32 = 1;
pub const __DARWIN_NO_LONG_LONG: u32 = 0;
pub const _DARWIN_FEATURE_64_BIT_INODE: u32 = 1;
-pub const _DARWIN_FEATURE_ONLY_64_BIT_INODE: u32 = 1;
-pub const _DARWIN_FEATURE_ONLY_VERS_1050: u32 = 1;
pub const _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE: u32 = 1;
pub const _DARWIN_FEATURE_UNIX_CONFORMANCE: u32 = 3;
pub const __has_ptrcheck: u32 = 0;
@@ -75,7 +75,7 @@ pub const WINT_MAX: u32 = 2147483647;
pub const SIG_ATOMIC_MIN: i32 = -2147483648;
pub const SIG_ATOMIC_MAX: u32 = 2147483647;
pub type wchar_t = ::std::os::raw::c_int;
-pub type max_align_t = f64;
+pub type max_align_t = u128;
pub type int_least8_t = i8;
pub type int_least16_t = i16;
pub type int_least32_t = i32;
@@ -735,4 +735,67 @@ extern "C" {
extern "C" {
pub fn free_result(result: *mut local_result);
}
-pub type __builtin_va_list = *mut ::std::os::raw::c_char;
+pub type __builtin_va_list = [__va_list_tag; 1usize];
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct __va_list_tag {
+ pub gp_offset: ::std::os::raw::c_uint,
+ pub fp_offset: ::std::os::raw::c_uint,
+ pub overflow_arg_area: *mut ::std::os::raw::c_void,
+ pub reg_save_area: *mut ::std::os::raw::c_void,
+}
+#[test]
+fn bindgen_test_layout___va_list_tag() {
+ const UNINIT: ::std::mem::MaybeUninit<__va_list_tag> = ::std::mem::MaybeUninit::uninit();
+ let ptr = UNINIT.as_ptr();
+ assert_eq!(
+ ::std::mem::size_of::<__va_list_tag>(),
+ 24usize,
+ concat!("Size of: ", stringify!(__va_list_tag))
+ );
+ assert_eq!(
+ ::std::mem::align_of::<__va_list_tag>(),
+ 8usize,
+ concat!("Alignment of ", stringify!(__va_list_tag))
+ );
+ assert_eq!(
+ unsafe { ::std::ptr::addr_of!((*ptr).gp_offset) as usize - ptr as usize },
+ 0usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(__va_list_tag),
+ "::",
+ stringify!(gp_offset)
+ )
+ );
+ assert_eq!(
+ unsafe { ::std::ptr::addr_of!((*ptr).fp_offset) as usize - ptr as usize },
+ 4usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(__va_list_tag),
+ "::",
+ stringify!(fp_offset)
+ )
+ );
+ assert_eq!(
+ unsafe { ::std::ptr::addr_of!((*ptr).overflow_arg_area) as usize - ptr as usize },
+ 8usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(__va_list_tag),
+ "::",
+ stringify!(overflow_arg_area)
+ )
+ );
+ assert_eq!(
+ unsafe { ::std::ptr::addr_of!((*ptr).reg_save_area) as usize - ptr as usize },
+ 16usize,
+ concat!(
+ "Offset of field: ",
+ stringify!(__va_list_tag),
+ "::",
+ stringify!(reg_save_area)
+ )
+ );
+}
diff --git a/update_libchdb.sh b/update_libchdb.sh
new file mode 100755
index 0000000..fee5ce5
--- /dev/null
+++ b/update_libchdb.sh
@@ -0,0 +1,43 @@
+
+#!/bin/bash
+
+# Get the newest release version
+LATEST_RELEASE=$(curl --silent "https://api.github.com/repos/chdb-io/chdb/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
+
+# Download the correct version based on the platform
+case "$(uname -s)" in
+ Linux)
+ if [[ $(uname -m) == "aarch64" ]]; then
+ PLATFORM="linux-aarch64-libchdb.tar.gz"
+ else
+ PLATFORM="linux-x86_64-libchdb.tar.gz"
+ fi
+ ;;
+ Darwin)
+ if [[ $(uname -m) == "arm64" ]]; then
+ PLATFORM="macos-arm64-libchdb.tar.gz"
+ else
+ PLATFORM="macos-x86_64-libchdb.tar.gz"
+ fi
+ ;;
+ *)
+ echo "Unsupported platform"
+ exit 1
+ ;;
+esac
+
+DOWNLOAD_URL="https://github.com/chdb-io/chdb/releases/download/$LATEST_RELEASE/$PLATFORM"
+
+echo "Downloading $PLATFORM from $DOWNLOAD_URL"
+
+# Download the file
+curl -L -o libchdb.tar.gz $DOWNLOAD_URL
+
+# Untar the file
+tar -xzf libchdb.tar.gz
+
+# Set execute permission for libchdb.so
+chmod +x libchdb.so
+
+# Clean up
+rm -f libchdb.tar.gz