Reject bogus output from uuid_create(3).
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 9 Sep 2022 16:41:36 +0000 (12:41 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 9 Sep 2022 16:41:36 +0000 (12:41 -0400)
commit95028d9de422e395d478da4dcda0a640989156d5
treedcd415a8d49b2f2db6920d4f01fbc4299a7d36e0
parent174c929e3ba03c90cf5386436be05a00ea5ed36a
Reject bogus output from uuid_create(3).

When using the BSD UUID functions, contrib/uuid-ossp expects
uuid_create() to produce a version-1 UUID.  FreeBSD still does so,
but in recent NetBSD releases that function produces a version-4
(random) UUID instead.  That's not acceptable for our purposes:
if the user wanted v4 she would have asked for v4, not v1.
Hence, check the version digit and complain if it's not '1'.

Also drop the documentation's claim that the NetBSD implementation
is usable.  It might be, depending on which OS version you're using,
but we're not going to get into that kind of detail.

(Maybe someday we should ditch all these external libraries
and just write our own UUID code, but today is not that day.)

Nazir Bilal Yavuz, with cosmetic adjustments and docs by me.
Backpatch to all supported versions.

Discussion: https://postgr.es/m/3848059.1661038772@sss.pgh.pa.us
Discussion: https://postgr.es/m/17358-89806e7420797025@postgresql.org
contrib/uuid-ossp/uuid-ossp.c
doc/src/sgml/installation.sgml
doc/src/sgml/uuid-ossp.sgml