Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Oct 24, 2024. It is now read-only.

clia/pgxr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

48 Commits

Repository files navigation

pgxr

Obsoleted: This project is not maintained now, please refer to the new pgrx project.

Write PostgreSQL extension functions (as stored procedures) using Rust.

Use the Fastest, Efficient, Safe, Enjoyable language, to write In-Database programs, for the World's Most Advanced Open Source Relational Database!

Code Example

#[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
{
 PG_RETURN_I32(1)
}

Usage

git clone https://github.com/clia/pgxr.git
cd pgxr/examples/pgxr_example_one
cargo build --release

Then run pg_config

Find PKGLIBDIR, such as /usr/lib/postgresql/11/lib

sudo cp target/release/libpgxr_example_one.so /usr/lib/postgresql/11/lib
sudo su - postgres
psql
CREATE FUNCTION pgxr_example_one() RETURNS integer
 AS 'libpgxr_example_one.so', 'pgxr_example_one'
 LANGUAGE C STRICT;
select pgxr_example_one();

bindgen

The included bindings.rs is for latest PostgreSQL version, current 11, on the Linux X86-64 arch. You can bindgen your platform's bindings.rs, using:

bindgen wrapper.h -o src/bindings.rs -- -I /usr/include/postgresql/11/server

Other platforms

This repo is for latest PostgreSQL version, current 11, on the Linux platform on X86-64 arch.

There are individual repos for each platform, listed below:

You can simply change the crate path in your Cargo.toml (No change the crate name pgxr) to develop for your target platform.

That is it.

Have fun!

About

Write PostgreSQL extension functions using Rust.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

Languages

AltStyle によって変換されたページ (->オリジナル) /