Re: Adjust error message for CREATE STATISTICS to account for expressions
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: John Naylor <johncnaylorls@gmail.com>
Cc: Yugo Nagata <nagata@sraoss.co.jp>, Pgsql Hackers <pgsql-hackers@postgresql.org>
Date: 2026-03-26T23:23:45Z
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
Commits
-
Split CREATE STATISTICS error reasons out into errdetails
- 51098839cfb4 19 (unreleased) landed