From 74496bc298e099401a8b41c1c529bf9fb7aa9f3c Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Sat, 21 Apr 2007 17:26:18 +0000
Subject: [PATCH] Contrib module uuid-ossp for generating UUID values using the
 OSSP UUID library.  New configure option --with-ossp-uuid to activate.

---
 configure                                 |  37 +++-
 configure.in                              |   9 +-
 contrib/Makefile                          |   6 +-
 contrib/README                            |   4 +
 contrib/uuid-ossp/Makefile                |  19 +++
 contrib/uuid-ossp/README.uuid-ossp        |  97 +++++++++++
 contrib/uuid-ossp/uninstall_uuid-ossp.sql |  15 ++
 contrib/uuid-ossp/uuid-ossp.c             | 198 ++++++++++++++++++++++
 contrib/uuid-ossp/uuid-ossp.sql.in        |  15 ++
 doc/src/sgml/datatype.sgml                |   9 +-
 doc/src/sgml/installation.sgml            |  15 +-
 src/Makefile.global.in                    |   3 +-
 12 files changed, 421 insertions(+), 6 deletions(-)
 create mode 100644 contrib/uuid-ossp/Makefile
 create mode 100644 contrib/uuid-ossp/README.uuid-ossp
 create mode 100644 contrib/uuid-ossp/uninstall_uuid-ossp.sql
 create mode 100644 contrib/uuid-ossp/uuid-ossp.c
 create mode 100644 contrib/uuid-ossp/uuid-ossp.sql.in

diff --git a/configure b/configure
index 3af7d001dfc..bb47cc32ee6 100755
--- a/configure
+++ b/configure
@@ -314,7 +314,7 @@ ac_includes_default="\
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS configure_args build build_cpu build_vendor build_os host host_cpu host_vendor host_os PORTNAME docdir enable_nls WANTED_LANGUAGES default_port enable_shared enable_rpath enable_debug enable_profiling DTRACE DTRACEFLAGS enable_dtrace CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP GCC TAS autodepend INCLUDES enable_thread_safety with_tcl with_perl with_python with_krb5 krb_srvtab with_pam with_ldap with_bonjour with_openssl XML2_CONFIG with_libxml with_libxslt with_zlib EGREP ELF_SYS LDFLAGS_SL AWK FLEX FLEXFLAGS LN_S LD with_gnu_ld ld_R_works RANLIB ac_ct_RANLIB TAR STRIP ac_ct_STRIP STRIP_STATIC_LIB STRIP_SHARED_LIB YACC YFLAGS PERL perl_archlibexp perl_privlibexp perl_useshrplib perl_embed_ldflags PYTHON python_version python_configdir python_includespec python_libdir python_libspec python_additional_libs HAVE_IPV6 LIBOBJS acx_pthread_config PTHREAD_CC PTHREAD_LIBS PTHREAD_CFLAGS LDAP_LIBS_FE LDAP_LIBS_BE HAVE_POSIX_SIGNALS MSGFMT MSGMERGE XGETTEXT localedir TCLSH TCL_CONFIG_SH TCL_INCLUDE_SPEC TCL_LIB_FILE TCL_LIBS TCL_LIB_SPEC TCL_SHARED_BUILD TCL_SHLIB_LD_LIBS NSGMLS JADE have_docbook DOCBOOKSTYLE COLLATEINDEX SGMLSPL vpath_build LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS configure_args build build_cpu build_vendor build_os host host_cpu host_vendor host_os PORTNAME docdir enable_nls WANTED_LANGUAGES default_port enable_shared enable_rpath enable_debug enable_profiling DTRACE DTRACEFLAGS enable_dtrace CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP GCC TAS autodepend INCLUDES enable_thread_safety with_tcl with_perl with_python with_krb5 krb_srvtab with_pam with_ldap with_bonjour with_openssl with_ossp_uuid XML2_CONFIG with_libxml with_libxslt with_zlib EGREP ELF_SYS LDFLAGS_SL AWK FLEX FLEXFLAGS LN_S LD with_gnu_ld ld_R_works RANLIB ac_ct_RANLIB TAR STRIP ac_ct_STRIP STRIP_STATIC_LIB STRIP_SHARED_LIB YACC YFLAGS PERL perl_archlibexp perl_privlibexp perl_useshrplib perl_embed_ldflags PYTHON python_version python_configdir python_includespec python_libdir python_libspec python_additional_libs HAVE_IPV6 LIBOBJS acx_pthread_config PTHREAD_CC PTHREAD_LIBS PTHREAD_CFLAGS LDAP_LIBS_FE LDAP_LIBS_BE HAVE_POSIX_SIGNALS MSGFMT MSGMERGE XGETTEXT localedir TCLSH TCL_CONFIG_SH TCL_INCLUDE_SPEC TCL_LIB_FILE TCL_LIBS TCL_LIB_SPEC TCL_SHARED_BUILD TCL_SHLIB_LD_LIBS NSGMLS JADE have_docbook DOCBOOKSTYLE COLLATEINDEX SGMLSPL vpath_build LTLIBOBJS'
 ac_subst_files=''
 
 # Initialize some variables set by options.
