pgxr使用 Rust 開發(fā) PostgreSQL 擴展函數
pgxr —— 使用 Rust 開發(fā) PostgreSQL 擴展函數(存儲過程)
pgxr 是一個 Rust 的 crate 庫,可以實現(xiàn)用 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 開發(fā) PostgreSQL 存儲過程
評論
圖片
表情
