Re: Extended Statistics set/restore/clear functions.

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, Tomas Vondra <tomas(at)vondra(dot)me>, pgsql-hackers(at)lists(dot)postgresql(dot)org, tgl(at)sss(dot)pgh(dot)pa(dot)us
Subject: Re: Extended Statistics set/restore/clear functions.
Date: 2025-11-18 05:39:04
Message-ID: aRwGeN7o22HJclg5@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Nov 18, 2025 at 01:07:23PM +0800, jian he wrote:
> + errsave(parse->escontext,
> + errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
> + errmsg("malformed pg_ndistinct: \"%s\"", parse->str),
> + errdetail("Invalid \"%s\" value.",
> + PG_NDISTINCT_KEY_NDISTINCT));
>
> the errdetail is way too generic?
> similar to ``select 'a'::int;``
> we can
> DETAIL: Invalid input syntax for type integer: "a"
> HINT: "ndistinct" value expected to be a type of integer.
>
> what do you think?

That is intentional, as it is intentional to not show the value of the
token in such cases. This will be mostly used for the import
functions, so I am not sure that it is worth spending time on tuning
all these error cases that one is most likely not going to see as the
main scenarios are going to be through pg_dump/restore, most of the
time in the scope of an upgrade.

> SELECT '[{"attributes" : [2,3], "ndistinct" : 4, "ndistinct" :
> 14}]'::pg_ndistinct;
> pg_ndistinct
> -------------------------------------------
> [{"attributes": [2, 3], "ndistinct": 14}]
>
> SELECT '[{"attributes" : [2,3], "ndistinct" : 4, "attributes" :
> []}]'::pg_ndistinct;
> pg_ndistinct
> ------------------------------------------
> [{"attributes": [2, 3], "ndistinct": 4}]
>
> Is the above output what we expected?

Interesting one. The extra "attributes" should not be required once
we have one set, indeed.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2025-11-18 05:39:36 Re: Add os_page_num to pg_buffercache
Previous Message Thomas Munro 2025-11-18 05:32:38 Re: GNU/Hurd portability patches