@@ -895,6 +895,7 @@ Optional Packages:
   --with-openssl          build with OpenSSL support
   --without-readline      do not use GNU Readline nor BSD Libedit for editing
   --with-libedit-preferred  prefer BSD Libedit over GNU Readline
+  --with-ossp-uuid        build with OSSP UUID library for UUID generation
   --with-libxml           build with XML support
   --with-libxslt           build with XSLT support
   --without-zlib          do not use Zlib
@@ -4241,6 +4242,39 @@ fi;
 
 
 
+#
+# OSSP UUID library
+#
+
+pgac_args="$pgac_args with_ossp_uuid"
+
+
+# Check whether --with-ossp-uuid or --without-ossp-uuid was given.
+if test "${with_ossp_uuid+set}" = set; then
+  withval="$with_ossp_uuid"
+
+  case $withval in
+    yes)
+      :
+      ;;
+    no)
+      :
+      ;;
+    *)
+      { { echo "$as_me:$LINENO: error: no argument expected for --with-ossp-uuid option" >&5
+echo "$as_me: error: no argument expected for --with-ossp-uuid option" >&2;}
+   { (exit 1); exit 1; }; }
+      ;;
+  esac
+
+else
+  with_ossp_uuid=no
+
+fi;
+
+
+
+
 #
 # XML
 #
@@ -24589,6 +24623,7 @@ s,@with_pam@,$with_pam,;t t
 s,@with_ldap@,$with_ldap,;t t
 s,@with_bonjour@,$with_bonjour,;t t
 s,@with_openssl@,$with_openssl,;t t
+s,@with_ossp_uuid@,$with_ossp_uuid,;t t
 s,@XML2_CONFIG@,$XML2_CONFIG,;t t
 s,@with_libxml@,$with_libxml,;t t
 s,@with_libxslt@,$with_libxslt,;t t
diff --git a/configure.in b/configure.in
index 43cf008ed8b..557f74f4bd6 100644
--- a/configure.in
+++ b/configure.in
@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
-dnl $PostgreSQL: pgsql/configure.in,v 1.511 2007/04/15 12:48:23 adunstan Exp $
+dnl $PostgreSQL: pgsql/configure.in,v 1.512 2007/04/21 17:26:17 petere Exp $
 dnl
 dnl Developers, please strive to achieve this order:
 dnl
@@ -555,6 +555,13 @@ PGAC_ARG_BOOL(with, libedit-preferred, no,
               [  --with-libedit-preferred  prefer BSD Libedit over GNU Readline])
 
 
+#
+# OSSP UUID library
+#
+PGAC_ARG_BOOL(with, ossp-uuid, no, [  --with-ossp-uuid        build with OSSP UUID library for UUID generation])
+AC_SUBST(with_ossp_uuid)
+
+
 #
 # XML
 #
diff --git a/contrib/Makefile b/contrib/Makefile
index 411bbec26cd..9b2bdc54485 100644
--- a/contrib/Makefile
+++ b/contrib/Makefile
@@ -1,4 +1,4 @@
-# $PostgreSQL: pgsql/contrib/Makefile,v 1.74 2007/04/15 12:48:23 adunstan Exp $
+# $PostgreSQL: pgsql/contrib/Makefile,v 1.75 2007/04/21 17:26:17 petere Exp $
 
 subdir = contrib
 top_builddir = ..
@@ -37,6 +37,10 @@ ifeq ($(with_openssl),yes)
 WANTED_DIRS += sslinfo
 endif
 
+ifeq ($(with_ossp_uuid),yes)
+WANTED_DIRS += uuid-ossp
+endif
+
 ifeq ($(with_libxml),yes)
 ifeq ($(with_libxslt),yes)
 WANTED_DIRS += xml2
