Fix error message when trying to alter statistics on includedcolumn

Поиск
Список
Период
Сортировка
От Yugo Nagata
Тема Fix error message when trying to alter statistics on includedcolumn
Дата
Msg-id 20180628182803.e4632d5a.nagata@sraoss.co.jp
обсуждение исходный текст
Ответы Re: Fix error message when trying to alter statistics on included column  (Robert Haas <robertmhaas@gmail.com>)
Re: Fix error message when trying to alter statistics on includedcolumn  (Andres Freund <andres@anarazel.de>)
Re: Fix error message when trying to alter statistics on includedcolumn  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Список pgsql-hackers
Hi,

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"

Regards,

-- 
Yugo Nagata <nagata@sraoss.co.jp>

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Amit Langote
Дата:
Сообщение: Re: partition tree inspection functions
Следующее
От: Peter Moser
Дата:
Сообщение: Re: Unexpected behavior of DROP VIEW/TABLE IF EXISTS