Monthly Summary: contrib/anyarray — Generalizing intarray to Any Array Type (May 2026)
Overview
A new contrib module anyarray was proposed to generalize contrib/intarray's set-style operations, boolean query matching, and index support to any array type with a default btree opclass (e.g., bigint[], uuid[], text[]). The patch adds 4,657 lines across 21 files and represents a substantial first submission addressing a long-standing gap in PostgreSQL's extension ecosystem.
No substantive technical review occurred this month — only a procedural note about submission formatting.
Architectural Design
The module is structured into five C source files:
anyarray.c— Type metadata caching viafn_extra, generic datum comparatoranyarray_op.c— Set operations: sort, uniq, idx, subarray, intersect, union, differenceanyarray_bool.c— Theanyquerytype: parser, evaluator, I/O functionsanyarray_gin.c— GIN opclasses with per-concrete-type wrappersanyarray_gist.c— Polymorphic GiST opclass using signature-based bit vectors
Key Design Decisions
-
Runtime type discovery: Uses
lookup_type_cache()with results cached infn_extra, correctly handling polymorphic calls with varying element types. -
anyquerytype with lazy parsing: Unlike intarray'squery_int(integer leaves),anyquerystores text tokens parsed lazily through the element type's input function at evaluation time. This allows the same query value to work against different element types. -
Polymorphic GiST: Fully type-agnostic signature-based index using dynamically-discovered hash functions. Configurable signature length via reloption.
-
Per-type GIN wrappers: Due to GIN's
extractQuerynot receivingfn_expr, the@@strategy requires one opclass per concrete element type (e.g.,int8_anyquery_gin_ops,text_anyquery_gin_ops). This is a known limitation requiring GIN AM changes to resolve.
Known Issues and Concerns
- Operator name conflicts: Defines
#,&,|,-onanyarray/anyelement— risk of ambiguity with other extensions - Not marked trusted: Limits adoption in managed PostgreSQL environments
- NULL/multi-dimensional rejection: All operations reject NULLs and multi-dimensional arrays
- GIN scalability: Per-type wrapper approach doesn't scale to arbitrary element types
- GiST picksplit quality: Simple Hamming-weight median split acknowledged as non-optimal
- Stray test artifacts: Accidentally includes
regression.diffsandregression.outfiles
Current Status
The thread received no substantive technical review in May. The only response was a procedural note from David Johnston pointing out that the patch was embedded in the email body rather than attached as a proper patch file. The author needs to resubmit with correct formatting before review can proceed.