pgxr - 使用 Rust 开发 PostgreSQL 扩展函数
BSD
跨平台
Rust
软件简介
pgxr —— 使用 Rust 开发 PostgreSQL 扩展函数(存储过程)
pgxr 是一个 Rust 的 crate 库,可以实现用 Rust 语言来编写 PostgreSQL 的扩展函数(相当于存储过程)。
代码示例:
#[macro_use]
extern crate pgxr;
use pgxr::bindings::*;
PG_MODULE_MAGIC!();
PG_FUNCTION_INFO_V1!(pg_finfo_pgxr_example_one);
#[no_mangle]
pub extern "C" fn pgxr_example_one(_fcinfo: FunctionCallInfo) -> Datum
{
1
}
使用方法:
CREATE FUNCTION pgxr_example_one(integer) RETURNS integer
AS 'libpgxr_example_one.so', 'pgxr_example_one'
LANGUAGE C STRICT;
使用 Rust 开发 PostgreSQL 存储过程