On 1/24/11 8:29 AM, "Richard Hipp" <d...@sqlite.org> wrote:
> On Mon, Jan 24, 2011 at 11:21 AM, Duquette, William H (318K) < > william.h.duque...@jpl.nasa.gov> wrote: > >> A question on using randomblob(16) to generate UUIDs, as the SQLite docs >> suggest: what assurance do you have that the UUID really is universally >> unique? It's a pseudo-random number, and you can replicate a stream of >> pseudo-random numbers by setting the seed appropriately. Is randomblob() >> doing some kind of magic in its seeding of the random number stream? >> > > The SQLite PRNG is based on RC4 and is quite good. On unix, it is seeded > from /dev/random (where available - which is pretty much everywhere these > days, except on windows). > > So if you do the math, you'll see that the odds of getting duplicate > randomblob(N) (for suitably large N, say 20) are far smaller than a giant > meteor striking earth and ending all life here. So while it is > mathematically possible, we consider it sufficiently unlikely that it can be > disregarded. (Googling /dev/random.) Aha. randomblob() *IS* doing some kind of magic in its seeding of the random number stream. Very cool, I was not aware of /dev/random. > > >> >> Will >> >> >> On 1/24/11 3:49 AM, "Alexey Pechnikov" <pechni...@mobigroup.ru> wrote: >> >> See >> http://sqlite.mobigroup.ru/dir?name=ext/uuid >> >> 2011/1/24 sqlite-us...@h-rd.org <sqlite-us...@h-rd.org> >> >>> Hi, >>> >>> I have put together a simple uuid generation method in sqlite: >>> >>> select '{' || hex( randomblob(4)) || '-' || hex( randomblob(2)) >>> || '-' || '4' || substr( hex( randomblob(2)), 2) || '-' >>> || substr('AB89', 1 + (abs(random()) % 4) , 1) || >>> substr(hex(randomblob(2)), 2) || '-' || hex(randomblob(6)) || >>> '}'; >>> >>> It's based on the description for v.4 uuid's in wikipedia >>> https://secure.wikimedia.org/wikipedia/en/wiki/Uuid . >>> >>> But I am thinking there may be a better (or another) method to do this >>> in sqlite, without the need to use something external? >>> >>> thanks >>> >>> _______________________________________________ >>> sqlite-users mailing list >>> sqlite-users@sqlite.org >>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users >>> >> >> >> >> -- >> Will Duquette -- william.h.duque...@jpl.nasa.gov >> Athena Development Lead -- Jet Propulsion Laboratory >> "It's amazing what you can do with the right tools." >> >> _______________________________________________ >> sqlite-users mailing list >> sqlite-users@sqlite.org >> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users >> > > -- Will Duquette -- william.h.duque...@jpl.nasa.gov Athena Development Lead -- Jet Propulsion Laboratory "It's amazing what you can do with the right tools." _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users