[fpc-devel] I get duplicate GUIDs under Linux
Michael Van Canneyt
michael at freepascal.org
Thu May 29 13:26:19 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.
You can use the kernel mechanism by inluding libuuid in your uses clause.
That should ensure uniqueness.
More information about the fpc-devel