Back to browse
GitHub Repository
2 starsRust

Extend MySQL with Rust

by deesix·Jun 2, 2026·2 points·0 comments

AI Analysis

●●SolidSolve My ProblemNiche Gem

pgrx for MySQL, but requires using a fork instead of vanilla MySQL.

Strengths
  • Safe Rust FFI marshaling handles all the painful type conversion automatically.
  • Cargo subcommand workflow mirrors the polished pgrx developer experience.
Weaknesses
  • Requires VillageSQL fork, not compatible with standard MySQL installations.
  • Only 2 stars suggests very early adoption and unproven stability.
Target Audience

MySQL developers who need custom functions without C++

Similar To

pgrx · MySQL UDFs · PostgreSQL extensions

Post Description

MySQL 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-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!

Similar Projects