diff --git a/contrib/README b/contrib/README
index d6067d44dce..7c5034d48cf 100644
--- a/contrib/README
+++ b/contrib/README
@@ -133,6 +133,10 @@ tsearch2 -
 	by Teodor Sigaev <teodor@sigaev.ru> and Oleg Bartunov
 	<oleg@sai.msu.su>.
 
+uuid-ossp -
+	UUID generation functions
+	by Peter Eisentraut <peter_e@gmx.net>
+
 vacuumlo -
 	Remove orphaned large objects
 	by Peter T Mount <peter@retep.org.uk>
diff --git a/contrib/uuid-ossp/Makefile b/contrib/uuid-ossp/Makefile
new file mode 100644
index 00000000000..76727a57985
--- /dev/null
+++ b/contrib/uuid-ossp/Makefile
@@ -0,0 +1,19 @@
+# $PostgreSQL: pgsql/contrib/uuid-ossp/Makefile,v 1.1 2007/04/21 17:26:17 petere Exp $
+
+MODULE_big = uuid-ossp
+OBJS = uuid-ossp.o
+DATA_built = uuid-ossp.sql
+DATA = uninstall_uuid-ossp.sql
+DOCS = README.uuid-ossp
+
+SHLIB_LINK += -lossp-uuid
+
+ifdef USE_PGXS
+PGXS := $(shell pg_config --pgxs)
+include $(PGXS)
+else
+subdir = contrib/uuid-ossp
+top_builddir = ../..
+include $(top_builddir)/src/Makefile.global
+include $(top_srcdir)/contrib/contrib-global.mk
+endif
diff --git a/contrib/uuid-ossp/README.uuid-ossp b/contrib/uuid-ossp/README.uuid-ossp
new file mode 100644
index 00000000000..53a3b729459
--- /dev/null
+++ b/contrib/uuid-ossp/README.uuid-ossp
@@ -0,0 +1,97 @@
+UUID Generation Functions
+=========================
+Peter Eisentraut <peter_e@gmx.net>
+
+This module provides functions to generate universally unique
+identifiers (UUIDs) using one of the several standard algorithms, as
+well as functions to produce certain special UUID constants.
+
+
+Installation
+------------
+
+The extra library required can be found at
+<http://www.ossp.org/pkg/lib/uuid/>.
+
+
+UUID Generation
+---------------
+
+The relevant standards ITU-T Rec. X.667, ISO/IEC 9834-8:2005, and RFC
+4122 specify four algorithms for generating UUIDs, identified by the
+version numbers 1, 3, 4, and 5.  (There is no version 2 algorithm.)
+Each of these algorithms could be suitable for a different set of
+applications.
+
+uuid_generate_v1()
+~~~~~~~~~~~~~~~~~~
+
+This function generates a version 1 UUID.  This involves the MAC
+address of the computer and a time stamp.  Note that UUIDs of this
+kind reveal the identity of the computer that created the identifier
+and the time at which it did so, which might make it unsuitable for
+certain security-sensitive applications.
+
+uuid_generate_v1mc()
+~~~~~~~~~~~~~~~~~~~~
+
+This function generates a version 1 UUID but uses a random multicast
+MAC address instead of the real MAC address of the computer.
+
+uuid_generate_v3(namespace uuid, name text)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This function generates a version 3 UUID in the given namespace using
+the specified input name.  The namespace should be one of the special
+constants produced by the uuid_ns_*() functions shown below.  (It
+should be any UUID in theory.)  The name is an identifier in the
+selected namespace.  For example:
+
+  uuid_generate_v3(uuid_ns_url(), 'http://www.postgresql.org')
+
+The name parameter will be MD5-hashed, so the cleartext cannot be
+derived from the generated UUID.
+
+The generation of UUIDs by this method has no random or
+environment-dependent element and is therefore reproducible.
+
+uuid_generate_v4()
+~~~~~~~~~~~~~~~~~~
+
+This function generates a version 4 UUID, which is derived entirely
+from random numbers.
+
+uuid_generate_v5(namespace uuid, name text)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This function generates a version 5 UUID, which works like a version 3
+UUID except that SHA-1 is used as a hashing method.  Version 5 should
+be preferred over version 3 because SHA-1 is thought to be more secure
+than MD5.
+
+
+UUID Constants
+--------------
+
+  uuid_nil()
+
+A "nil" UUID constant, which does not occur as a real UUID.
+
+  uuid_ns_dns()
+
+Constant designating the DNS namespace for UUIDs.
+
+  uuid_ns_url()
+
+Constant designating the URL namespace for UUIDs.
+
+  uuid_ns_oid()
+
+Constant designating the ISO object identifier (OID) namespace for
+UUIDs.  (This pertains to ASN.1 OIDs, unrelated to the OIDs used in
+PostgreSQL.)
+
+  uuid_ns_x500()
+
+Constant designating the X.500 distinguished name (DN) namespace for
+UUIDs.
diff --git a/contrib/uuid-ossp/uninstall_uuid-ossp.sql b/contrib/uuid-ossp/uninstall_uuid-ossp.sql
new file mode 100644
index 00000000000..30226e98c5d
--- /dev/null
+++ b/contrib/uuid-ossp/uninstall_uuid-ossp.sql
@@ -0,0 +1,15 @@
+/* $PostgreSQL: pgsql/contrib/uuid-ossp/uninstall_uuid-ossp.sql,v 1.1 2007/04/21 17:26:17 petere Exp $ */
+
+SET search_path = public;
+
+DROP FUNCTION uuid_nil();
+DROP FUNCTION uuid_ns_dns();
+DROP FUNCTION uuid_ns_url();
+DROP FUNCTION uuid_ns_oid();
+DROP FUNCTION uuid_ns_x500();
+
+DROP FUNCTION uuid_generate_v1();
+DROP FUNCTION uuid_generate_v1mc();
+DROP FUNCTION uuid_generate_v3(namespace uuid, name text);
+DROP FUNCTION uuid_generate_v4();
+DROP FUNCTION uuid_generate_v5(namespace uuid, name text);
diff --git a/contrib/uuid-ossp/uuid-ossp.c b/contrib/uuid-ossp/uuid-ossp.c
new file mode 100644
index 00000000000..3be2cd1908d
--- /dev/null
+++ b/contrib/uuid-ossp/uuid-ossp.c
@@ -0,0 +1,198 @@
+/*-------------------------------------------------------------------------
+ *
+ * UUID generation functions using the OSSP UUID library
+ *
+ * Copyright (c) 2007 PostgreSQL Global Development Group
+ *
+ * $PostgreSQL: pgsql/contrib/uuid-ossp/uuid-ossp.c,v 1.1 2007/04/21 17:26:17 petere Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+
+#include "postgres.h"
+#include "fmgr.h"
+#include "utils/builtins.h"
+#include "utils/uuid.h"
+
+#include <ossp/uuid.h>
+
+
+/* better both be 16 */
+#if (UUID_LEN != UUID_LEN_BIN)
+#error UUID length mismatch
+#endif
+
+
+PG_MODULE_MAGIC;
+
+
+Datum uuid_nil(PG_FUNCTION_ARGS);
+Datum uuid_ns_dns(PG_FUNCTION_ARGS);
+Datum uuid_ns_url(PG_FUNCTION_ARGS);
+Datum uuid_ns_oid(PG_FUNCTION_ARGS);
+Datum uuid_ns_x500(PG_FUNCTION_ARGS);
+
+Datum uuid_generate_v1(PG_FUNCTION_ARGS);
+Datum uuid_generate_v1mc(PG_FUNCTION_ARGS);
+Datum uuid_generate_v3(PG_FUNCTION_ARGS);
+Datum uuid_generate_v4(PG_FUNCTION_ARGS);
+Datum uuid_generate_v5(PG_FUNCTION_ARGS);
+
+
+PG_FUNCTION_INFO_V1(uuid_nil);
+PG_FUNCTION_INFO_V1(uuid_ns_dns);
+PG_FUNCTION_INFO_V1(uuid_ns_url);
+PG_FUNCTION_INFO_V1(uuid_ns_oid);
+PG_FUNCTION_INFO_V1(uuid_ns_x500);
+
+PG_FUNCTION_INFO_V1(uuid_generate_v1);
+PG_FUNCTION_INFO_V1(uuid_generate_v1mc);
+PG_FUNCTION_INFO_V1(uuid_generate_v3);
+PG_FUNCTION_INFO_V1(uuid_generate_v4);
+PG_FUNCTION_INFO_V1(uuid_generate_v5);
+
+
+static char *
+uuid_to_string(const uuid_t *uuid)
+{
+	char   *buf = palloc(UUID_LEN_STR + 1);
+	void   *ptr = buf;
+	size_t	len = UUID_LEN_STR + 1;
+
+	uuid_export(uuid, UUID_FMT_STR, &ptr, &len);
+
+	return buf;
+}
+
+
+static void
+string_to_uuid(const char *str, uuid_t *uuid)
+{
+	uuid_import(uuid, UUID_FMT_STR, str, UUID_LEN_STR + 1);
+}
+
+
+static Datum
+special_uuid_value(const char *name)
+{
+	uuid_t *uuid;
+	char   *str;
+
+	uuid_create(&uuid);
+	uuid_load(uuid, name);
+	str = uuid_to_string(uuid);
+	uuid_destroy(uuid);
+
+	return DirectFunctionCall1(uuid_in, CStringGetDatum(str));
+}
+
+
+Datum
+uuid_nil(PG_FUNCTION_ARGS)
+{
+	return special_uuid_value("nil");
+}
+
+
+Datum
+uuid_ns_dns(PG_FUNCTION_ARGS)
+{
+	return special_uuid_value("ns:DNS");
+}
+
+
+Datum
+uuid_ns_url(PG_FUNCTION_ARGS)
+{
+	return special_uuid_value("ns:URL");
+}
+
+
+Datum
+uuid_ns_oid(PG_FUNCTION_ARGS)
+{
+	return special_uuid_value("ns:OID");
+}
+
+
+Datum
+uuid_ns_x500(PG_FUNCTION_ARGS)
+{
+	return special_uuid_value("ns:X500");
+}
+
+
+static Datum
+uuid_generate_internal(int mode, const uuid_t *ns, const char *name)
+{
+	uuid_t *uuid;
+	char   *str;
+
+	uuid_create(&uuid);
+	uuid_make(uuid, mode, ns, name);
+	str = uuid_to_string(uuid);
+	uuid_destroy(uuid);
+
+	return DirectFunctionCall1(uuid_in, CStringGetDatum(str));
+}
+
+
+Datum
+uuid_generate_v1(PG_FUNCTION_ARGS)
+{
+	return uuid_generate_internal(UUID_MAKE_V1, NULL, NULL);
+}
+
+
+Datum
+uuid_generate_v1mc(PG_FUNCTION_ARGS)
+{
+	return uuid_generate_internal(UUID_MAKE_V1 | UUID_MAKE_MC, NULL, NULL);
+}
+
+
+static Datum
+uuid_generate_v35_internal(int mode, pg_uuid_t *ns, text *name)
+{
+	uuid_t	   *ns_uuid;
+	Datum		result;
+
+	uuid_create(&ns_uuid);
+	string_to_uuid(DatumGetCString(DirectFunctionCall1(uuid_out, UUIDPGetDatum(ns))),
+				   ns_uuid);
+
+	result = uuid_generate_internal(mode,
+									ns_uuid,
+									DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(name))));
+
+	uuid_destroy(ns_uuid);
+
+	return result;
+}
+
+
+Datum
+uuid_generate_v3(PG_FUNCTION_ARGS)
+{
+	pg_uuid_t  *ns = PG_GETARG_UUID_P(0);
+	text	   *name = PG_GETARG_TEXT_P(1);
+
+	return uuid_generate_v35_internal(UUID_MAKE_V3, ns, name);
+}
+
+
+Datum
+uuid_generate_v4(PG_FUNCTION_ARGS)
+{
+	return uuid_generate_internal(UUID_MAKE_V4, NULL, NULL);
+}
+
+
+Datum
+uuid_generate_v5(PG_FUNCTION_ARGS)
+{
+	pg_uuid_t  *ns = PG_GETARG_UUID_P(0);
+	text	   *name = PG_GETARG_TEXT_P(1);
+
+	return uuid_generate_v35_internal(UUID_MAKE_V5, ns, name);
+}
diff --git a/contrib/uuid-ossp/uuid-ossp.sql.in b/contrib/uuid-ossp/uuid-ossp.sql.in
new file mode 100644
index 00000000000..5b0599d4ad7
--- /dev/null
+++ b/contrib/uuid-ossp/uuid-ossp.sql.in
@@ -0,0 +1,15 @@
+/* $PostgreSQL: pgsql/contrib/uuid-ossp/uuid-ossp.sql.in,v 1.1 2007/04/21 17:26:17 petere Exp $ */
+
+SET search_path = public;
+
+CREATE FUNCTION uuid_nil()     RETURNS uuid IMMUTABLE STRICT LANGUAGE C AS 'MODULE_PATHNAME', 'uuid_nil';
+CREATE FUNCTION uuid_ns_dns()  RETURNS uuid IMMUTABLE STRICT LANGUAGE C AS 'MODULE_PATHNAME', 'uuid_ns_dns';
+CREATE FUNCTION uuid_ns_url()  RETURNS uuid IMMUTABLE STRICT LANGUAGE C AS 'MODULE_PATHNAME', 'uuid_ns_url';
+CREATE FUNCTION uuid_ns_oid()  RETURNS uuid IMMUTABLE STRICT LANGUAGE C AS 'MODULE_PATHNAME', 'uuid_ns_oid';
+CREATE FUNCTION uuid_ns_x500() RETURNS uuid IMMUTABLE STRICT LANGUAGE C AS 'MODULE_PATHNAME', 'uuid_ns_x500';
+
+CREATE FUNCTION uuid_generate_v1()   RETURNS uuid IMMUTABLE STRICT LANGUAGE C AS 'MODULE_PATHNAME', 'uuid_generate_v1';
+CREATE FUNCTION uuid_generate_v1mc() RETURNS uuid IMMUTABLE STRICT LANGUAGE C AS 'MODULE_PATHNAME', 'uuid_generate_v1mc';
+CREATE FUNCTION uuid_generate_v3(namespace uuid, name text) RETURNS uuid IMMUTABLE STRICT LANGUAGE C AS 'MODULE_PATHNAME', 'uuid_generate_v3';
+CREATE FUNCTION uuid_generate_v4()   RETURNS uuid IMMUTABLE STRICT LANGUAGE C AS 'MODULE_PATHNAME', 'uuid_generate_v4';
+CREATE FUNCTION uuid_generate_v5(namespace uuid, name text) RETURNS uuid IMMUTABLE STRICT LANGUAGE C AS 'MODULE_PATHNAME', 'uuid_generate_v5';
diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml
index cda0f50d94b..2ffe0745869 100644
--- a/doc/src/sgml/datatype.sgml
+++ b/doc/src/sgml/datatype.sgml
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.197 2007/04/20 21:51:46 petere Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.198 2007/04/21 17:26:17 petere Exp $ -->
 
  <chapter id="datatype">
   <title id="datatype-title">Data Types</title>
