Subject | Re: Maintaining proper generator values |
---|---|
Author | Svein Erling |
Post date | 2003-11-12T09:36:59Z |
--- In firebird-support@yahoogroups.com, Doug Chamberlin
<yahoogroups@a...> wrote:
SET <GeneratorName> TO <Max+20>
still has a small, theoretical chance of creating problems, whereas
GEN_ID(<GeneratorName>, <Max-PreviousGeneratorValue>)
should always be safe provided PreviousGeneratorValue is less than or
equal to Max (well, up to the maximum value a generator can hold).
Set
<yahoogroups@a...> wrote:
> At 11/11/2003 02:52 PM (Tuesday), Milan Babuskov wrote:Doug, I see that your approach is pretty safe, but
> >One more thing, why max+1 ?
> >Setting it to max is enough.
>
> Actually I just double checked and found that the value in use is
> really max+20.
>
> The reason for this is due to the fact that generator operations are
> outside of transaction control. Therefore, in the sequence of 1)
> determining of max value existing in tables, 2) determining current
> generator value, 3) comparing the two, 4) resetting the generator,
> there could be concurrent operations which are altering those
> values. Therefore, we reset to max plus a comfortable margin which
> hopefully puts the new value past any current activity effects.
SET <GeneratorName> TO <Max+20>
still has a small, theoretical chance of creating problems, whereas
GEN_ID(<GeneratorName>, <Max-PreviousGeneratorValue>)
should always be safe provided PreviousGeneratorValue is less than or
equal to Max (well, up to the maximum value a generator can hold).
Set