Jeff Davis <pgsql@j-davis.com> writes:
> My point was that, because we can run it in multiple transactions, can't
> we drop the nonexclusive lock before acquiring the exclusive lock,
No. What happens if someone renames the table out from under you, to
mention just one possibility? If you've been holding nonexclusive lock
for a long time (as you would've been) there's a nontrivial chance that
someone is already queued up for an exclusive lock and will get in
before you do.
regards, tom lane