@@ -3246,6 +3246,13 @@ a0eebc999c0b4ef8bb6d6bb9bd380a11
 </programlisting>
     Output is always in the standard form.
    </para>
+
+   <para>
+    To generate UUIDs, the contrib module <literal>uuid-ossp</literal>
+    provides functions that implement the standard algorithms.
+    Alternatively, UUIDs could be generated by client applications or
+    other libraries invoked through a server-side function.
+   </para>
   </sect1>
 
   <sect1 id="datatype-xml">
diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index b8474a0a87b..5d5188aa008 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/installation.sgml,v 1.287 2007/04/21 15:30:28 adunstan Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/installation.sgml,v 1.288 2007/04/21 17:26:17 petere Exp $ -->
 
 <chapter id="installation">
  <title><![%standalone-include[<productname>PostgreSQL</>]]>
@@ -910,6 +910,19 @@ su - postgres
        </listitem>
       </varlistentry>
 
+      <varlistentry>
+       <term><option>--with-ossp-uuid</option></term>
+       <listitem>
+        <para>
+         Build with the <ulink
+         url="http://www.ossp.org/pkg/lib/uuid/">OSSP UUID
+         library</ulink>.  This is necessary for the contrib module
+         <literal>uuid-ossp</literal> which provides functions to
+         generate UUIDs.<indexterm><primary>UUID</primary></indexterm>
+        </para>
+       </listitem>
+      </varlistentry>
+
       <varlistentry>
        <term><option>--with-libxml</option></term>
        <listitem>
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 2266704922c..604d7bbc67f 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -1,5 +1,5 @@
 # -*-makefile-*-
-# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.235 2007/04/15 12:48:23 adunstan Exp $
+# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.236 2007/04/21 17:26:18 petere Exp $
 
 #------------------------------------------------------------------------------
 # All PostgreSQL makefiles include this file and use the variables it sets,
@@ -152,6 +152,7 @@ with_perl	= @with_perl@
 with_python	= @with_python@
 with_tcl	= @with_tcl@
 with_openssl	= @with_openssl@
+with_ossp_uuid	= @with_ossp_uuid@
 with_libxml	= @with_libxml@
 with_libxslt	= @with_libxslt@
 with_zlib	= @with_zlib@
-- 
GitLab