[fpc-devel] I get duplicate GUIDs under Linux

Marco van de Voort marcov at stack.nl
Thu May 29 13:25:06 CEST 2008


> On Thu, 29 May 2008, Graeme Geldenhuys wrote:
> > I'm trying to do performance testing in Firebird RDBMS using GUID's
> > and primary keys. I constantly got PK violations. I then wrote the
> > code show below to create 50,000 GUID's and add them to a StringList
> > (no duplicates allowed). Every time I run this I get a duplicate GUID
> > at iteration 1021.  My original test is supposed to create 5mil
> > records, but I can't get past 1000! :-(
> 
> As a short workaround:
> 
> The default implementation on Linux uses a random() call to generate a
> guid, combined with a timestamp, if I recall correctly. 

rtl/linux/suuid.inc reads from '/proc/sys/kernel/random/uuid' Maybe it is
not used though.

> You can use the kernel mechanism by inluding libuuid in your uses clause. 
> That should ensure uniqueness.

It's unportable though. It is wiser to try to find out why the default (and
portable call) doesn't work on Linux, using a system generator.



More information about the fpc-devel mailing list