Re: [PATCH] Report malformed integer aggregate states as array errors

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Strydom, Matthys" <strydom(at)amazon(dot)com>
Cc: "Burd, Greg" <gregburd(at)amazon(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Report malformed integer aggregate states as array errors
Date: 2026-11-12 15:54:35
Message-ID: 3832439.1794498875@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Strydom, Matthys" <strydom(at)amazon(dot)com> writes:
> Hi All,
> Several SQL-callable aggregate support functions accept an int8[]
> transition state. They use elog(ERROR) when the supplied state does not
> have the expected two-element shape. This means a direct call such as:

> SELECT int8_avg(ARRAY[1]::int8[]);

> reports SQLSTATE XX000.

> The attached patch reports ERRCODE_ARRAY_SUBSCRIPT_ERROR (2202E)
> instead. This matches existing array-shape checks, including the
> array_agg state handling.

I don't think this is worth the trouble. It's not reasonable for
people to call these functions directly --- indeed there's been
discussion about making that impossible, and then stripping out some
of these error checks.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Joao Rito 2026-11-12 16:12:43 Re: pg_stat_io_histogram
Previous Message Strydom, Matthys 2026-11-12 15:49:29 RE: [PATCH] Report malformed integer aggregate states as array errors