]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix null-bitmap combining in array_agg_array_combine().
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 6 Apr 2026 17:14:50 +0000 (13:14 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 6 Apr 2026 17:14:50 +0000 (13:14 -0400)
commitd6c9432cb5da3b3d2c31b31fbe8eb668a9f927a4
tree5675dcccfbb38fc5186332ba7d61055fa5718f89
parent0a2291b59f9b7f44b2b2c362fad60ca9ff026a60
Fix null-bitmap combining in array_agg_array_combine().

This code missed the need to update the combined state's
nullbitmap if state1 already had a bitmap but state2 didn't.
We need to extend the existing bitmap with 1's but didn't.
This could result in wrong output from a parallelized
array_agg(anyarray) calculation, if the input has a mix of
null and non-null elements.  The errors depended on timing
of the parallel workers, and therefore would vary from one
run to another.

Also install guards against integer overflow when calculating
the combined object's sizes, and make some trivial cosmetic
improvements.

Author: Dmytro Astapov <dastapov@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAFQUnFj2pQ1HbGp69+w2fKqARSfGhAi9UOb+JjyExp7kx3gsqA@mail.gmail.com
Backpatch-through: 16
src/backend/utils/adt/array_userfuncs.c