On Sunday, June 14, 2020, Tom Lane <
tgl@sss.pgh.pa.us> wrote:
What I'd prefer to see, I think, is a command DROP RELATION [IF EXISTS]
that is entirely un-picky about the object's relkind. Once upon a time
DROP TABLE worked that way, IIRC, but it was "improved" with little
thought about the needs of schema-update scripts
IMO if the DROP type IF EXISTS worked as expected the drop relation command would be undesirable - the use case being that there is a specific type of object the user was potentially expecting to exist that they want to ensure does not. If an object of a different typed gets matched for some reason it should not get dropped as a safety feature.
Unless drop relation is part of the SQL standard I’d suggest it is something to not implement on “don’t give users a loaded weapon” grounds. People aren’t clamoring for it and making the drop type if exists work in the proposed manner makes it possible to, if a bit verbosely, replicate the same behavior in the rare case it would be needed. The same rarity that is being used to defend not changing the behavior.
David J.