Re: misleading error message in ProcessUtilitySlow T_CreateStatsStmt

Álvaro Herrera <alvherre@kurilemu.de>

From: Álvaro Herrera <alvherre@kurilemu.de>
To: jian he <jian.universality@gmail.com>
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: 2026-05-15T14:04:52Z
Lists: pgsql-hackers
On 2025-Dec-17, jian he wrote:

> diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
> index bc7adba4a0f..326d30cfb2f 100644
> --- a/src/include/nodes/parsenodes.h
> +++ b/src/include/nodes/parsenodes.h
> @@ -3551,6 +3551,10 @@ typedef struct CreateStatsStmt
>  	List	   *stat_types;		/* stat types (list of String) */
>  	List	   *exprs;			/* expressions to build statistics on */
>  	List	   *relations;		/* rels to build stats on (list of RangeVar) */
> +	List	   *from_clause;	/* FROM clause ((list of RangeVar)) */
> +	List	   *rtable;			/* It’s not derived directly from the
> +								 * parser, instead it comes from parse
> +								 * analysis. (list of RangeTblEntry) */
>  	char	   *stxcomment;		/* comment to apply to stats, or NULL */
>  	bool		transformed;	/* true when transformStatsStmt is finished */
>  	bool		if_not_exists;	/* do nothing if stats name already exists */

I'm unconvinced about this, and I wonder if it would make sense to have
two separate nodes, one which is pre-transform (direct out of parser)
and another which is post-transform.  Would that things a bit simpler?

-- 
Álvaro Herrera               48°01'N 7°57'E  —  https://www.EnterpriseDB.com/
"We have labored long to build a heaven, only            (Prof. Milton Glass)
 to find it populated with horrors"                    (Watchmen, Alan Moore)