From: Álvaro Herrera <alvherre@kurilemu.de>
To: Kirill Reshke <reshkekirill@gmail.com>
Cc: jian he <jian.universality@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: misleading error message in ProcessUtilitySlow T_CreateStatsStmt
Date: Fri, 22 Aug 2025 17:34:06 +0200
Message-ID: <202508221534.z4xe7cg4dwsu@alvherre.pgsql> (raw)
In-Reply-To: <CALdSSPjb98dqy6bq4OmS23c7yYUDNET+pX6=G=SUFUQKe_ULmA@mail.gmail.com>
On 2025-Aug-22, Kirill Reshke wrote:
> I am sorry: I am not following. CREATE STATISTIC will work only for
> single HEAP (or other AM) relations. So, for "simple regular tables"
> as one can say (not tablefunc).
Ah yeah, you're right, I think we should say "a single table", or maybe
"a single table or materialized view" if the latter case is supported (I
don't remember offhand if it is).
The error message is mostly concerned with rejecting the case of
multiple relations being given in the FROM clause, because we said at
the time that we needed to make the grammar flexible enough to support
that case, but make it clear that it wasn't implemented yet. (It's a
pity that we haven't implemented that thus far ... I suppose it must be
a difficult problem.)
> DETAIL: This operation is not supported for query result.
I would say "This operation is only supported for tables [and
matviews]." We don't need to list all the things that aren't supported,
I think. But your example here is wrong:
> db=# CREATE STATISTICS alt_stat2 ON a, b FROM tftest(1);
> ERROR: cannot define statistics for relation "alt_stat2"
> DETAIL: This operation is not supported for query result.
It's not alt_stat2 that's the problem (that's the extstats object being
created), but tftest(1). I don't know if we need to specify that the
problem is in the FROM clause here -- seems obvious enough to me -- but
maybe someone opines differently?
ERROR: cannot define statistics for relation "tftest"
DETAIL: The FROM clause may only contain a single table.
--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
"Si quieres ser creativo, aprende el arte de perder el tiempo"
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: pgsql-hackers@postgresql.org
Cc: alvherre@kurilemu.de, reshkekirill@gmail.com, jian.universality@gmail.com
Subject: Re: misleading error message in ProcessUtilitySlow T_CreateStatsStmt
In-Reply-To: <202508221534.z4xe7cg4dwsu@alvherre.pgsql>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox