What is a generator?

By: Borland Staff

Abstract: General description of what a generator is
What is a generator?


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.

Published on: 7/24/2000 12:00:00 AM

Server Response from: ETNASC04

Copyright© 1994 - 2013 Embarcadero Technologies, Inc. All rights reserved.