What is a generator?

By: Borland Staff

Abstract: General description of what a generator is

Problem:
What is a generator?

Solution:

The use of GENERATORS is documented in the InterBase Programmer's
Guide and Data Definition Guide with respect to their use as 
populating keys with unique values.
		
Generators were added to InterBase when we realized that 
customers where creating unique identifiers by storing a 
single record that held the current (or next) identifier, 
which was read and modified before storing the new record.  
The problem, of course, is that the record becomes a serious 
source of contention, deadlocks and rollbacks.  Generators 
were built outside of transasction control, using the same 
strategy that keeps the on-disk structure consistent.
		
Because the system relations are kept under transaction control, 
the generator value can't be stored there.  The only way to get
the next generator value is (or at least was) though the 
generator function, and that, of course, changes the value.
		
This doesn't mean that the new value is under transaction 
control but that the new value should be used within the  
context of that transaction.  It should be left as undefined 
behavior if that new value is used outside the context of the 
transaction that generated it.

Server Response from: ETNASC03