"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Sat, Jul 12, 2025 at 11:31 AM Marcos Pegoraro <marcos@f10.com.br> wrote:
>> I don't know how to fix it, but I think it's a bug.
> You told it to cascade and it will happily remove anything within the
> database to comply. It is not a bug. The docs even make that point
> explicitly:
Indeed. If we put a restriction on this case then we'd just need to
invent a "REALLY CASCADE" option that did the more aggressive thing.
In any case, AFAICS the SQL spec says what CASCADE means, and this
is what it means. There's no intermediate step between RESTRICT
(don't drop any dependent objects) and CASCADE (drop every directly
or indirectly dependent object).
I grant that there could sometimes be a use for intermediate levels of
aggressiveness, but it's hard to see exactly where to draw the line
that wouldn't be extremely application-specific.
regards, tom lane