Show HN: Extend MySQL with Rust(github.com)2 points·by deesix·지난달·0 commentsgithub.comShow HN: Extend MySQL with Rusthttps://github.com/villagesql/vsql-rust-sdkMySQL has limited extensibility via plugins and components. We created a fork of MySQL with a PostgreSQL-like extension framework (VillageSQL).Until now, all extension development was done in C++ but we know LOTS of PostgreSQL extension is done in Rust via pgrx etc.We built a Rust SDK that allows you to natively extend MySQL with custom types and functions and a subset of the PostgreSQL extension hooks.Steps:cargo install cargo-vsql cargo install cargo-generate cargo generate --git https://github.com/villagesql/vsql-extension-template-rustThe actual code looks like:use villagesql::{InValue, VdfReturn};fn my_func(args: &[InValue]) -> VdfReturn { match args.first() { Some(InValue::String(s)) => VdfReturn::string(s.to_uppercase()), Some(InValue::Null) | None => VdfReturn::null(), _ => VdfReturn::error("my_func: expected a STRING argument"), } }villagesql::extension! { funcs: [ villagesql::func!(my_func, "my_func", [villagesql::Type::String] -> villagesql::Type::String), ] }Feedback welcome!0 commentsPost comment—
Until now, all extension development was done in C++ but we know LOTS of PostgreSQL extension is done in Rust via pgrx etc.
We built a Rust SDK that allows you to natively extend MySQL with custom types and functions and a subset of the PostgreSQL extension hooks.
Steps:
cargo install cargo-vsql cargo install cargo-generate cargo generate --git https://github.com/villagesql/vsql-extension-template-rust
The actual code looks like:
use villagesql::{InValue, VdfReturn};
fn my_func(args: &[InValue]) -> VdfReturn { match args.first() { Some(InValue::String(s)) => VdfReturn::string(s.to_uppercase()), Some(InValue::Null) | None => VdfReturn::null(), _ => VdfReturn::error("my_func: expected a STRING argument"), } }
villagesql::extension! { funcs: [ villagesql::func!(my_func, "my_func", [villagesql::Type::String] -> villagesql::Type::String), ] }
Feedback welcome!