]> granicus.if.org Git - postgresql/commit
When using the OSSP UUID library, cache its uuid_t state object.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 29 May 2014 17:51:18 +0000 (13:51 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 29 May 2014 17:51:18 +0000 (13:51 -0400)
commitfd785441ffc11969b658625fe66f162589f07bdb
tree598208056c31d62fd4c5af52c87227e1c12c7edc
parent1b20c639ea89506dfc1ff8cfb5643ec4268da883
When using the OSSP UUID library, cache its uuid_t state object.

The original coding in contrib/uuid-ossp created and destroyed a uuid_t
object (or, in some cases, even two of them) each time it was called.
This is not the intended usage: you're supposed to keep the uuid_t object
around so that the library can cache its state across uses.  (Other UUID
libraries seem to keep equivalent state behind-the-scenes in static
variables, but OSSP chose differently.)  Aside from being quite inefficient,
creating a new uuid_t loses knowledge of the previously generated UUID,
which in theory could result in duplicate V1-style UUIDs being created
on sufficiently fast machines.

On at least some platforms, creating a new uuid_t also draws some entropy
from /dev/urandom, leaving less for the rest of the system.  This seems
sufficiently unpleasant to justify back-patching this change.
contrib/uuid-ossp/uuid-ossp.c