[PATCH] Extend ALTER OPERATOR to support adding commutator, negator, hashes, and merges - Mailing list pgsql-hackers

From Tommy Pavlicek
Subject [PATCH] Extend ALTER OPERATOR to support adding commutator, negator, hashes, and merges
Date
Msg-id CAEhP-W-vGVzf4udhR5M8Bdv88UYnPrhoSkj3ieR3QNrsGQoqdg@mail.gmail.com
Whole thread Raw
Responses Re: [PATCH] Extend ALTER OPERATOR to support adding commutator, negator, hashes, and merges
List pgsql-hackers
Hi All,

I've attached a couple of patches to allow ALTER OPERATOR to add commutators, negators, hashes and merges to operators that lack them.

The need for this arose adding hash functions to the ltree type after the operator had been created without hash support[1]. There are potential issues with modifying these attributes that have been discussed previously[2], but I understand that setting them, if they have not been set before, is ok.

I belatedly realised that it may not be desirable or necessary to allow adding commutators and negators in ALTER OPERATOR because the linkage can already be added when creating a new operator. I don't know what's best, so I thought I'd post this here and get feedback before removing anything.

The first patch is create_op_fixes_v1.patch and it includes some refactoring in preparation for the ALTER OPERATOR changes and fixes a couple of minor bugs in CREATE OPERATOR:
- prevents self negation when filling in/creating an existing shell operator
- remove reference to sort operator in the self negation error message as the sort attribute appears to be deprecated in Postgres 8.3

The second patch is alter_op_v1.patch which contains the changes to ALTER OPERATOR and depends on create_op_fixes_v1.patch.

Additionally, I wasn't sure whether it was preferred to fail or succeed on ALTERs that have no effect, such as adding hashes on an operator that already allows them or disabling hashes on one that does not. I chose to raise an error when this happens, on the thinking it was more explicit and made the code simpler, even though the end result would be what the user wanted.

Comments appreciated.

Thanks,
Tommy

[1] https://www.postgresql.org/message-id/flat/CAEhP-W9ZEoHeaP_nKnPCVd_o1c3BAUvq1gWHrq8EbkNRiS9CvQ%40mail.gmail.com
[2] https://www.postgresql.org/message-id/flat/3348985.V7xMLFDaJO@dinodell
Attachment

pgsql-hackers by date:

Previous
From: "Imseih (AWS), Sami"
Date:
Subject: Re: New function to show index being vacuumed
Next
From: Andres Freund
Date:
Subject: Re: Assert while autovacuum was executing