Re: BUG #17220: ALTER INDEX ALTER COLUMN SET (..) with an optionless opclass makes index and table unusable

From: "Bossart, Nathan" <bossartn(at)amazon(dot)com>
To: Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Vik Fearing <vik(at)postgresfriends(dot)org>, "postgresql(at)zr40(dot)nl" <postgresql(at)zr40(dot)nl>, Alexander Korotkov <aekorotkov(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: BUG #17220: ALTER INDEX ALTER COLUMN SET (..) with an optionless opclass makes index and table unusable
Date: 2021-10-13 17:20:56
Message-ID: 678CF71A-934B-4FD0-BF63-E41D795E41C9@amazon.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On 10/13/21, 1:31 AM, "Dilip Kumar" <dilipbalaut(at)gmail(dot)com> wrote:
> On Wed, Oct 13, 2021 at 9:12 AM Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>> Anyway, specifying a column name for an ALTER INDEX is not right, no?
>> Just take for example the case of an expression which has a hardcoded
>> column name in pg_attribute. So these are not specific to indexes,
>> which is why we apply column numbers for the statistics case. I think
>> that we'd better just reject those cases until there is a proper
>> design done here. As far as I can see, I guess that we should do
>> things similarly to what we do for SET STATISTICS with column
>> numbers when it comes to indexes.
>
> +1 it should behave similarly to SET STATISTICS for the index and if
> someone tries to set with the column name then it should throw an
> error.

Good point. I agree that rejecting this case is probably the best
option for now. In addition to the bug mentioned in this thread, this
functionality doesn't even work for supported options currently.

postgres=> create table test (a tsvector);
CREATE TABLE
postgres=> create index on test using gist (a);
CREATE INDEX
postgres=> alter index test_a_idx alter column a set (siglen = 100);
ERROR: unrecognized parameter "siglen"

AFAICT the fact that these commands can succeed at all seems to be
unintentional, and I wonder if modifying these options requires extra
steps such as rebuilding the index.

I've attached new patch that just adds an ERROR.

Nathan

Attachment Content-Type Size
disallow_alter_index_column_set.patch application/octet-stream 1.9 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2021-10-13 17:57:05 BUG #17229: Segmentation Fault after upgrading to version 13
Previous Message Tom Lane 2021-10-13 14:28:55 Re: BUG #17227: segmentation fault with jsonb_to_recordset

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2021-10-13 17:26:54 Re: [RFC] building postgres with meson
Previous Message John Naylor 2021-10-13 17:19:36 Re: [RFC] building postgres with meson