Joachim Wieland <joe(at)mcknight(dot)de> writes:
> Ok, the attached patch now does it correctly as suggested by Alvaro.
Applied with minor cleanup --- I thought the code for scanning for
dependent relations was unreasonably complicated and created
unpredictable locking order, so I simplified it.
regards, tom lane