public inbox for [email protected]help / color / mirror / Atom feed
Re: Adjust error message for CREATE STATISTICS to account for expressions 10+ messages / 5 participants [nested] [flat]
* Re: Adjust error message for CREATE STATISTICS to account for expressions @ 2026-03-25 01:24 John Naylor <[email protected]> 2026-03-26 09:22 ` Re: Adjust error message for CREATE STATISTICS to account for expressions John Naylor <[email protected]> 0 siblings, 1 reply; 10+ messages in thread From: John Naylor @ 2026-03-25 01:24 UTC (permalink / raw) To: Yugo Nagata <[email protected]>; +Cc: pgsql-hackers On Tue, Mar 24, 2026 at 6:34 PM Yugo Nagata <[email protected]> wrote: > > Hi, > > I've attached a patch to adjust the error message for CREATE STATISTICS > to account for expressions. > > Previously, when attempting to create extended statistics on a single column, > the following error is raised. > > ERROR: extended statistics require at least 2 columns > > However, this message assumed only columns. In reality, an expression on a > single column is also allowed, so two columns are not necessarily required. > Thgis patch updates the message to: > > ERROR: extended statistics require at least 2 columns or an expression I'm ambivalent about this. Instead of trying to document all the possible valid possibilities (which may get out of date again), maybe we can say that it's not allowed on a single column? -- John Naylor Amazon Web Services ^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Adjust error message for CREATE STATISTICS to account for expressions 2026-03-25 01:24 Re: Adjust error message for CREATE STATISTICS to account for expressions John Naylor <[email protected]> @ 2026-03-26 09:22 ` John Naylor <[email protected]> 2026-03-26 23:23 ` Re: Adjust error message for CREATE STATISTICS to account for expressions Michael Paquier <[email protected]> 0 siblings, 1 reply; 10+ messages in thread From: John Naylor @ 2026-03-26 09:22 UTC (permalink / raw) To: Yugo Nagata <[email protected]>; +Cc: pgsql-hackers On Wed, Mar 25, 2026 at 11:15 AM Yugo Nagata <[email protected]> wrote: > > On Wed, 25 Mar 2026 08:24:40 +0700 > John Naylor <[email protected]> wrote: > > I'm ambivalent about this. Instead of trying to document all the > > possible valid possibilities (which may get out of date again), maybe > > we can say that it's not allowed on a single column? > > Thank you for the suggestion. I agree that this is a simpler approach, > so I've attached a revised patch. - errmsg("extended statistics require at least 2 columns"))); + errmsg("extended statistics are not supported on a single column"))); I'd probably write this as "extended statistics on a single column are not supported" (no need to send a new patch). Any objections? 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. I looked in the feature thread and saw that this was actually raised during development of the feature: https://www.postgresql.org/message-id/CAEZATCU9uPo7JYdx4k0-ufXXZH8t7itodibUwCva%2Bs%2BAvAKcnw%40mail... -- John Naylor Amazon Web Services ^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Adjust error message for CREATE STATISTICS to account for expressions 2026-03-25 01:24 Re: Adjust error message for CREATE STATISTICS to account for expressions John Naylor <[email protected]> 2026-03-26 09:22 ` Re: Adjust error message for CREATE STATISTICS to account for expressions John Naylor <[email protected]> @ 2026-03-26 23:23 ` Michael Paquier <[email protected]> 2026-03-27 00:45 ` Re: Adjust error message for CREATE STATISTICS to account for expressions John Naylor <[email protected]> 0 siblings, 1 reply; 10+ messages in thread From: Michael Paquier @ 2026-03-26 23:23 UTC (permalink / raw) To: John Naylor <[email protected]>; +Cc: Yugo Nagata <[email protected]>; 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 Attachments: [application/pgp-signature] signature.asc (833B, 2-signature.asc) download ^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Adjust error message for CREATE STATISTICS to account for expressions 2026-03-25 01:24 Re: Adjust error message for CREATE STATISTICS to account for expressions John Naylor <[email protected]> 2026-03-26 09:22 ` Re: Adjust error message for CREATE STATISTICS to account for expressions John Naylor <[email protected]> 2026-03-26 23:23 ` Re: Adjust error message for CREATE STATISTICS to account for expressions Michael Paquier <[email protected]> @ 2026-03-27 00:45 ` John Naylor <[email protected]> 2026-03-27 09:50 ` Re: Adjust error message for CREATE STATISTICS to account for expressions Dean Rasheed <[email protected]> 2026-03-30 03:19 ` Re: Adjust error message for CREATE STATISTICS to account for expressions Chao Li <[email protected]> 0 siblings, 2 replies; 10+ messages in thread From: John Naylor @ 2026-03-27 00:45 UTC (permalink / raw) To: Michael Paquier <[email protected]>; +Cc: Yugo Nagata <[email protected]>; pgsql-hackers On Fri, Mar 27, 2026 at 6:23 AM Michael Paquier <[email protected]> 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. If the obvious way to write primary message is with a complete sentence, I would say that's fine, but I don't have a lot of context here. > 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? I don't feel strongly either way, so in that case I would default to not changing to errdetail. Looking elsewhere in this file, however, I do see some messages with "cannot do X because ....", and I'd be more motivated to turn those "because" phrases into errdetails. -- John Naylor Amazon Web Services ^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Adjust error message for CREATE STATISTICS to account for expressions 2026-03-25 01:24 Re: Adjust error message for CREATE STATISTICS to account for expressions John Naylor <[email protected]> 2026-03-26 09:22 ` Re: Adjust error message for CREATE STATISTICS to account for expressions John Naylor <[email protected]> 2026-03-26 23:23 ` Re: Adjust error message for CREATE STATISTICS to account for expressions Michael Paquier <[email protected]> 2026-03-27 00:45 ` Re: Adjust error message for CREATE STATISTICS to account for expressions John Naylor <[email protected]> @ 2026-03-27 09:50 ` Dean Rasheed <[email protected]> 2026-03-30 03:21 ` Re: Adjust error message for CREATE STATISTICS to account for expressions John Naylor <[email protected]> 1 sibling, 1 reply; 10+ messages in thread From: Dean Rasheed @ 2026-03-27 09:50 UTC (permalink / raw) To: Yugo Nagata <[email protected]>; +Cc: John Naylor <[email protected]>; Michael Paquier <[email protected]>; pgsql-hackers On Fri, 27 Mar 2026 at 04:46, Yugo Nagata <[email protected]> wrote: > > On Fri, 27 Mar 2026 07:45:37 +0700 > John Naylor <[email protected]> wrote: > > > On Fri, Mar 27, 2026 at 6:23 AM Michael Paquier <[email protected]> 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. If the obvious way > > to write primary message is with a complete sentence, I would say > > that's fine, but I don't have a lot of context here. > > > > > 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? > > > > I don't feel strongly either way, so in that case I would default to > > not changing to errdetail. Looking elsewhere in this file, however, I > > do see some messages with "cannot do X because ....", and I'd be more > > motivated to turn those "because" phrases into errdetails. > > I don't have a strong preference here, so I'm fine with either approach. > I also agree that moving "because ..." into errdetails in some longer > messages makes sense. I don't think it should be a hint, because that's more for suggestions on how to fix the problem. Given that the user just tried to create extended statistics on a single column, they're probably not interested in expression statistics or multivariate statistics, so a single short "not supported" error seems sufficient. 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. Regards, Dean ^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Adjust error message for CREATE STATISTICS to account for expressions 2026-03-25 01:24 Re: Adjust error message for CREATE STATISTICS to account for expressions John Naylor <[email protected]> 2026-03-26 09:22 ` Re: Adjust error message for CREATE STATISTICS to account for expressions John Naylor <[email protected]> 2026-03-26 23:23 ` Re: Adjust error message for CREATE STATISTICS to account for expressions Michael Paquier <[email protected]> 2026-03-27 00:45 ` Re: Adjust error message for CREATE STATISTICS to account for expressions John Naylor <[email protected]> 2026-03-27 09:50 ` Re: Adjust error message for CREATE STATISTICS to account for expressions Dean Rasheed <[email protected]> @ 2026-03-30 03:21 ` John Naylor <[email protected]> 2026-04-01 16:19 ` Re: Adjust error message for CREATE STATISTICS to account for expressions Dean Rasheed <[email protected]> 0 siblings, 1 reply; 10+ messages in thread From: John Naylor @ 2026-03-30 03:21 UTC (permalink / raw) To: Yugo Nagata <[email protected]>; +Cc: Dean Rasheed <[email protected]>; Michael Paquier <[email protected]>; pgsql-hackers On Sat, Mar 28, 2026 at 1:04 PM Yugo Nagata <[email protected]> wrote: > > On Fri, 27 Mar 2026 09:50:07 +0000 > Dean Rasheed <[email protected]> wrote: > > 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. > > That makes sense to me. > > Using an errdetail to explain the reason sounds reasonable. Works for me. > > > On Fri, 27 Mar 2026 07:45:37 +0700 > > > John Naylor <[email protected]> wrote: > > > > Looking elsewhere in this file, however, I > > > > do see some messages with "cannot do X because ....", and I'd be more > > > > motivated to turn those "because" phrases into errdetails. Did you also want to try tackling this while we're here? -- John Naylor Amazon Web Services ^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Adjust error message for CREATE STATISTICS to account for expressions 2026-03-25 01:24 Re: Adjust error message for CREATE STATISTICS to account for expressions John Naylor <[email protected]> 2026-03-26 09:22 ` Re: Adjust error message for CREATE STATISTICS to account for expressions John Naylor <[email protected]> 2026-03-26 23:23 ` Re: Adjust error message for CREATE STATISTICS to account for expressions Michael Paquier <[email protected]> 2026-03-27 00:45 ` Re: Adjust error message for CREATE STATISTICS to account for expressions John Naylor <[email protected]> 2026-03-27 09:50 ` Re: Adjust error message for CREATE STATISTICS to account for expressions Dean Rasheed <[email protected]> 2026-03-30 03:21 ` Re: Adjust error message for CREATE STATISTICS to account for expressions John Naylor <[email protected]> @ 2026-04-01 16:19 ` Dean Rasheed <[email protected]> 2026-04-03 01:44 ` Re: Adjust error message for CREATE STATISTICS to account for expressions Yugo Nagata <[email protected]> 0 siblings, 1 reply; 10+ messages in thread From: Dean Rasheed @ 2026-04-01 16:19 UTC (permalink / raw) To: Yugo Nagata <[email protected]>; +Cc: John Naylor <[email protected]>; Michael Paquier <[email protected]>; pgsql-hackers On Tue, 31 Mar 2026 at 15:47, Yugo Nagata <[email protected]> wrote: > > Yes, that sounds good to me. > > In particular, the following suggestion from Dean Rasheed seems like a > good approach: > > > Error: cannot create extended statistics on a single column > > Detail: Univariate statistics are already built for each individual > > table column I've pushed that change as part of the patch to support extended statistics on virtual generated columns [1], since I felt that patch already needed to change that error message. I didn't look more widely at other error messages in that file might benefit from having separate errdetail text. Regards, Dean [1] https://www.postgresql.org/message-id/flat/[email protected] ^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Adjust error message for CREATE STATISTICS to account for expressions 2026-03-25 01:24 Re: Adjust error message for CREATE STATISTICS to account for expressions John Naylor <[email protected]> 2026-03-26 09:22 ` Re: Adjust error message for CREATE STATISTICS to account for expressions John Naylor <[email protected]> 2026-03-26 23:23 ` Re: Adjust error message for CREATE STATISTICS to account for expressions Michael Paquier <[email protected]> 2026-03-27 00:45 ` Re: Adjust error message for CREATE STATISTICS to account for expressions John Naylor <[email protected]> 2026-03-27 09:50 ` Re: Adjust error message for CREATE STATISTICS to account for expressions Dean Rasheed <[email protected]> 2026-03-30 03:21 ` Re: Adjust error message for CREATE STATISTICS to account for expressions John Naylor <[email protected]> 2026-04-01 16:19 ` Re: Adjust error message for CREATE STATISTICS to account for expressions Dean Rasheed <[email protected]> @ 2026-04-03 01:44 ` Yugo Nagata <[email protected]> 2026-04-07 04:40 ` Re: Adjust error message for CREATE STATISTICS to account for expressions John Naylor <[email protected]> 0 siblings, 1 reply; 10+ messages in thread From: Yugo Nagata @ 2026-04-03 01:44 UTC (permalink / raw) To: Dean Rasheed <[email protected]>; +Cc: John Naylor <[email protected]>; Michael Paquier <[email protected]>; pgsql-hackers On Wed, 1 Apr 2026 17:19:16 +0100 Dean Rasheed <[email protected]> wrote: > On Tue, 31 Mar 2026 at 15:47, Yugo Nagata <[email protected]> wrote: > > > > Yes, that sounds good to me. > > > > In particular, the following suggestion from Dean Rasheed seems like a > > good approach: > > > > > Error: cannot create extended statistics on a single column > > > Detail: Univariate statistics are already built for each individual > > > table column > > I've pushed that change as part of the patch to support extended > statistics on virtual generated columns [1], since I felt that patch > already needed to change that error message. Thank you for handling this. > I didn't look more widely at other error messages in that file might > benefit from having separate errdetail text. I’ve attached a patch that also updates other error messages to move their reason parts into errdetail. Regards, Yugo Nagata -- Yugo Nagata <[email protected]> Attachments: [text/x-diff] v3-Adjust_error_message_for_CREATE_STATISTICS.patch (3.0K, 2-v3-Adjust_error_message_for_CREATE_STATISTICS.patch) download | inline diff: diff --git a/src/backend/commands/statscmds.c b/src/backend/commands/statscmds.c index eea45106a3f..b354723be44 100644 --- a/src/backend/commands/statscmds.c +++ b/src/backend/commands/statscmds.c @@ -280,8 +280,10 @@ CreateStatistics(CreateStatsStmt *stmt, bool check_rights) if (type->lt_opr == InvalidOid) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("column \"%s\" cannot be used in multivariate statistics because its type %s has no default btree operator class", - attname, format_type_be(attForm->atttypid)))); + errmsg("cannot create multivariate statistics on column \"%s\"", + attname), + errdetail("The type %s has no default btree operator class.", + format_type_be(attForm->atttypid)))); } /* Treat virtual generated columns as expressions */ @@ -325,8 +327,10 @@ CreateStatistics(CreateStatsStmt *stmt, bool check_rights) if (type->lt_opr == InvalidOid) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("column \"%s\" cannot be used in multivariate statistics because its type %s has no default btree operator class", - get_attname(relid, var->varattno, false), format_type_be(var->vartype)))); + errmsg("cannot create multivariate statistics on column \"%s\"", + get_attname(relid, var->varattno, false)), + errdetail("The type %s has no default btree operator class.", + format_type_be(var->vartype)))); } /* Treat virtual generated columns as expressions */ @@ -375,8 +379,9 @@ CreateStatistics(CreateStatsStmt *stmt, bool check_rights) if (type->lt_opr == InvalidOid) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("expression cannot be used in multivariate statistics because its type %s has no default btree operator class", - format_type_be(atttype)))); + errmsg("cannot create multivariate statistics on this expression"), + errdetail("The type %s has no default btree operator class.", + format_type_be(atttype)))); } stxexprs = lappend(stxexprs, expr); diff --git a/src/test/regress/expected/stats_ext.out b/src/test/regress/expected/stats_ext.out index c6ba2479413..37070c1a896 100644 --- a/src/test/regress/expected/stats_ext.out +++ b/src/test/regress/expected/stats_ext.out @@ -99,7 +99,8 @@ CREATE STATISTICS tst (ndistinct) ON (y + z) FROM ext_stats_test; ERROR: cannot specify statistics kinds when building univariate statistics -- multivariate statistics without a less-than operator not supported CREATE STATISTICS tst (ndistinct) ON x, w from ext_stats_test; -ERROR: column "w" cannot be used in multivariate statistics because its type xid has no default btree operator class +ERROR: cannot create multivariate statistics on column "w" +DETAIL: The type xid has no default btree operator class. DROP TABLE ext_stats_test; -- Ensure stats are dropped sanely, and test IF NOT EXISTS while at it CREATE TABLE ab1 (a INTEGER, b INTEGER, c INTEGER); ^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Adjust error message for CREATE STATISTICS to account for expressions 2026-03-25 01:24 Re: Adjust error message for CREATE STATISTICS to account for expressions John Naylor <[email protected]> 2026-03-26 09:22 ` Re: Adjust error message for CREATE STATISTICS to account for expressions John Naylor <[email protected]> 2026-03-26 23:23 ` Re: Adjust error message for CREATE STATISTICS to account for expressions Michael Paquier <[email protected]> 2026-03-27 00:45 ` Re: Adjust error message for CREATE STATISTICS to account for expressions John Naylor <[email protected]> 2026-03-27 09:50 ` Re: Adjust error message for CREATE STATISTICS to account for expressions Dean Rasheed <[email protected]> 2026-03-30 03:21 ` Re: Adjust error message for CREATE STATISTICS to account for expressions John Naylor <[email protected]> 2026-04-01 16:19 ` Re: Adjust error message for CREATE STATISTICS to account for expressions Dean Rasheed <[email protected]> 2026-04-03 01:44 ` Re: Adjust error message for CREATE STATISTICS to account for expressions Yugo Nagata <[email protected]> @ 2026-04-07 04:40 ` John Naylor <[email protected]> 0 siblings, 0 replies; 10+ messages in thread From: John Naylor @ 2026-04-07 04:40 UTC (permalink / raw) To: Yugo Nagata <[email protected]>; +Cc: Dean Rasheed <[email protected]>; Michael Paquier <[email protected]>; pgsql-hackers On Fri, Apr 3, 2026 at 8:44 AM Yugo Nagata <[email protected]> wrote: > I’ve attached a patch that also updates other error messages to move > their reason parts into errdetail. Pushed, thanks! -- John Naylor Amazon Web Services ^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Adjust error message for CREATE STATISTICS to account for expressions 2026-03-25 01:24 Re: Adjust error message for CREATE STATISTICS to account for expressions John Naylor <[email protected]> 2026-03-26 09:22 ` Re: Adjust error message for CREATE STATISTICS to account for expressions John Naylor <[email protected]> 2026-03-26 23:23 ` Re: Adjust error message for CREATE STATISTICS to account for expressions Michael Paquier <[email protected]> 2026-03-27 00:45 ` Re: Adjust error message for CREATE STATISTICS to account for expressions John Naylor <[email protected]> @ 2026-03-30 03:19 ` Chao Li <[email protected]> 1 sibling, 0 replies; 10+ messages in thread From: Chao Li @ 2026-03-30 03:19 UTC (permalink / raw) To: pgsql-hackers; +Cc: Michael Paquier <[email protected]>; Yugo Nagata <[email protected]>; John Naylor <[email protected]>; Dean Rasheed <[email protected]> > On Mar 27, 2026, at 08:45, John Naylor <[email protected]> wrote: > > On Fri, Mar 27, 2026 at 6:23 AM Michael Paquier <[email protected]> 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 <[email protected]> > > > 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/ ^ permalink raw reply [nested|flat] 10+ messages in thread
end of thread, other threads:[~2026-04-07 04:40 UTC | newest] Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-03-25 01:24 Re: Adjust error message for CREATE STATISTICS to account for expressions John Naylor <[email protected]> 2026-03-26 09:22 ` John Naylor <[email protected]> 2026-03-26 23:23 ` Michael Paquier <[email protected]> 2026-03-27 00:45 ` John Naylor <[email protected]> 2026-03-27 09:50 ` Dean Rasheed <[email protected]> 2026-03-30 03:21 ` John Naylor <[email protected]> 2026-04-01 16:19 ` Dean Rasheed <[email protected]> 2026-04-03 01:44 ` Yugo Nagata <[email protected]> 2026-04-07 04:40 ` John Naylor <[email protected]> 2026-03-30 03:19 ` Chao Li <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox