Dangling operator family after DROP TYPE

Yoran Heling <contact@yorhel.nl>

From: Yoran Heling <contact@yorhel.nl>
To: pgsql-bugs@lists.postgresql.org
Date: 2024-12-06T15:15:20Z
Lists: pgsql-bugs

Attachments

Hello list,

pg_upgrade was failing on one of my databases and, while digging a bit,
I found that the database in question contained a dangling operator
family for a type that didn't exist anymore.

I've attached a script to recreate this situation: creating a new type,
defining an operator class for it and then dropping the type causes the
implicitly created operator family to remain.

Attempting to drop this operator family results in an error. Attempting
to do a dump/restore results in a syntax error on restore.

The problematic database I found this on was running 15.10, but with the
attached script I can also reproduce it on 17.2.

Happy to provide more information as needed,

Yoran.

Commits

  1. Ensure that pg_amop/amproc entries depend on their lefttype/righttype.

  2. Make getObjectDescription robust against dangling amproc type links.