Re: Fix error message when trying to alter statistics on included column

From: Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix error message when trying to alter statistics on included column
Date: 2018-07-06 07:09:28
Message-ID: 20180706160928.aa353786.nagata@sraoss.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 2 Jul 2018 14:23:09 -0400
Robert Haas <robertmhaas(at)gmail(dot)com> wrote:

> On Thu, Jun 28, 2018 at 5:28 AM, Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp> wrote:
> > According to the error message, it is not allowed to alter statistics on
> > included column because this is "non-expression column".
> >
> > postgres=# create table test (i int, d int);
> > CREATE TABLE
> > postgres=# create index idx on test(i) include (d);
> > CREATE INDEX
> > postgres=# alter index idx alter column 2 set statistics 10;
> > ERROR: cannot alter statistics on non-expression column "d" of index "idx"
> > HINT: Alter statistics on table column instead.
> >
> > However, I think this should be forbidded in that this is not a key column
> > but a included column. Even if we decide to support expressions in included
> > columns in future, it is meaningless to do this because any statistics on
> > included column is never used by the planner.
> >
> > Attached is the patch to fix the error message. In this fix, column number
> > is checked first. After applying this, the message is changed as below;
> >
> > postgres=# alter index idx alter column 2 set statistics 10;
> > ERROR: cannot alter statistics on included column "d" of index "idx"
>
> I think you should add an open item for this.

I was about to add this to the wiki, but someone has already done this. Thanks!
https://wiki.postgresql.org/wiki/PostgreSQL_11_Open_Items

>
> --
> Robert Haas
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>

--
Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Yugo Nagata 2018-07-06 07:36:46 Re: CREATE TABLE .. LIKE .. EXCLUDING documentation
Previous Message Kyotaro HORIGUCHI 2018-07-06 06:37:57 Re: Non-reserved replication slots and slot advancing