Skip to content

pgrx examples

Every example in pgrx’s pgrx-examples directory has an Ankus counterpart: a runnable sample under samples/ or, for Rust-only mechanisms, a guide that explains the .NET equivalent. Samples are ordinary projects; publish and install one as described in Publish and install, then run the SQL in its README.

pgrx example Ankus Notes
aggregate Ankus.Examples.Aggregates Managed state, parallel transport and moving windows. See Aggregates.
arrays Ankus.Examples.Arrays Borrowed and copied arrays. See Arrays.
bad_ideas Ankus.Examples.BadIdeas Each bad idea is rejected, converted to an error, contained or documented. See Running .NET inside PostgreSQL.
bgworker Ankus.Examples.BackgroundWorkers See Background workers.
benching Ankus.Examples.Benchmarks In-backend benchmarks through ankus bench. See Benchmarks.
bytea Ankus.Examples.Bytea
composite_type Ankus.Examples.Composites See Composite values.
custom_libname Ankus.Examples.CustomLibraryName AnkusLibraryName replaces Cargo’s [lib] name. See native library names.
custom_sql Ankus.Examples.CustomSql Bootstrap, inline, file and final blocks in dependency order. See Custom SQL.
custom_types Ankus.Examples.CustomTypes See Custom types.
datetime Ankus.Examples.DateTime See Date and time values.
errors Ankus.Examples.Errors Managed exceptions replace Rust panics. See Logging and errors.
generic_agg Ankus.Examples.GenericAggregates Polymorphic aggregates using PostgreSQL’s datum copy and comparison bindings.
hooks Ankus.Examples.Hooks Executor, parse-analysis and utility hooks installed once and chained. See Raw values.
json Ankus.Examples.Json See JSON and UUID values.
memory_contexts Ankus.Examples.MemoryContexts Scratch contexts, sets and a worker counter in TopMemoryContext.
nostd Ankus.Examples.MinimalRuntime .NET has no runtime-free mode; the sample removes optional Native AOT runtime features instead.
notify Ankus.Examples.Notify LISTEN/NOTIFY wrappers, a cache-invalidation trigger and invalidations coalesced at commit. See Transaction callbacks.
numeric Ankus.Examples.Numeric See Numeric values.
operators Ankus.Examples.Operators See Operators and casts.
pglz_inspect Ankus.Examples.PglzInspect PGLZ probes, column sampling, ratio histograms and recommendations through PostgreSQL’s compressor.
pgthread Ankus.Examples.Threads Managed threads compute; only the backend thread calls PostgreSQL.
pgtrybuilder Ankus.Examples.TryCatch Filtered catch and finally replace PgTryBuilder.
postgres_type_variants Ankus.Examples.TypeVariants JSON, custom text, packed native, hand-written datum and array variants. See Custom types.
range Ankus.Examples.Ranges See Ranges.
rewrite_manip Ankus.Examples.RewriteManip Var changes through rewrite/rewriteManip.h. See Native declarations.
schemas Ankus.Examples.Schemas Objects in the installation, extension-owned, public and pg_catalog schemas.
shmem Ankus.Examples.SharedMemory Bounded collections, locks and an atomic in preloaded shared memory. See Shared memory.
spi, spi_srf Ankus.Examples.Spi See SPI queries.
srf Ankus.Examples.Sets C# iterators replace pgrx’s iterator types. See Sets and tables.
strings Ankus.Examples.Strings
subtrans_infos Ankus.Examples.Subtransactions Transaction status, parents, nesting level and commit time.
triggers Ankus.Examples.Triggers See Triggers.
versioned_custom_libname_so Ankus.Examples.VersionedCustomLibraryName AnkusLibraryName with AnkusVersionedLibrary.
versioned_so Ankus.Examples.VersionedLibrary AnkusVersionedLibrary installs versions side by side. See versioned libraries.
wal_decoder Ankus.Examples.WalDecoder A logical decoding output plugin that writes changes as JSON. See Logical decoding output plugins.

Ankus.Examples.Hello is the extension cargo pgrx new would generate: one function, its backend test and an installable library.

Ankus also includes samples without a direct pgrx counterpart: Ankus.Examples.CustomScans, Ankus.Examples.Configuration, Ankus.Examples.Enums, Ankus.Examples.EventTriggers and Ankus.Examples.Initialization.