[][src]Crate pgx

pgx is a framework for creating Postgres extensions in 100% Rust

Example

use pgx::*;

pg_module_magic!();

// Convert the input string to lowercase and return
#[pg_extern]
fn my_to_lowercase(input: &'static str) -> String {
    input.to_lowercase()
}

Re-exports

pub use atomics::*;
pub use callbacks::*;
pub use datum::*;
pub use enum_helper::*;
pub use fcinfo::*;
pub use guc::*;
pub use hooks::*;
pub use htup::*;
pub use inoutfuncs::*;
pub use itemptr::*;
pub use list::*;
pub use log::*;
pub use lwlock::*;
pub use memcxt::*;
pub use namespace::*;
pub use nodes::*;
pub use pgbox::*;
pub use rel::*;
pub use shmem::*;
pub use spi::*;
pub use stringinfo::*;
pub use trigger_support::*;
pub use tupdesc::*;
pub use varlena::*;
pub use wrappers::*;
pub use xid::*;
pub use pgx_pg_sys as pg_sys;

Modules

atomics
bgworkers

Safely create Postgres Background Workers, including with full SPI support

callbacks

Provides safe wrappers around Postgres' "Transaction" and "Sub Transaction" hook system

datum

Handing for easily converting Postgres Datum types into their corresponding Rust types and converting Rust types into their corresponding Postgres types

enum_helper

Helper functions for working with Postgres enum types

fcinfo

Helper macros and functions for creating Postgres UDFs.

guard
guc

Provides a safe interface into Postgres' Configuration System (GUC)

hooks

A trait and registration system for hooking Postgres internal operations such as its planner and executor

htup

Utility functions for working with pg_sys::HeapTuple and pg_sys::HeapTupleHeader structs

inoutfuncs

Helper trait for the #[derive(PostgresType)] proc macro for overriding custom Postgres type input/output functions.

itemptr

Helper functions for working with Postgres ItemPointerData (tid) type

list

A safe wrapper around Postgres' internal List structure.

log

Access to Postgres' logging system

lwlock
memcxt

Provides interfacing into Postgres' MemoryContext system.

misc
namespace

A helper struct for creating a Postgres List of Strings to qualify an object name

nodes

Helper functions and such for Postgres' various query tree Nodes

pgbox
rel

Provides a safe wrapper around Postgres' pg_sys::RelationData struct

shmem
spi

Safe access to Postgres' Server Programming Interface (SPI).

stringinfo

A safe wrapper around Postgres StringInfo structure

trigger_support

Helper functions for working with custom Rust trigger functions

tupdesc

Provides a safe wrapper around Postgres' pg_sys::TupleDescData struct

varlena

Helper functions to work with Postgres varlena * structures

wrappers

Provides safe wrapper functions around some of Postgres' useful functions.

xid

Macros

FATAL

Log to Postgres' fatal log level. This will abort the current Postgres backend connection processs

PANIC

Log to Postgres' panic log level. This will cause the entire Postgres cluster to crash

check_for_interrupts

If an interrupt is pending (perhaps a user-initiated "cancel query" message to this backend), this will safely abort the current transaction

debug1

Log to Postgres' debug1 log level

debug2

Log to Postgres' debug2 log level

debug3

Log to Postgres' debug3 log level

debug4

Log to Postgres' debug4 log level

debug5

Log to Postgres' debug5 log level

default

A macro for specifying default argument values so they get propery translated to SQL in CREATE FUNCTION statements

error

Log to Postgres' error log level. This will abort the current Postgres transaction.

extension_sql

Embed SQL directly into the generated extension script.

info

Log to Postgres' info log level

log

Log to Postgres' log log level

name

A macro for providing SQL names for the returned fields for functions that return a Rust tuple, especially those that return a std::iter::Iterator<Item=(f1, f2, f3)>

notice

Log to Postgres' notice log level

pg_module_magic

A macro for marking a library compatible with the Postgres extension framework.

pg_shmem_init

In order to store a type in Postgres Shared Memory, it must be passed to pg_shmem_init!() during _PG_init().

variadic
warning

Log to Postgres' warning log level

Structs

JumpContext
PgTryResult

A std::result::Result-type value returned from pg_try() that allows for performing cleanup work after a closure raised an error and before it is possibly rethrown

PgxPanic

Enums

PgBuiltInOids
PgOid

Functions

guard

Guard a closure such that Rust Panics are properly converted into Postgres ERRORs

initialize

Top-level initialization function. This is called automatically by the pg_module_magic!() macro and need not be called directly

name_data_to_str

Converts a pg_sys::NameData struct into a &str.

pg_try

Similar to guard, but allows the caller to unwrap the result in various ways, possibly performing cleanup work before the caught error is rethrown

register_pg_guard_panic_handler

Attribute Macros

commutator

Used with #[pg_operator]. 1 value which is the function name

hashes

Used with #[pg_operator]. no values

initialize

Associated macro for #[pg_test] to provide context back to your test framework to indicate that the test system is being initialized

join

Used with #[pg_operator]. 1 value which is the function name

merges

Used with #[pg_operator]. no values

negator

Used with #[pg_operator]. 1 value which is the function name

opname

Used with #[pg_operator]. 1 value which is the operator name itself

pg_extern

Declare a function as #[pg_extern] to indicate that it can be used by Postgres as a UDF

pg_guard

Declare a function as #[pg_guard] to indcate that it is called from a Postgres extern "C" function so that Rust panic!()s (and Postgres elog(ERROR)s) will be properly handled by pgx

pg_operator

Declare a function as #[pg_operator] to indicate that it represents a Postgres operator cargo pgx schema will automatically generate the underlying SQL

pg_test

#[pg_test] functions are test functions (akin to #[test]), but they run in-process inside Postgres during cargo pgx test.

restrict

Used with #[pg_operator]. 1 value which is the function name

search_path

Associated macro for #[pg_extern] or #pg_operator. Used to set the SEARCH_PATHoption on theCREATE FUNCTION` statement.

Derive Macros

PostgresEnum
PostgresEq
PostgresGucEnum
PostgresHash
PostgresOrd
PostgresType