# pgcentralfoundation/pgrx

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/pgcentralfoundation-pgrx).**

4,370 stars · 302 forks · Rust · other

## Links

- GitHub: https://github.com/pgcentralfoundation/pgrx
- awesome-repositories: https://awesome-repositories.com/repository/pgcentralfoundation-pgrx.md

## Topics

`postgres` `postgresql` `postgresql-extension` `rust` `rustlang`

## Description

pgrx is a framework for building and packaging custom PostgreSQL extensions using Rust. It serves as a foreign function interface bridge that maps Rust types and functions to the internal server programming interface of the database.

The project provides a specialized toolchain for cross-compilation across different operating systems and target architectures using custom sysroots. It includes a schema generator that automatically translates high-level language structures into SQL definitions and binary protocol mappings.

The framework manages memory safety by wrapping database memory contexts and translating runtime panics into database-level errors to prevent server crashes. It further supports the definition of custom native database types and the implementation of functions and triggers.

A command line interface is provided to manage the extension lifecycle, including building, testing, and packaging across multiple database versions.

## Tags

### Data & Databases

- [Rust Extension Frameworks](https://awesome-repositories.com/f/data-databases/postgresql-extensions/rust-extension-frameworks.md) — Provides a framework for building and packaging custom PostgreSQL extensions entirely in Rust.
- [Rust Frameworks](https://awesome-repositories.com/f/data-databases/postgresql-extensions/rust-frameworks.md) — Serves as the primary Rust framework for building and packaging custom PostgreSQL extensions with memory safety.
- [PostgreSQL Custom Type Derivation](https://awesome-repositories.com/f/data-databases/custom-data-types/postgresql-custom-type-derivation.md) — Derives PostgreSQL types, enums, and composites directly from Rust structs and enums with automatic serialization. ([source](https://cdn.jsdelivr.net/gh/pgcentralfoundation/pgrx@develop/README.md))
- [PostgreSQL](https://awesome-repositories.com/f/data-databases/data-type-managers/dynamic-type-managers/custom-type-serializers/postgresql.md) — Derives PostgreSQL types from Rust structs and enums with automatic binary protocol support. ([source](https://cdn.jsdelivr.net/gh/pgcentralfoundation/pgrx@develop/README.md))
- [Server Programming Interfaces](https://awesome-repositories.com/f/data-databases/database-query-interfaces/server-programming-interfaces.md) — Executes SQL queries safely from within extensions using a managed Server Programming Interface. ([source](https://cdn.jsdelivr.net/gh/pgcentralfoundation/pgrx@develop/README.md))
- [Build Toolchains](https://awesome-repositories.com/f/data-databases/postgresql-extensions/build-toolchains.md) — Provides a complete cargo-based toolchain for cross-compiling, testing, and packaging PostgreSQL extensions.
- [Custom Type Derivation](https://awesome-repositories.com/f/data-databases/postgresql-integrations/custom-type-derivation.md) — Derives PostgreSQL types from Rust structs and enums with automatic serialization and binary protocol support. ([source](https://docs.rs/pgrx))
- [Custom Type Implementations](https://awesome-repositories.com/f/data-databases/postgresql-integrations/custom-type-implementations.md) — Creates native PostgreSQL data types from Rust structs and enums with automatic serialization and binary protocol support.
- [Safe Internal Access](https://awesome-repositories.com/f/data-databases/postgresql-integrations/safe-internal-access.md) — Provides safe wrappers for PostgreSQL memory contexts and internals with panic-to-error safety guarantees.
- [Safe Internal Access Wrappers](https://awesome-repositories.com/f/data-databases/postgresql-integrations/safe-internal-access-wrappers.md) — Provides safe wrappers for PostgreSQL memory contexts and pointers with panic-to-error translation. ([source](https://docs.rs/pgrx))
- [Rust](https://awesome-repositories.com/f/data-databases/postgresql-integrations/type-mappings/rust.md) — Converts between PostgreSQL and Rust types automatically, including zero-copy for text and bytea. ([source](https://cdn.jsdelivr.net/gh/pgcentralfoundation/pgrx@develop/README.md))
- [User-Defined Functions](https://awesome-repositories.com/f/data-databases/user-defined-functions.md) — Exposes Rust functions as PostgreSQL user-defined functions via declarative attribute macros. ([source](https://cdn.jsdelivr.net/gh/pgcentralfoundation/pgrx@develop/README.md))
- [Extension Cross-Compilation](https://awesome-repositories.com/f/data-databases/database-extensions/extension-cross-compilation.md) — Compiles and packages PostgreSQL extensions for multiple operating systems and database versions.
- [Sysroot Toolchains](https://awesome-repositories.com/f/data-databases/database-extensions/extension-cross-compilation/sysroot-toolchains.md) — Provides custom sysroots and build scripts to compile Rust extensions for multiple platforms.
- [Zero-Copy Mappings](https://awesome-repositories.com/f/data-databases/object-relational-mapping/zero-copy-mappings.md) — Maps PostgreSQL text and bytea types to Rust slices without copying data using pointer aliasing.
- [Extension Testing Environments](https://awesome-repositories.com/f/data-databases/postgresql-extensions/extension-testing-environments.md) — Launches a PostgreSQL instance with the extension loaded and opens an interactive psql session. ([source](https://docs.rs/pgrx))

### Development Tools & Productivity

- [Rust User-Defined Functions](https://awesome-repositories.com/f/development-tools-productivity/custom-task-functions/sql-function-namespaces/function-definitions/rust-user-defined-functions.md) — Annotates Rust functions to register them as PostgreSQL user-defined functions and triggers. ([source](https://cdn.jsdelivr.net/gh/pgcentralfoundation/pgrx@develop/README.md))
- [PostgreSQL UDF Development Toolkits](https://awesome-repositories.com/f/development-tools-productivity/custom-task-functions/sql-function-namespaces/function-definitions/rust-user-defined-functions/postgresql-udf-development-toolkits.md) — Provides a complete toolkit for defining PostgreSQL user-defined functions, triggers, and custom types in Rust.
- [PostgreSQL User-Defined Functions](https://awesome-repositories.com/f/development-tools-productivity/custom-task-functions/sql-function-namespaces/function-definitions/rust-user-defined-functions/postgresql-user-defined-functions.md) — Defines user-defined functions and triggers in PostgreSQL using Rust code with automatic SQL schema generation.
- [Extension Development Environments](https://awesome-repositories.com/f/development-tools-productivity/development-environment-management/extension-development-environments.md) — Provides a cargo subcommand to scaffold, test, and package extensions across multiple PostgreSQL versions. ([source](https://docs.rs/pgrx))
- [SQL Schema Generators](https://awesome-repositories.com/f/development-tools-productivity/type-generators/database-schema/sql-schema-generators.md) — Automatically derives SQL type definitions and binary protocol mappings from Rust structs and enums.
- [Extension Scaffolders](https://awesome-repositories.com/f/development-tools-productivity/extension-scaffolders.md) — Generates a new PostgreSQL extension project with a single command providing a ready-to-use structure. ([source](https://docs.rs/pgrx))
- [Extension Packaging Tools](https://awesome-repositories.com/f/development-tools-productivity/package-registry-extensions/extension-packaging-tools.md) — Creates installation packages for the extension ready for deployment to other systems. ([source](https://docs.rs/pgrx))

### Operating Systems & Systems Programming

- [Database Memory Context Wrappers](https://awesome-repositories.com/f/operating-systems-systems-programming/database-memory-context-wrappers.md) — Wraps PostgreSQL memory contexts in Rust's ownership model for automatic allocation management.
- [PostgreSQL Memory Context Wrappers](https://awesome-repositories.com/f/operating-systems-systems-programming/database-memory-context-wrappers/postgresql-memory-context-wrappers.md) — Wraps PostgreSQL memory contexts in Rust's ownership model and converts panics to database-level errors.

### Programming Languages & Runtimes

- [PostgreSQL FFI Bridges](https://awesome-repositories.com/f/programming-languages-runtimes/c-language-bridges/rust-c-bridges/database-ffi-bridges/postgresql-ffi-bridges.md) — Maps Rust types and functions to PostgreSQL's internal server programming interface through a foreign function bridge.
- [Attribute-Macro Code Generators](https://awesome-repositories.com/f/programming-languages-runtimes/language-features-paradigms/language-features/metaprogramming/procedural-macros/attribute-macro-code-generators.md) — Translates annotated Rust functions into PostgreSQL-compatible C entry points using procedural macros.
- [Database Version Compatibility](https://awesome-repositories.com/f/programming-languages-runtimes/runtime-execution-environments/runtime-environments/runtime-management-utilities/pre-release-runtime-installers/multi-version-installations/database-version-compatibility.md) — Runs extension unit tests against multiple installed PostgreSQL versions from a single command.

### Security & Cryptography

- [PostgreSQL Internal Safe Wrappers](https://awesome-repositories.com/f/security-cryptography/safe-memory-manipulation/postgresql-internal-safe-wrappers.md) — Provides safe wrappers for PostgreSQL pointers and memory contexts, with optional direct unsafe access to internals. ([source](https://docs.rs/pgrx))
- [PostgreSQL Memory Context Safety](https://awesome-repositories.com/f/security-cryptography/safe-memory-manipulation/postgresql-memory-context-safety.md) — Handles PostgreSQL memory contexts with Rust's drop semantics, preventing leaks even during panics or errors. ([source](https://docs.rs/pgrx))

### Software Engineering & Architecture

- [Cross-Language Panic Mapping](https://awesome-repositories.com/f/software-engineering-architecture/error-propagation-systems/panic-propagation/cross-language-panic-mapping.md) — Converts Rust panics into PostgreSQL errors that abort only the current transaction.
- [Server Programming Interfaces](https://awesome-repositories.com/f/software-engineering-architecture/integration-extensibility/programmatic-interfaces/application-programming-interfaces/server-programming-interfaces.md) — Provides safe Rust bindings to PostgreSQL's Server Programming Interface for executing queries within extensions. ([source](https://docs.rs/pgrx))
- [Cross-Version Testing](https://awesome-repositories.com/f/software-engineering-architecture/development-methodologies/engineering-best-practices/development-process-methodologies/development-workflows/cross-version-testing.md) — Runs extension unit tests against multiple installed PostgreSQL versions from a single command. ([source](https://docs.rs/pgrx))
- [Database Version Compatibility](https://awesome-repositories.com/f/software-engineering-architecture/development-methodologies/engineering-best-practices/development-process-methodologies/development-workflows/cross-version-testing/database-version-compatibility.md) — Runs unit tests against multiple installed PostgreSQL versions to ensure cross-version compatibility. ([source](https://cdn.jsdelivr.net/gh/pgcentralfoundation/pgrx@develop/README.md))
- [SQL Schema Generators](https://awesome-repositories.com/f/software-engineering-architecture/schema-generators/procedural-macro-generators/sql-schema-generators.md) — Produces SQL schema files automatically from Rust extension code or custom SQL includes. ([source](https://cdn.jsdelivr.net/gh/pgcentralfoundation/pgrx@develop/README.md))

### Web Development

- [Panic Recovery](https://awesome-repositories.com/f/web-development/error-handling/panic-recovery.md) — Translates Rust panics into PostgreSQL errors that abort the transaction without crashing the server process. ([source](https://cdn.jsdelivr.net/gh/pgcentralfoundation/pgrx@develop/README.md))
- [Database](https://awesome-repositories.com/f/web-development/error-handling/panic-recovery/database.md) — Translates Rust panics into PostgreSQL errors that abort only the current transaction, preventing server crashes. ([source](https://cdn.jsdelivr.net/gh/pgcentralfoundation/pgrx@develop/README.md))

### DevOps & Infrastructure

- [Version Target Controls](https://awesome-repositories.com/f/devops-infrastructure/version-upgrades/version-target-controls.md) — Supports building and testing extensions against PostgreSQL versions 13 through 18 from a single codebase. ([source](https://docs.rs/pgrx))
