Re: Making jsonb_agg() faster

From: Alexander Lakhin <exclusion(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: jian he <jian(dot)universality(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Making jsonb_agg() faster
Date: 2025-12-13 11:00:00
Message-ID: ec5e96fb-ee49-4e5f-8a09-3f72b4780538@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello Tom,

07.12.2025 18:58, Tom Lane wrote:
>> That’s even better than resolving my comment.
> Cool, done like that then.

I and SQLsmith have discovered that the following query:
select jsonb_object_agg_unique_strict(i, null) over (order by i) from
          (select i from generate_series(1, 20) g(i));

triggers SIGSEGV:
Core was generated by `postgres: law regression [local] SELECT                                       '.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  MemoryChunkGetValue (chunk=0x5af800000001) at ../../../../src/include/utils/memutils_memorychunk.h:224
224             Assert(!HdrMaskIsExternal(chunk->hdrmask));
(gdb) bt
#0  MemoryChunkGetValue (chunk=0x5af800000001) at ../../../../src/include/utils/memutils_memorychunk.h:224
#1  AllocSetAlloc (context=0x5af8d6709330, size=8, flags=<optimized out>) at aset.c:1056
#2  0x00005af8b9b5db40 in palloc (size=size(at)entry=8) at mcxt.c:1386
#3  0x00005af8b9a177e1 in datumCopy (value=100024796075024, typByVal=typByVal(at)entry=false, typLen=<optimized out>) at
datum.c:162
#4  0x00005af8b98071a3 in eval_windowaggregates (winstate=0x5af8d66f8b00) at nodeWindowAgg.c:1053
#5  ExecWindowAgg (pstate=0x5af8d66f8b00) at nodeWindowAgg.c:2367
#6  0x00005af8b97c0465 in ExecProcNode (node=0x5af8d66f8b00) at ../../../src/include/executor/executor.h:319
#7  ExecutePlan (dest=0x5af8d67025c8, direction=<optimized out>, numberTuples=0, sendTuples=true, operation=CMD_SELECT,
queryDesc=0x5af8d6638620)
    at execMain.c:1707
...
starting from b61aa76e4.

Best regards,
Alexander

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2025-12-13 11:10:46 Re: Proposal: Cascade REPLICA IDENTITY changes to leaf partitions
Previous Message Jelte Fennema-Nio 2025-12-13 10:33:51 Re: Support named (destination) portals in extended proto for psql meta commands.