Re: misleading error message in ProcessUtilitySlow T_CreateStatsStmt
jian he <jian.universality@gmail.com>
From: jian he <jian.universality@gmail.com>
To: Álvaro Herrera <alvherre@kurilemu.de>
Cc: Peter Eisentraut <peter@eisentraut.org>, Tom Lane <tgl@sss.pgh.pa.us>, PostgreSQL-development <pgsql-hackers@postgresql.org>,
Kirill Reshke <reshkekirill@gmail.com>
Date: 2025-12-17T05:49:36Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
CREATE STATISTICS: improve misleading error message
- cbd3732cbbaa 14.20 landed
- 4529861cc408 15.15 landed
- f30c04682cdf 16.11 landed
- f9b41f3e1ecd 17.7 landed
- 38883916e41c 18.0 landed
- 9ec0b29976b6 19 (unreleased) landed
- f9a7622483c3 15.15 landed
- f225473cbae2 19 (unreleased) landed
- e9fb314c7ad8 17.7 landed
- d84a6c3dad1f 16.11 landed
- b830f9d67463 14.20 landed
- 3eea4dc2c7cf 18.0 landed
-
Glossary: improve definition of "relation"
- 16a9165ce4a4 19 (unreleased) landed
-
Extended statistics on expressions
- a4d75c86bf15 14.0 cited
Attachments
- v6-0001-Restructure-CreateStatsStmt-parse-analysis-processing.patch (text/x-patch) patch v6-0001
On Thu, Nov 13, 2025 at 5:41 PM Álvaro Herrera <alvherre@kurilemu.de> wrote:
>
>
> > @@ -15658,10 +15658,19 @@ ATPostAlterTypeParse(Oid oldId, Oid oldRelId, Oid refRelId, char *cmd,
> > querytree_list = list_concat(querytree_list, afterStmts);
> > }
> > else if (IsA(stmt, CreateStatsStmt))
> > + {
> > + RangeTblEntry *rte;
> > + CreateStatsStmt *ss = castNode(CreateStatsStmt, stmt);
> > +
> > + rte = makeNode(RangeTblEntry);
> > + rte->rtekind = RTE_RELATION;
> > + rte->relid = oldRelId;
> > + rte->rellockmode = ShareUpdateExclusiveLock;
> > + ss->rtable = list_make1(rte);
> > +
> > querytree_list = lappend(querytree_list,
> > - transformStatsStmt(oldRelId,
> > - (CreateStatsStmt *) stmt,
> > - cmd));
> > + transformStatsStmt(ss, cmd));
> > + }
> > else
> > querytree_list = lappend(querytree_list, stmt);
> > }
>
> Hmm, how would this part here work in the hypothetical world where a
> stats object references multiple relations?
>
hi.
For extended statistics that span multiple relations (hypothetically),
we should have the OIDs of
all involved relations within the pg_statistic_ext catalog. Without this , it's
hard to do statistic's expression deparse, changing column data types
or generation
expressions. Catalog pg_depend do have statistics associated relation OIDs
information, relying on it for statistical expression deparsing would be more
complicated.
Once pg_statistic_ext have all relation oid information,
RememberStatisticsForRebuilding will not only collecting
AlteredTableInfo->changedStatisticsOids, it will aslo collect the OID of other
relations associated with this statistic.
For the above quoted part, we should construct a RangeTblEntry for
each associated
relation (OID).
Obviously transformStatsStmt itself needs to figure out how to
deal with multi-relation expressions.
rebased and minor polishing.
--
jian
https://www.enterprisedb.com