pgxr使用 Rust 開發(fā) PostgreSQL 擴(kuò)展函數(shù)
pgxr —— 使用 Rust 開發(fā) PostgreSQL 擴(kuò)展函數(shù)(存儲(chǔ)過(guò)程)
pgxr 是一個(gè) Rust 的 crate 庫(kù),可以實(shí)現(xiàn)用 Rust 語(yǔ)言來(lái)編寫 PostgreSQL 的擴(kuò)展函數(shù)(相當(dāng)于存儲(chǔ)過(guò)程)。
代碼示例:
#[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 存儲(chǔ)過(guò)程
評(píng)論
圖片
表情
