Add gen_random_uuid function

Enterprise / PostgreSQL - Peter Eisentraut [eisentraut.org] - 14 July 2019 12:30 EDT

This adds a built-in function to generate UUIDs.

PostgreSQL hasn't had a built-in function to generate a UUID yet, relying on external modules such as uuid-ossp and pgcrypto to provide one. Now that we have a strong random number generator built-in, we can easily provide a version 4 (random) UUID generation function.

This patch takes the existing function gen_random_uuid() from pgcrypto and makes it a built-in function. The pgcrypto implementation now internally redirects to the built-in one.

5925e55498 Add gen_random_uuid function
contrib/pgcrypto/pgcrypto.c | 16 ++--------------
doc/src/sgml/datatype.sgml | 12 ++----------
doc/src/sgml/func.sgml | 26 ++++++++++++++++++++++++++
doc/src/sgml/pgcrypto.sgml | 3 ++-
doc/src/sgml/uuid-ossp.sgml | 11 +++--------
src/backend/utils/adt/uuid.c | 20 ++++++++++++++++++++
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_proc.dat | 3 +++
src/test/regress/expected/opr_sanity.out | 1 +
src/test/regress/expected/uuid.out | 10 ++++++++++
src/test/regress/sql/uuid.sql | 6 ++++++
11 files changed, 76 insertions(+), 34 deletions(-)

Upstream: git.postgresql.org


  • Share