On 7/27/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> "Trevor Talbot" <[EMAIL PROTECTED]> wrote:
> >
> > > > sqlite> select "{" || hex(randomblob(4)) || "-" || hex(randomblob(2))
> > > > || "-" || hex(randomblob(2)) ||  "-" || hex(randomblob(2)) || "-" ||
> > > > hex(randomblob(6)) || "}";
> > > > {4EA4A842-6ACA-0A81-5B42-F9E1D295BC27}
> >
> > Note that this is *NOT* a GUID/UUID.  Be very sure of your
> > requirement: if you need a GUID, write a function that uses your
> > platform tools to get one.  If you just need some long random
> > identifier, the above is fine, but don't call it a GUID.  See RFC
> > 4122.

> Please reread RFC-4122, especially section 4.4.  While Chase's
> guid is technically in violation of RFC-4122 in that it contains
> 4 extra bits of randomness, it is very close.  And in a sense,
> the extra 4 bits of randomness provide a stronger GUID than
> RFC-4122 specifies.

The reason RFC 4122 defines the format that way is to avoid collision
of the randomly generated version with other versions.  Random
generation of GUIDs is weaker than the timestamp-based version, which
is actually guaranteed to be unique rather than merely
probabilistically unique.  (Assuming perfect implementations, that is
-- I'm aware of the related practical problems of MAC number reuse,
clock sequencing storage, etc.)

If you don't pay attention to RFC 4122's defined format, what you're
generating simply isn't a GUID, and you run the risk of bad things
happening if you try to interoperate with a system that deals with
GUIDs.

Hence my warning :)

> I personally find all the syntax in RFC-4122 to be annoying
> and so I usually do my GUIDs using hex(randomblob(20)).  But
> I guess that is just personal preference.

Yeah, if all you need is something that's unique with extremely high
probability, there's not much sense in bothering with syntax designed
for working with other systems.  You already know how to meet your
needs, the rest is just pointless overhead.

> Note that SQLite contains a decent PRNG which is well seeded,
> if you are running on Mac or Linux.  (We need to work on better
> seeding on Win32...)

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to