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

Chao Li <li.evan.chao@gmail.com>

From: Chao Li <li.evan.chao@gmail.com>
To: Pgsql Hackers <pgsql-hackers@postgresql.org>
Cc: Michael Paquier <michael@paquier.xyz>, Yugo Nagata <nagata@sraoss.co.jp>, John Naylor <johncnaylorls@gmail.com>, Dean Rasheed <dean.a.rasheed@gmail.com>
Date: 2026-03-30T03:19:36Z
Lists: pgsql-hackers

> On Mar 27, 2026, at 08:45, John Naylor <johncnaylorls@gmail.com> wrote:
> 
> On Fri, Mar 27, 2026 at 6:23 AM Michael Paquier <michael@paquier.xyz> wrote:
>> -    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
> 
> My reading of that is that hints/details need to be complete
> sentences, and primary messages don't need to be. 

+1


> From: Dean Rasheed <dean.a.rasheed@gmail.com>
> 
> 
> If we were to give more detail, it should probably be to point out
> that regular statistics will already be built for single columns,
> which is why single-column extended statistics would be redundant. So
> perhaps something like this:
> 
> Error: cannot create extended statistics on a single column
> Detail: Univariate statistics are already built for each individual
> table column.

I like this version.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/







Commits

  1. Split CREATE STATISTICS error reasons out into errdetails