[PATCH] fix DROP OPERATOR to reset links to itself on commutator and negator - Mailing list pgsql-hackers

From Roma Sokolov
Subject [PATCH] fix DROP OPERATOR to reset links to itself on commutator and negator
Date
Msg-id A0DF8607-A1A1-40CE-B152-82FC91EF8A3A@gmail.com
Whole thread Raw
Responses Re: [PATCH] fix DROP OPERATOR to reset links to itself on commutator and negator
Re: [PATCH] fix DROP OPERATOR to reset links to itself on commutator and negator
List pgsql-hackers
Hello, hackers!

As was mentioned in that message [1], and earlier in [2], DROPping OPERATOR with
negator or commutator doesn't update respective fields (oprnegate and oprcom) on
them. While this issue is probably not very frequent, this behaviour leaves
database in inconsistent state and prevents from using former negator or
commutator.

Proposed patch fixes unwanted behaviour by reseting oprnegate and oprcom fields
to InvalidOid when deleting operator. Code updates tries to update other
operators only if necessary, and only if negator or commutator have target oid
in their respective fields.

To implement desired behaviour with as little code as possible, OperatorUpd
function is extended to accept additional parameter and made externally visible.
It's used from RemoveOperatorById, after checking that update is indeed needed.

Regression tests are added to check DROP OPERATOR behaves as intended (including
case with self-commutator and unlikely case with operator being both negator and
commutator).

Should this patch be added to CommitFest?

[1] — http://www.postgresql.org/message-id/CA+TgmoYThtZZf6yhnq22SZPw7OTiT68iu9wvvidb2Jz50KdAnQ@mail.gmail.com
[2] — http://www.postgresql.org/message-id/15208.1285772173@sss.pgh.pa.us

Cheers,
Roma


Attachment

pgsql-hackers by date:

Previous
From: Kartyshov Ivan
Date:
Subject: proposal: get oldest LSN - function
Next
From: Robert Haas
Date:
Subject: Re: Performance degradation in commit 6150a1b0