Hi Tom, On 27/05/2014 03:07, Tom Lane wrote: > I've verified functionality of this patch on these scenarios: > > (1) --with-ossp-uuid on RHEL6, using uuid-1.6.1-10.el6.x86_64 > (2) --with-linux-uuid on RHEL6, using libuuid-2.17.2-12.14.el6_5.x86_64 > (3) --with-linux-uuid on OS X 10.9.3, Intel > (4) --with-linux-uuid on OS X 10.4.11, PPC (hence, bigendian) > > I do not have a machine on which to try --with-bsd-uuid, so it's > possible I broke that portion of Matteo's patch. Would someone try > that case on a FreeBSD box?
I've tested on NetBSD i386 and --with-bsd-uuid worked out of the box. I could fire up some virtual machines with FreeBSD and other BSD flavours, but maybe some buildfarm animals could be used for that. I'm attaching a little patch to be applied on top of yours. I didn't notice that "buf ? 13 : 0" was raising a warning about the condition being always true on BSD. I guess it's safe to hardcode 13 as the argument is ignored anyway with ossp, so I've fixed that. I've also fixed v1mc generation on "linux" to match the OSSP and BSD variants and added a regression test for it. Cheers -- Matteo Beccati Development & Consulting - http://www.beccati.com/
diff --git a/contrib/uuid-ossp/expected/uuid_ossp.out b/contrib/uuid-ossp/expected/uuid_ossp.out index f393e86..c14db22 100644 --- a/contrib/uuid-ossp/expected/uuid_ossp.out +++ b/contrib/uuid-ossp/expected/uuid_ossp.out @@ -77,3 +77,18 @@ SELECT uuid_generate_v4()::text ~ '^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9] t (1 row) +DO $_$ +DECLARE + u text; + i int; + c int; +BEGIN + FOR i in 1..32 LOOP + u := substr(uuid_generate_v1mc()::text, 25, 2); + EXECUTE 'SELECT x''' || u || '''::int & 3' INTO c; + IF c <> 3 THEN + RAISE WARNING 'v1mc broken'; + END IF; + END LOOP; +END; +$_$; diff --git a/contrib/uuid-ossp/sql/uuid_ossp.sql b/contrib/uuid-ossp/sql/uuid_ossp.sql index 8f22417..61a44a8 100644 --- a/contrib/uuid-ossp/sql/uuid_ossp.sql +++ b/contrib/uuid-ossp/sql/uuid_ossp.sql @@ -17,3 +17,20 @@ SELECT uuid_generate_v3(uuid_ns_dns(), 'www.widgets.com'); SELECT uuid_generate_v5(uuid_ns_dns(), 'www.widgets.com'); SELECT uuid_generate_v4()::text ~ '^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$'; + +DO $_$ +DECLARE + u text; + i int; + c int; +BEGIN + FOR i in 1..32 LOOP + u := substr(uuid_generate_v1mc()::text, 25, 2); + EXECUTE 'SELECT x''' || u || '''::int & 3' INTO c; + IF c <> 3 THEN + RAISE WARNING 'v1mc broken'; + END IF; + END LOOP; +END; +$_$; + diff --git a/contrib/uuid-ossp/uuid-ossp.c b/contrib/uuid-ossp/uuid-ossp.c index bc29ade..7803dbe 100644 --- a/contrib/uuid-ossp/uuid-ossp.c +++ b/contrib/uuid-ossp/uuid-ossp.c @@ -460,6 +460,10 @@ uuid_generate_v1mc(PG_FUNCTION_ARGS) uuid_t uu; uuid_generate_random(uu); + + /* set IEEE802 multicast and local-admin bits */ + ((dce_uuid_t *)&uu)->node[0] |= 0x03; + uuid_unparse(uu, strbuf); buf = strbuf + 24; #else /* BSD */ @@ -472,7 +476,7 @@ uuid_generate_v1mc(PG_FUNCTION_ARGS) #endif return uuid_generate_internal(UUID_MAKE_V1 | UUID_MAKE_MC, NULL, - buf, buf ? 13 : 0); + buf, 13); }
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers