Forbid referencing columns by names in ALTER INDEX ... SET STATISTICS

Started by Yugo Nagataabout 8 years ago3 messageshackers
Jump to latest
#1Yugo Nagata
nagata@sraoss.co.jp

Hi,

According to the syntax in ALTER INDEX doc, a column should be specified by
column number as discussed in [1]/messages/by-id/CAPpHfdsSYo6xpt0F=ngAdqMPFJJhC7zApde9h1qwkdpHpwFisA@mail.gmail.com. However, the current code still allows to
use an internal column name like "expr". Is this intentional?

Although it is harmless, how about forbiding this undocumented and
unuseful behavior. The attached patch does it.

[1]: /messages/by-id/CAPpHfdsSYo6xpt0F=ngAdqMPFJJhC7zApde9h1qwkdpHpwFisA@mail.gmail.com

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

Attachments:

forbid_expr_index_col_by_name.patchtext/x-diff; name=forbid_expr_index_col_by_name.patchDownload+6-0
#2Robert Haas
robertmhaas@gmail.com
In reply to: Yugo Nagata (#1)
Re: Forbid referencing columns by names in ALTER INDEX ... SET STATISTICS

On Wed, Jun 27, 2018 at 9:22 AM, Yugo Nagata <nagata@sraoss.co.jp> wrote:

According to the syntax in ALTER INDEX doc, a column should be specified by
column number as discussed in [1]. However, the current code still allows to
use an internal column name like "expr". Is this intentional?

Although it is harmless, how about forbiding this undocumented and
unuseful behavior. The attached patch does it.

If it's harmless, why prohibit it?

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

#3Yugo Nagata
nagata@sraoss.co.jp
In reply to: Robert Haas (#2)
Re: Forbid referencing columns by names in ALTER INDEX ... SET STATISTICS

On Thu, 28 Jun 2018 10:26:13 -0400
Robert Haas <robertmhaas@gmail.com> wrote:

On Wed, Jun 27, 2018 at 9:22 AM, Yugo Nagata <nagata@sraoss.co.jp> wrote:

According to the syntax in ALTER INDEX doc, a column should be specified by
column number as discussed in [1]. However, the current code still allows to
use an internal column name like "expr". Is this intentional?

Although it is harmless, how about forbiding this undocumented and
unuseful behavior. The attached patch does it.

If it's harmless, why prohibit it?

I thought that we should prohibit it because this is not allowed
according to the documented syntax. However, don't we have to be
so rigorous about it?

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

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