Re: Assertion failure when importing expression statistics with nested JSON values

From: Ilia Evdokimov <ilya(dot)evdokimov(at)tantorlabs(dot)com>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Assertion failure when importing expression statistics with nested JSON values
Date: 2026-11-03 08:11:12
Message-ID: d76d4528-1602-4181-82fe-2bcf9ace90e0@tantorlabs.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Chao,

Thanks for review.

On 11/3/26 10:59, Chao Li wrote:
>> On Nov 3, 2026, at 03:13, Ilia Evdokimov<ilya(dot)evdokimov(at)tantorlabs(dot)com> wrote:
>>
>> Hi,
>>
>> On an assertion-enabled build, `pg_restore_extended_stats()` triggers an assertion failure in check_all_expr_argnames_valid() when an expression statistics object contains an unknown JSON key with an array value
>>
>> ```
>> CREATE TABLE t (i INT);
>> CREATE STATISTICS t_stats ON (i + 1) FROM t;
>> SELECT pg_catalog.pg_restore_extended_stats(
>> 'schemaname', 'public',
>> 'relname', 't',
>> 'statistics_schemaname', 'public',
>> 'statistics_name', 't_stats',
>> 'inherited', false,
>> 'exprs', '[{"unknown": []}]'::jsonb
>> );
>>
>> server closed the connection unexpectedly
>> This probably means the server terminated abnormally
>> before or while processing the request.
>> The connection to the server was lost. Attempting reset: Failed.
>> The connection to the server was lost. Attempting reset: Failed.
>> ```
> I doubt this bug is likely to be encountered in practice, but I agree that the server should not crash on invalid input anyway.

So do I. Without asserts, the backend enters an infinite loop that does
not respond to query cancellation, so it cannot be stopped through
normal cancellation.

--
Best regards,
Ilia Evdokimov,
Tantor Labs LLC,
https://tantorlabs.com/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2026-11-03 08:17:09 Re: Proposal: Conflict log history table for Logical Replication
Previous Message Peter Smith 2026-11-03 08:02:24 Re: PSQL - improve tab completion for pub/sub options