Add utils/datum.h bindings + generic_agg example#2341
Merged
eeeebbbbrrrr merged 1 commit intoJun 25, 2026
Conversation
Contributor
|
I put up the same fix for the flaky tests in #2342, so if you'll remove it from this PR I'd appreciate it. |
isdaniel
force-pushed
the
feat/bind-utils-datum-h
branch
from
June 25, 2026 14:20
fc6c0a4 to
e0a3c30
Compare
Contributor
Author
|
Hi @eeeebbbbrrrr noted, I already removed that commit from my branch, and also change the PR comment as well |
eeeebbbbrrrr
merged commit Jun 25, 2026
14ccc0e
into
pgcentralfoundation:develop
30 of 32 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
These are the canonical, type-length-aware way to copy/compare a
Datumwhen the concrete type is only known at runtime (anyelement, polymorphic aggregates, generic state). Today an extension author has to hand-redeclare themextern "C"— easy to get subtly wrong (typLenis Cint, notint16) and missing pgrx's#[pg_guard], so apallocOOM longjmp becomes UB.What this does
#include "utils/datum.h"to all seven wrappers (pg13–pg19).pgrx-examples/generic_agg: a polymorphiccount_changes(anyelement)aggregate that needsdatumCopy(keep a by-ref value alive across transition calls) +datumIsEqual(byte-compare type-erased values), with#[pg_test]s covering text/numeric (by-ref), int4 (by-value), NULL, and empty input.