plrust_trusted_pgx/
lib.rs

1//! `plrust-trusted-pgx` is a re-export crate based on [pgx](https://crates.io/crates/pgx) which exposes
2//! the minimal set of `pgx` internals necessary for `plrust` function compilation.  `plrust-trusted-pgx`
3//! also includes a number of Rust types for interoperating with Postgres types, access to Postgres'
4//! "SPI", logging, and trigger support.
5
6/// Use all the things.  
7///
8/// `plrust` user crates use the `plrust-trusted-pgx` crate as if it were named `pgx`, and all user
9/// functions contain a `use pgx::prelude::*;` statement.
10pub mod prelude {
11    pub use super::*;
12}
13
14pub use ::pgx::{
15    debug1, debug2, debug3, debug4, debug5, ereport, error, info, log, notice, warning,
16};
17
18pub use datum::*;
19
20/// Safe Rust wrappers for various Postgres types.
21pub mod datum {
22    // traits
23    pub use ::pgx::datum::{FromDatum, IntoDatum};
24
25    // // dates & times
26    // pub use ::pgx::datum::{Date, Time, TimeWithTimeZone, Timestamp, TimestampWithTimeZone};
27
28    // json
29    pub use ::pgx::datum::{Json, JsonB};
30
31    // geometric types
32    pub use ::pgx::pg_sys::{Point, BOX};
33
34    // uuid types
35    pub use ::pgx::datum::Uuid;
36
37    // range types
38    pub use ::pgx::datum::{Range, RangeBound, RangeSubType};
39
40    // dynamic types
41    pub use ::pgx::datum::AnyNumeric;
42
43    // others
44    pub use ::pgx::pg_sys::Oid;
45}
46
47#[doc(hidden)]
48pub mod fcinfo {
49    pub use ::pgx::fcinfo::pg_getarg;
50    pub use ::pgx::fcinfo::pg_return_null;
51    pub use ::pgx::fcinfo::pg_return_void;
52    pub use ::pgx::fcinfo::srf_first_call_init;
53    pub use ::pgx::fcinfo::srf_is_first_call;
54    pub use ::pgx::fcinfo::srf_per_call_setup;
55    pub use ::pgx::fcinfo::srf_return_done;
56    pub use ::pgx::fcinfo::srf_return_next;
57}
58
59pub use heap_tuple::*;
60
61/// Support for arbitrary composite types as a "heap tuple".
62pub mod heap_tuple {
63    pub use ::pgx::heap_tuple::PgHeapTuple;
64}
65
66pub use iter::*;
67
68/// Return iterators from plrust functions
69pub mod iter {
70    pub use ::pgx::iter::{SetOfIterator, TableIterator};
71}
72
73#[doc(hidden)]
74pub use memcxt::*;
75#[doc(hidden)]
76pub mod memcxt {
77    pub use ::pgx::memcxt::PgMemoryContexts;
78}
79
80#[doc(hidden)]
81pub use pgbox::*;
82#[doc(hidden)]
83pub mod pgbox {
84    pub use ::pgx::pgbox::{PgBox, WhoAllocated};
85}
86
87pub use pg_sys::panic::ErrorReportable;
88pub use pg_sys::*;
89
90/// Lower-level Postgres internals, which are safe to use.
91pub mod pg_sys {
92    pub use ::pgx::pg_sys::elog::PgLogLevel;
93    pub use ::pgx::pg_sys::errcodes::PgSqlErrorCode;
94    pub use ::pgx::pg_sys::pg_try::PgTryBuilder;
95    pub use ::pgx::pg_sys::Datum;
96    #[doc(hidden)]
97    pub use ::pgx::pg_sys::FuncCallContext;
98    #[doc(hidden)]
99    pub use ::pgx::pg_sys::FunctionCallInfo;
100    #[doc(hidden)]
101    pub use ::pgx::pg_sys::Pg_finfo_record;
102    pub use ::pgx::pg_sys::{BuiltinOid, PgBuiltInOids};
103    pub use ::pgx::pg_sys::{ItemPointerData, Oid};
104
105    pub mod panic {
106        pub use super::submodules::panic::ErrorReportable;
107    }
108
109    pub mod oids {
110        pub use ::pgx::pg_sys::oids::{NotBuiltinOid, PgBuiltInOids, PgOid};
111    }
112
113    pub mod submodules {
114        pub mod elog {
115            pub use ::pgx::pg_sys::submodules::elog::PgLogLevel;
116        }
117
118        pub mod errcodes {
119            pub use ::pgx::pg_sys::submodules::errcodes::PgSqlErrorCode;
120        }
121
122        pub mod panic {
123            pub use ::pgx::pg_sys::submodules::panic::pgx_extern_c_guard;
124            pub use ::pgx::pg_sys::submodules::panic::ErrorReportable;
125        }
126    }
127}
128
129pub use spi::Spi;
130
131/// Use Postgres' Server Programming Interface to execute arbitrary SQL.
132pub mod spi {
133    pub use ::pgx::spi::{
134        self, Error, Result, Spi, SpiClient, SpiCursor, SpiErrorCodes, SpiHeapTupleData,
135        SpiHeapTupleDataEntry, SpiOkCodes, SpiTupleTable, UnknownVariant,
136    };
137}
138
139pub use trigger_support::*;
140
141/// Various types for use when a `plrust` function is a trigger function.
142pub mod trigger_support {
143    pub use ::pgx::trigger_support::{
144        PgTrigger, PgTriggerError, PgTriggerLevel, PgTriggerOperation, PgTriggerWhen, TriggerEvent,
145        TriggerTuple,
146    };
147}
148
149#[doc(hidden)]
150pub use pgx_macros::*;
151#[doc(hidden)]
152pub mod pgx_macros {
153    pub use ::pgx::pgx_macros::pg_extern;
154    pub use ::pgx::pgx_macros::pg_guard;
155    pub use ::pgx::pgx_macros::pg_trigger;
156}