Skip to content
Postgres extension library for Rust
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Binary to create foreign data wrapper Feb 27, 2019
.travis.yml add PgAllocator for palloc and pfree Dec 27, 2018
Cargo.lock Bump tempfile from 3.0.7 to 3.0.8 May 24, 2019
Cargo.toml writable FDWs Feb 20, 2019
LICENSE-MIT fix the MIT license Dec 28, 2018 Fix to point to currect crate name Apr 29, 2019

Build Status License: MIT License: Apache 2.0 Dependabot Status

Rust based postgres extension

The main things provided by this crate are some macros that help with writing Postgres extensions in Rust.

The objective (not all these are yet implemented):

  • Automatic type conversions, see PgDatum and TryFromPgDatum to Into<PgDatum>
  • pg_magic macro for declaring libraries as Postgres extensions
  • pg_extern attribute for wrapping Rust functions in Postgres C style definitions
  • panic handlers for conversion into Postgres errors
  • allocator that uses Postgres palloc allocator and pfree
  • tbd integrate postgres error logs with log
  • tbd support all Datum types
  • tbd support table like returns and manipulation
  • tbd generators for the psql scripts to load functions


First install Postgres. Once installed, this environment variable is required:

PG_INCLUDE_PATH=[/path/to/postgres]/include/server # e.g. /usr/local/pgsql/include/server

This environment variable is also required for the dynamic libraries to compile:

RUSTFLAGS="-C link-arg=-undefineddynamic_lookup"

This informs the linker that some of the symbols for postgres won't be available until runtime on the dynamic library load.



To use the postgres allocator, the feature pg_allocator must be defined and enabled in the implementing crate.

You can’t perform that action at this time.