Gary Stainburn <gary(dot)stainburn(at)ringways(dot)co(dot)uk> writes:
> That did the trick. However, I now have another problem with the constraint
> complaining about there not being an index to refer to. However, there is.
No there isn't:
> jrank int4 not null references ranks(rrank), -- needs sorting
^^^^^^^^^^^^^^^^^^^^^^^
You have no index constraining rrank (by itself) to be unique.
regards, tom lane