Re: misleading error message in ProcessUtilitySlow T_CreateStatsStmt

From: Kirill Reshke <reshkekirill(at)gmail(dot)com>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: misleading error message in ProcessUtilitySlow T_CreateStatsStmt
Date: 2025-08-21 15:20:52
Message-ID: CALdSSPiZtCRJhe=KdPKEmeYNZQe_yhQKVn3QCsfrCiNdOCTP0A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, 21 Aug 2025 at 17:00, jian he <jian(dot)universality(at)gmail(dot)com> wrote:
>
> hi.

Hi!

> RangeVar *rel = (RangeVar *) linitial(stmt->relations);
> if (!IsA(rel, RangeVar))

These two lines are weird. Looks like linitial(stmt->relations)
should be assigned to variable with type Node* first?

>
> for example:
>
> create or replace function tftest(int) returns table(a int, b int) as $$
> begin
> return query select $1, $1+i from generate_series(1,5) g(i);
> end;
> $$ language plpgsql immutable strict;
>
> CREATE STATISTICS alt_stat2 ON a, b FROM tftest(1);
> ERROR: only a single relation is allowed in CREATE STATISTICS
>
> this error message seem misleading?

I wouldn’t say this is misleading, but " a single relation" is indeed
not precise enough. IMO we need a more precise term to distinguish
regular relation and table func.

> also this error check seems duplicated in CreateStatistics?
>

Indeed.

--
Best regards,
Kirill Reshke

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2025-08-21 15:27:59 Re: misleading error message in ProcessUtilitySlow T_CreateStatsStmt
Previous Message Tom Lane 2025-08-21 15:17:44 Re: Weird error message from Postgres 18