[fpc-pascal] GUIDs under FreeBSD don't seem very random

Graeme Geldenhuys mailinglists at geldenhuys.co.uk
Wed Jan 6 00:56:26 CET 2016


I use GUID's as my primary key values in databases. tiOPF uses the
following FPC functions to do this

  CreateGUID(lGUID);
  Result := GUIDToString(lGUID);


I just noticed this difference between two of my databases.

The following GUID's were generated a few minutes ago by FPC (under
FreeBSD) when I imported some data.

43E119C8-B404-11E5-9B6C-C86000E37EB0
4421FB17-B404-11E5-9B6C-C86000E37EB0
445D3112-B404-11E5-9B6C-C86000E37EB0
449D1010-B404-11E5-9B6C-C86000E37EB0
44D8951B-B404-11E5-9B6C-C86000E37EB0
45225928-B404-11E5-9B6C-C86000E37EB0
455D0C9D-B404-11E5-9B6C-C86000E37EB0
45984546-B404-11E5-9B6C-C86000E37EB0

Another database of mine has GUID's as follows (records were created in
2011).

151A5024-B075-4331-B12D-FBD686AC4E19
37379F54-B5A7-4702-9A85-74253E2DC91E
F62EE551-B4F1-4319-855A-EBFAF85BD17F
E5F99902-92FC-46C1-944F-0F284592158B
E4974D41-D5CD-4E0E-B943-F243DC300FF6
FF59C912-DE67-4EEA-BDFE-F7E4DEB41640
DD9B17EA-720F-43E7-814A-E06946024810


Note that the second (older) set of GUID's are much more random.
Unfortunately I don't know what OS platform I used to generate that data
- I think in was under a Linux system.

My initial thought was that FPC 3.0 changed something, but then I
recompiled by application with FPC 2.6.4 (FreeBSD) and imported some
more data. The new GUID's generated appeared like the first set under
both FPC 2.6.4 and 3.0 using FreeBSD.

Remark:
  The first set don't appear to be very random - this is my worry. I'm
  about it import about 1-2 million records using a FreeBSD system. Is
  it something I need to worry about?

Why is the one set of GUID's much more random looking than the others?
I'm assuming FPC uses different algorithms depending on the OS platform.
The FPC help seems to suggest this too.

I just remembered about a *nix console tool "uuidgen" and ran it a
couple of times on my FreeBSD system. The GUID's (or UUID's - not sure
the difference) have the exact same format as the first set of GUID's
above. So I'm assuming FPC is using FreeBSD's UUID generator under
FreeBSD, so that would explain the similarity to the uuidgen tool.


>From Wikipedia (GUID vs UUID)
-----------------------------
The term GUID usually refers to Microsoft's implementation of the
Universally Unique Identifier (UUID) standard.



So am I to assume that I will still get unique values even if I generate
1-2 million records in succession?



Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp


More information about the fpc-pascal mailing list