Hi, I just tested that same code under Windows 2000 and I don't have any errors or duplicates. As I would have expected. So there seems to be a bug in the CreateGUID implementation of Linux.
BTW: I'm using Ubuntu 7.10. My 'uname -a' output: Linux graemeg 2.6.22-14-generic #1 SMP Tue Feb 12 07:42:25 UTC 2008 i686 GNU/Linux Regards, - Graeme - On 29/05/2008, Graeme Geldenhuys <[EMAIL PROTECTED]> wrote: > Hi, > > 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! :-( > > Actual program output: > > [EMAIL PROTECTED]:index_performance$ ./index_performance.elf > Duplicate value detected: {FD3DF19D-A878-F8BA-F9D1-108658451E05} > List.Count = 1021 > > GUID's are supposed to be very unique! Wikipedia says something like: > Create a billion every second for 10 years or something before you > deplete the range. > So what is wrong with my code or maybe the Free Pascal implementation? > > --------------------[ code ]------------------------------ > procedure TMainForm.btnTestClicked(Sender: TObject); > var > sl: TStringList; > s: string; > i: integer; > d: integer; > guid: TGUID; > begin > sl := TStringList.Create; > try > try > sl.Sorted := True; > sl.Duplicates := dupError; > for i := 1 to 50000 do > begin > CreateGUID(guid); > s := GUIDToString(guid); > sl.Add(s); > end; > writeln('Created 50,000 GUIDs'); > except > on e: EStringListError do > begin > writeln('Duplicate value detected: ' + s); > writeln(' List.Count = ', sl.Count); > end; > on e: Exception do > writeln('Unknown error: ', e.Message); > end; > finally > sl.Free; > end; > end; > --------------------[ end ]-------------------------------- > > > Changing the line that adds the GUID to the StringList by prefixing > the counter, all is fine. So I can't see a problem in my code. > > sl.Add(IntToStr(i) + s); > > > Regards, > - Graeme - > > > _______________________________________________ > fpGUI - a cross-platform Free Pascal GUI toolkit > http://opensoft.homeip.net/fpgui/ > -- Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/ _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel