"Nigel J. Andrews" <nandrews(at)investsystems(dot)co(dot)uk> writes:
> + if (!superuser() && MyBackendId > MaxBackends - ReservedBackends)
> + elog(ERROR, "Normal user limit exceeded");
This coding is wrong on its face: the slot number you happen to find has
no relationship to the number of slots remaining free, except as an
existence proof that the number of slots free was > 0 before you took
one.
regards, tom lane