[PATCH] Implement uuid_version()

José Luis Tallón <jltallon@adv-solutions.net>

From: Jose Luis Tallon <jltallon@adv-solutions.net>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2019-04-06T11:57:22Z
Lists: pgsql-hackers

Attachments

Hackers,

     While working on an application, the need arose to be able 
efficiently differentiate v4/v5 UUIDs (for use in partial indexes, among 
others)

... so please find attached a trivial patch which adds the 
functionality. The "uuid_version_bits()" function (from the test suite?) 
seems quite a bit hackish, apart from inefficient :(


     I'm not sure whether this actually would justify a version bump for 
the OSSP-UUID extension ---a misnomer, BTW, since at least in all the 
systems I have access to, the extension is actually linked against 
libuuid from e2fsutils, but I digress --- or not, given that it doesn't 
change exposed functionality.


     Another matter, which I'd like to propose in a later thread, is 
whether it'd be interesting to include the main UUID functionality 
directly in core, with the remaining functions in ossp-uuid (just like 
it is now, for backwards compatibility): Most current patterns for 
distributed/sharded databases are based on using UUIDs for many PKs.


Thanks,

     J.L.


Commits

  1. Add gen_random_uuid function

  2. Add a 64-bit hash function for type hstore.