Re: Adjust error message for CREATE STATISTICS to account for expressions

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: John Naylor <johncnaylorls(at)gmail(dot)com>
Cc: Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp>, Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Adjust error message for CREATE STATISTICS to account for expressions
Date: 2026-03-26 23:23:45
Message-ID: acXAAbIp9tfsvHxy@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Mar 26, 2026 at 04:22:07PM +0700, John Naylor wrote:
> I'd probably write this as "extended statistics on a single column are
> not supported" (no need to send a new patch).
>
> Any objections?

None. I have found this error message puzzling while doing some of my
recent work for extended statistics, because extended statistics can
be created if there is a single element made of an expression in the
list given in input.

> Also, I'm leaning towards not backpatching -- I figure a user that got
> here by fat-fingering an expression is not likely to be too confused.

- errmsg("extended statistics require at least 2 columns")));
+ errmsg("extended statistics are not supported on a single column")));

Now our documentation also tells that the former message is not the
preferred project style (full sentences usually avoided in primary
messages):
https://www.postgresql.org/docs/devel/error-style-guide.html#ERROR-STYLE-GUIDE-GRAMMAR-PUNCTUATION

Perhaps something like "could not create extended statistics" with a
hint describing the cause would be better.. Full sentences usually
apply to errdetails or errhints. If we're on it, we could just as
well improve the whole thing, I guess?
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2026-03-26 23:25:57 Re: pg_plan_advice
Previous Message Álvaro Herrera 2026-03-26 23:21:22 Re: [PATCH v1] Fix typos in pg_bsd_indent: "dont" -> "don't" in comments Anexo: o arquivo