Reset pgseq after explicitly setting entry seq#?
The cgi edit page allows a user logged in as an editor to explicitly set a sequence number on a new entry, rather than getting an automatically assigned one. (This was broken but fixed in rev 200127-50db7742.) It also allows changing the seq number when editing an existing entry although it is not clear if this ability is usable (eg IS-143).
However, if a seq number is set to a value greater than the counter for auto assignment (maintained in the Postgresql sequence (let's call it "pgseq" for brevity) "seq_xxxx" where "xxxx" is the name of the corpus the entry is assigned to), the possibility exists that eventually the automatically assigned values will reach the same value as the explicitly set value and the submission will fail with a duplicate key error. It also allows a weak form of DoS were an editor to submit entries with seq numbers chosen to collide with the next auto-generated submission.
- No need to do this if the explicitly assigned seq number is less than the current pgseq value and doing so may be undesirable. For example, if the most recently auto-assigned entry were removed from the database its seq number would be reassigned to the next auto-assigned entry. (Not a problem per se since the original entry is gone but could result in confusion when reading log files.)
- May want to assign a seq number well above the range of auto assigned number to make the entry distinct but not want auto- assigned entries to start using seq numbers in that range.
- Variation on the above is that the explicitly assigned number might be above the pgseq's 'maxvalue' value which would cause an attempt to reset the pgseq to fail.
Another option might be a check box on the submission page to enable/disable resetting of the pgseq.
A third option is to do nothing at submission time (the current status quo) and to run a periodic database check looking for corpora with seq numbers greater than the current corpus pgseq value, and report to a database admin who can make a judgement call.