Add returns_nonnull to infallible allocators
Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.
You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:
docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t253002psql -h localhost -U postgresBuilt from patchset v2 (message #2), September 22, 2026 at 12:20 PM.
Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:
git clone --branch t253002_2 https://github.com/hackorum-dev/postgres.gitIn a checkout you already have, add the fork once:
git remote add hackorum https://github.com/hackorum-dev/postgres.gitthen, for this patchset and every later one:
git fetch hackorum t253002_2 && git checkout t253002_2Patchset v2 (message #2) is on t253002_2
Postgres memory allocators, by default, ERROR out on memory allocation
failures. An ERROR leads to a longjmp, which means that the caller of
the allocator will never see a NULL return value. We can explicitly let
the compiler know about this behavior by adding the returns_nonnull
attribute to the allocators that follow this behavior. Postgres does
support _extended versions of some of the allocators that take a flaks
argument. The caller can provide the MCXT_ALLOC_NO_OOM flag to these
allocators to request that they return NULL on allocation failure
instead of ERROR-ing out. The _extended allocators cannot be marked as
returns_nonnull because of that.
By using returns_nonnull, we can help the compiler to optimize call
sites.
--
Tristan Partin
PostgreSQL Contributors Team
AWS (https://aws.amazon.com)
On Mon Jul 6, 2026 at 6:10 PM UTC, Tristan Partin wrote:
Postgres memory allocators, by default, ERROR out on memory allocation
failures. An ERROR leads to a longjmp, which means that the caller of
the allocator will never see a NULL return value. We can explicitly let
the compiler know about this behavior by adding the returns_nonnull
attribute to the allocators that follow this behavior. Postgres does
support _extended versions of some of the allocators that take a flaks
argument. The caller can provide the MCXT_ALLOC_NO_OOM flag to these
allocators to request that they return NULL on allocation failure
instead of ERROR-ing out. The _extended allocators cannot be marked as
returns_nonnull because of that.By using returns_nonnull, we can help the compiler to optimize call
sites.
...
--
Tristan Partin
PostgreSQL Contributors Team
AWS (https://aws.amazon.com)