public inbox for [email protected]
help / color / mirror / Atom feedFrom: Yugo Nagata <[email protected]>
To: Dean Rasheed <[email protected]>
Cc: John Naylor <[email protected]>
Cc: Michael Paquier <[email protected]>
Cc: Pgsql Hackers <[email protected]>
Subject: Re: Adjust error message for CREATE STATISTICS to account for expressions
Date: Fri, 3 Apr 2026 10:44:53 +0900
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAEZATCX+grmuX5g2zohY4z1vviSnYru7u8AgzF=KpfWnOhc-bw@mail.gmail.com>
References: <[email protected]>
<CANWCAZYdyQzCoAiq9kybHT2RcnC1CgrxbCpyxeV3+KZn2xj2UA@mail.gmail.com>
<[email protected]>
<CANWCAZYjDSsvC6M6pas26ffbj-TZmXOHHC1-DwRM2LFa+qr3GQ@mail.gmail.com>
<[email protected]>
<CANWCAZaZeX0omWNh_ZbD_JVujzYQdRUW8UZOQ4dWh9Sg7OcAow@mail.gmail.com>
<[email protected]>
<CAEZATCX2YDkbNZrACOpeLVQKgOhqTdON20XuTqwjWhSaVqbhUQ@mail.gmail.com>
<[email protected]>
<CANWCAZaYOdb7p=xndzgDfvJ-0NN_HTyx54LVUX2i1Xs7cPSzbw@mail.gmail.com>
<[email protected]>
<CAEZATCX+grmuX5g2zohY4z1vviSnYru7u8AgzF=KpfWnOhc-bw@mail.gmail.com>
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);
view thread (10+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected]
Subject: Re: Adjust error message for CREATE STATISTICS to account for expressions
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox