From nobody@FreeBSD.org  Sun Mar 16 00:29:53 2008
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 44FBB106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 16 Mar 2008 00:29:53 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 44B0C8FC15
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 16 Mar 2008 00:29:53 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m2G0QTS9080982
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 16 Mar 2008 00:26:29 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.2/8.14.1/Submit) id m2G0QT2A080981;
	Sun, 16 Mar 2008 00:26:29 GMT
	(envelope-from nobody)
Message-Id: <200803160026.m2G0QT2A080981@www.freebsd.org>
Date: Sun, 16 Mar 2008 00:26:29 GMT
From: "Samuel J. Greear" <freebsd-pr@evilcode.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: PostgreSQL contrib ossp-uuid crashes backend
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         121745
>Category:       ports
>Synopsis:       misc/ossp-uuid - PostgreSQL contrib ossp-uuid crashes backend
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    vd
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Mar 16 00:30:02 UTC 2008
>Closed-Date:    
>Last-Modified:  Thu Mar 20 13:50:02 UTC 2014
>Originator:     Samuel J. Greear
>Release:        7.0-RELEASE
>Organization:
Evilcode Corporation
>Environment:
FreeBSD dev1.in.flixn.com 7.0-RELEASE FreeBSD 7.0-RELEASE #0: Sun Feb 24 19:59:52 UTC 2008     root@logan.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386

>Description:
#0  0x28960bf0 in uuid_make_v1 (uuid=0xf58f3e57, mode=1, ap=0xbfbfe308 "") at uuid.c:897
897             if (!(   time_now.tv_sec  == uuid->time_last.tv_sec
[New Thread 0x28a01100 (LWP 100116)]
(gdb) bt
#0  0x28960bf0 in uuid_make_v1 (uuid=0xf58f3e57, mode=1, ap=0xbfbfe308 "") at uuid.c:897
#1  0x28961441 in uuid_make (uuid=0xf58f3e57, mode=1) at uuid.c:1195
#2  0x2895ee71 in uuid_generate_internal (mode=1, ns=0x0, name=0x0) at uuid-ossp.c:176
#3  0x2895eef2 in uuid_generate_v1 (fcinfo=0xbfbfe388) at uuid-ossp.c:191
#4  0x08193306 in ExecMakeFunctionResult (fcache=0x28ae62b8, econtext=0x28ae6230, isNull=0x28ae6918 "", isDone=0x28ae6928) at execQual.c:1351
#5  0x08193b49 in ExecEvalFunc (fcache=0x28ae62b8, econtext=0x28ae6230, isNull=0x28ae6918 "", isDone=0x28ae6928) at execQual.c:1753
#6  0x08199253 in ExecTargetList (targetlist=0x28ae66d0, econtext=0x28ae6230, values=0x28ae6908, isnull=0x28ae6918 "", itemIsDone=0x28ae6928,
    isDone=0xbfbfe6a0) at execQual.c:4601
#7  0x08199670 in ExecProject (projInfo=0x28ae6808, isDone=0xbfbfe6a0) at execQual.c:4802
#8  0x081a6dea in ExecResult (node=0x28ae61a8) at nodeResult.c:155
#9  0x08190e59 in ExecProcNode (node=0x28ae61a8) at execProcnode.c:319
#10 0x0818eb05 in ExecutePlan (estate=0x28ae6018, planstate=0x28ae61a8, operation=CMD_SELECT, numberTuples=0, direction=ForwardScanDirection,
    dest=0x28a96dd8) at execMain.c:1233
#11 0x0818d6a4 in ExecutorRun (queryDesc=0x28adb868, direction=ForwardScanDirection, count=0) at execMain.c:267
#12 0x08255264 in PortalRunSelect (portal=0x28ae1018, forward=1 '\001', count=0, dest=0x28a96dd8) at pquery.c:943
#13 0x08254f6a in PortalRun (portal=0x28ae1018, count=2147483647, isTopLevel=1 '\001', dest=0x28a96dd8, altdest=0x28a96dd8, completionTag=0xbfbfe8fa "")
    at pquery.c:769
#14 0x0824f84e in exec_simple_query (query_string=0x28a96018 "SELECT uuid_generate_v1();") at postgres.c:963
#15 0x082536dc in PostgresMain (argc=4, argv=0x28a32448, username=0x28a32428 "flixn") at postgres.c:3530
#16 0x0821cf0c in BackendRun (port=0x28a07400) at postmaster.c:3207
#17 0x0821c420 in BackendStartup (port=0x28a07400) at postmaster.c:2830
#18 0x08219e62 in ServerLoop () at postmaster.c:1274
#19 0x08219835 in PostmasterMain (argc=3, argv=0xbfbfed74) at postmaster.c:1029
#20 0x081bab25 in main (argc=3, argv=0xbfbfed74) at main.c:188


Pg uuid-ossp module is perhaps using the wrong uuid_t definition?
>How-To-Repeat:
Install misc/ossp-uuid. Install databases/postgresql83-server, install databases/postgresql-contrib (may need extra configure line --with-ossp-uuid). 

Add uuid functions to a database as per: http://www.postgresql.org/docs/current/static/contrib.html

Call any of the uuid functions as per: http://www.postgresql.org/docs/current/static/uuid-ossp.html
>Fix:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->vd 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Sun Mar 16 09:17:31 UTC 2008 
Responsible-Changed-Why:  
Over to maintainer (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=121745 
State-Changed-From-To: open->feedback 
State-Changed-By: vd 
State-Changed-When: Fri May 30 10:45:54 UTC 2008 
State-Changed-Why:  
Maybe this should be reported upstream, does not look like FreeBSD specific. 

I have just upgraded misc/ossp-uuid from 1.6.0 to 1.6.1 and the ChangeLog 
mentions some PostgreSQL changes, can someone confirm or deny whether this 
bug exists in 1.6.1? 

Thank you! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=121745 

From: Jan Deelstra <jd@labq.nl>
To: bug-followup@FreeBSD.org, freebsd-pr@evilcode.net
Cc:  
Subject: Re: ports/121745: misc/ossp-uuid - PostgreSQL contrib ossp-uuid crashes
 backend
Date: Mon, 23 Jun 2008 16:54:52 +0200

 Bug does exists in ossp-uuid 1.6.1 . Seems to be FreeBSD specific, since 
 I cant find any other reports.
 
 Best Regards,
 Jan Deelstra

From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: bug-followup@FreeBSD.org,freebsd-pr@evilcode.net
Cc:  
Subject: Re: ports/121745: misc/ossp-uuid - PostgreSQL contrib ossp-uuid
 crashes backend
Date: Sun, 08 Mar 2009 07:44:09 +0000

 In case anyone still cares about this one, it's actually very simple;
 the uuid_create function in ossp-uuid conflicts with the one in libc.
 Since postgresql contrib modules are loaded dynamically, the function
 in libc takes precedence over the one in the module, and hilarity
 ensues.
 
 -- 
 Andrew.

From: =?ISO-8859-1?Q?J=F8rgen_Fr=F8jk_Kj=E6rsgaard?= <jfk@metation.dk>
To: bug-followup@FreeBSD.org, freebsd-pr@evilcode.net
Cc:  
Subject: Re: ports/121745: misc/ossp-uuid - PostgreSQL contrib ossp-uuid crashes
 backend
Date: Sun, 05 Jul 2009 12:25:05 +0200

 I need uuid for PostgreSQL. How do I build misc/ossp-uuid and 
 databases/postgresql-contrib to avoid the uuid_create() conflict?
 
 Regards, Jorgen Kjaersgaard
 

From: Vasil Dimov <vd@FreeBSD.org>
To: J?rgen Fr?jk Kj?rsgaard <jfk@metation.dk>
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/121745: misc/ossp-uuid - PostgreSQL contrib ossp-uuid
	crashes backend
Date: Mon, 6 Jul 2009 11:54:55 +0300

 On Sun, Jul 05, 2009 at 10:50:04 +0000, J?rgen Fr?jk Kj?rsgaard wrote:
 > The following reply was made to PR ports/121745; it has been noted by GNA=
 TS.
 >=20
 > From: =3D?ISO-8859-1?Q?J=3DF8rgen_Fr=3DF8jk_Kj=3DE6rsgaard?=3D <jfk@metat=
 ion.dk>
 > To: bug-followup@FreeBSD.org, freebsd-pr@evilcode.net
 > Cc: =20
 > Subject: Re: ports/121745: misc/ossp-uuid - PostgreSQL contrib ossp-uuid =
 crashes
 >  backend
 > Date: Sun, 05 Jul 2009 12:25:05 +0200
 >=20
 >  I need uuid for PostgreSQL. How do I build misc/ossp-uuid and=20
 >  databases/postgresql-contrib to avoid the uuid_create() conflict?
 [...]
 
 Hi,
 
 I see a few workarounds (if indeed the problem is that the system's
 uuid_*() functions are picked up):
 
 * Link ossp-uuid statically into the client application, so that e.g.
   uuid_create() is not picked from libc.
 
 * Change ossp-uuid to export functions that have different names, e.g.
   ossp_uuid_create() instead of uuid_create() and change the application
   that is using it to call ossp_uuid_create().
 
 Let me know if any of these or something else works for you and I will
 see if it can be hacked into the misc/ossp-uuid port, probably as an
 option.
 
 --=20
 Vasil Dimov
 moc.elcaro@vomid.lisav        Software Developer @ Oracle/Innobase Oy
 gro.DSBeerF@dv                Committer @ FreeBSD.org
 gro.d5v@dv                    Home @ Sofia, Bulgaria

From: =?ISO-8859-1?Q?J=F8rgen_Fr=F8jk_Kj=E6rsgaard?= <jfk@metation.dk>
To: bug-followup@FreeBSD.org, freebsd-pr@evilcode.net
Cc:  
Subject: Re: ports/121745: misc/ossp-uuid - PostgreSQL contrib ossp-uuid crashes
 backend
Date: Tue, 07 Jul 2009 14:15:26 +0200

 The problem is indeed a clash with the system's uuid_* functions. It's a 
 really nasty problem. The function names ought to be changed in ossp-uuid.
 
 I found an alternative uuid module for PostgreSQL, see 
 http://blog.rhodiumtoad.org.uk/2008/12/21/uuid-generation-for-postgresql-83-on-freebsd/ 
 and http://pgfoundry.org/projects/uuid-freebsd/. It works well and using 
 it is much easier than having to modify ossp-uuid and the uuid module 
 for PostgreSQL.
 
 regards, Jrgen Kjrsgaard
 
State-Changed-From-To: feedback->open 
State-Changed-By: pav 
State-Changed-When: Sat Dec 19 17:16:49 UTC 2009 
State-Changed-Why:  
Feedback received - bug still exists 

http://www.freebsd.org/cgi/query-pr.cgi?pr=121745 

From: Christian Lawrence <christian.lawrence@calorieking.com>
To: bug-followup@FreeBSD.org, freebsd-pr@evilcode.net
Cc:  
Subject: Re: ports/121745: misc/ossp-uuid - PostgreSQL contrib ossp-uuid crashes
 backend
Date: Fri, 08 Feb 2013 12:40:59 +0800

 Hi!
 
 Given this PR is steaming head long into it's 5th year, and it affects 
 postgresql-contrib (including postgresql92), and it hasn't been fixed by 
 ossp-uuid 1.6.2_2, then what's the likely hood of this bug being 
 resolved any time soon?
 
 -- 
 Christian Lawrence
 Senior Developer
 CalorieKing Wellness Solutions Incorporated
 T: +618.9389.8777
 F: +618.9389.8444
 E: christian.lawrence@calorieking.com
 W: www.calorieking.com

From: =?ISO-8859-15?Q?Andre_Gro=DFe_Bley?= <info@grosse-bley.com>
To: bug-followup@FreeBSD.org, freebsd-pr@evilcode.net
Cc:  
Subject: Re: ports/121745: misc/ossp-uuid - PostgreSQL contrib ossp-uuid crashes
 backend
Date: Sat, 27 Apr 2013 21:45:09 +0200

 Hello,
 
 a user on my machine hit this problem, too.
 I did a quick'n'dirty hotfix:
 
 gandalf@ak47 ~pgsql: cat .profile
 export LD_PRELOAD=/usr/local/pgsql/libc.so.hack
 
 libc.so.hack is a copy of /lib/libc.so.7
 I used "vi" to change the "uuid_" export symbol names to "xxxx_". (Yeah, 
 i _am_ a lunatic.)
 After restarting postgres, it will use the "patched" libc, and the 
 uuid-Functions won't cause a crash anymore.
 
 BTW, it would be better to add the preload to rc.d/postgres
 Note: you need to re-"patch" the libc after every make world.
 
 Greetings
 	Andre

From: Palle Girgensohn <girgen@pingpong.net>
To: bug-followup@FreeBSD.org, freebsd-pr@evilcode.net
Cc:  
Subject: Re: ports/121745: misc/ossp-uuid - PostgreSQL contrib ossp-uuid
 crashes backend
Date: Tue, 18 Mar 2014 12:13:02 +0100

 Hi,
 
 There are two approaches to this as I see it.
 
 1. modify ossp so it aliases the methods to avoid using the libc ones, as 
 suggested [ports/121745]
 
 2. use the uuid-freebsd compatible uuid that uses libc instead of ossp.
 
 Since uuid is built in to libc, and the uuid-freebsd is completely 
 compatible with the ossp variant, I'm adding support in postgresql-contrib 
 for the uuid-freebsd extension.
 
 Will that be OK with you all?
 
 Palle
 
 [1] http://pgfoundry.org/projects/uuid-freebsd/
 [2] http://www.freebsd.org/cgi/query-pr.cgi?pr=121745
 
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/121745: commit references a PR
Date: Thu, 20 Mar 2014 13:43:23 +0000 (UTC)

 Author: girgen
 Date: Thu Mar 20 13:43:15 2014
 New Revision: 348685
 URL: http://svnweb.freebsd.org/changeset/ports/348685
 QAT: https://qat.redports.org/buildarchive/r348685/
 
 Log:
   The PostgreSQL Global Development Group has released an update to all supported
   version of the database system, including versions 9.3.4, 9.2.8, 9.1.13,
   9.0.17, and 8.4.21. This minor release fixes a data corruption issue with
   replication and crash recovery in version 9.3, as well as several other minor
   issues in all versions.  All users of version 9.3 are urged to update their
   installations at the next possible downtime.  Users of older versions should
   update at their convenience.
   
   The data corruption issue in PostgreSQL 9.3 affects binary replication
   standbys, servers being recovered from point-in-time-recovery backup, and
   standalone servers which recover from a system crash. The bug causes
   unrecoverable index corruption during recovery due to incorrect replay of row
   locking operations.  This can then cause query results to be inconsistent
   depending on whether or not an index is used, and eventually lead to primary
   key violations and similar issues.  For this reason, users are encouraged to
   replace each of their standby databases with a new base backup after applying
   the update.
   
   See release notes for more changes.
   
   URL:	http://www.postgresql.org/docs/current/static/release.html
   URL:	https://wiki.postgresql.org/wiki/20140320UpdateIssues
   
   A change specific to the FreeBSD port:
   Modify the contrib/uuid-ossp to actually work (not crashing the backend) by
   using the libc implementation of uuid instead of the ossp port. Schemas and
   queries will just work. Based on the work of Andrew Gierth. 9.1+ EXTENSION
   support added by girgen@.
   
   URL:	http://pgfoundry.org/projects/uuid-freebsd
   PR:	ports/121745, ports/182846
 
 Added:
   head/databases/postgresql84-server/files/patch-contrib-uuid   (contents, props changed)
   head/databases/postgresql90-server/files/patch-contrib-uuid   (contents, props changed)
   head/databases/postgresql91-server/files/patch-contrib-uuid   (contents, props changed)
   head/databases/postgresql92-server/files/patch-contrib-uuid   (contents, props changed)
   head/databases/postgresql93-server/files/patch-contrib-uuid   (contents, props changed)
 Modified:
   head/databases/postgresql84-contrib/Makefile
   head/databases/postgresql84-server/Makefile
   head/databases/postgresql84-server/distinfo
   head/databases/postgresql84-server/pkg-plist-contrib
   head/databases/postgresql90-contrib/Makefile
   head/databases/postgresql90-server/Makefile
   head/databases/postgresql90-server/distinfo
   head/databases/postgresql90-server/pkg-plist-contrib
   head/databases/postgresql91-contrib/Makefile
   head/databases/postgresql91-server/Makefile
   head/databases/postgresql91-server/distinfo
   head/databases/postgresql91-server/pkg-plist-contrib
   head/databases/postgresql92-contrib/Makefile
   head/databases/postgresql92-server/Makefile
   head/databases/postgresql92-server/distinfo
   head/databases/postgresql92-server/pkg-plist-contrib
   head/databases/postgresql93-contrib/Makefile
   head/databases/postgresql93-server/Makefile
   head/databases/postgresql93-server/distinfo
   head/databases/postgresql93-server/pkg-plist-contrib
 
 Modified: head/databases/postgresql84-contrib/Makefile
 ==============================================================================
 --- head/databases/postgresql84-contrib/Makefile	Thu Mar 20 13:16:44 2014	(r348684)
 +++ head/databases/postgresql84-contrib/Makefile	Thu Mar 20 13:43:15 2014	(r348685)
 @@ -23,7 +23,7 @@ INSTALL_DIRS=	contrib
  
  SLAVE_ONLY=	yes
  COMPONENT=	-contrib
 -CONFIGURE_ARGS+=--with-libxslt --with-libxml --with-openssl
 +CONFIGURE_ARGS+=--with-libxslt --with-libxml --with-openssl --with-ossp-uuid
  
  post-install:
  	@- ${INSTALL_DATA} ${WRKSRC}/contrib/README ${STAGEDIR}${DOCSDIR}/contrib/README
 
 Modified: head/databases/postgresql84-server/Makefile
 ==============================================================================
 --- head/databases/postgresql84-server/Makefile	Thu Mar 20 13:16:44 2014	(r348684)
 +++ head/databases/postgresql84-server/Makefile	Thu Mar 20 13:43:15 2014	(r348685)
 @@ -2,7 +2,7 @@
  # $FreeBSD$
  
  PORTNAME?=	postgresql
 -DISTVERSION?=	8.4.20
 +DISTVERSION?=	8.4.21
  PORTREVISION?=	0
  CATEGORIES?=	databases
  MASTER_SITES=	PGSQL
 
 Modified: head/databases/postgresql84-server/distinfo
 ==============================================================================
 --- head/databases/postgresql84-server/distinfo	Thu Mar 20 13:16:44 2014	(r348684)
 +++ head/databases/postgresql84-server/distinfo	Thu Mar 20 13:43:15 2014	(r348685)
 @@ -1,4 +1,4 @@
 -SHA256 (postgresql/postgresql-8.4.20.tar.bz2) = e84e46083a6accd2bf37f0bd7253415649afcafc49f2564bc8481c10ed90d7c1
 -SIZE (postgresql/postgresql-8.4.20.tar.bz2) = 14642312
 +SHA256 (postgresql/postgresql-8.4.21.tar.bz2) = 388f67e59f2a16c27e84f50656f5d755adf3d0a883138366d091aa0c727c1e2c
 +SIZE (postgresql/postgresql-8.4.21.tar.bz2) = 14645050
  SHA256 (postgresql/pg-8419-icu-2014-02-10.diff.gz) = a67fc17ef9985200cd25d6d534338305978496ea13d86fc6d1f6125d36ecf78f
  SIZE (postgresql/pg-8419-icu-2014-02-10.diff.gz) = 4374
 
 Added: head/databases/postgresql84-server/files/patch-contrib-uuid
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ head/databases/postgresql84-server/files/patch-contrib-uuid	Thu Mar 20 13:43:15 2014	(r348685)
 @@ -0,0 +1,371 @@
 +--- contrib/uuid-ossp/Makefile.orig	2014-03-17 20:38:14.000000000 +0100
 ++++ contrib/uuid-ossp/Makefile	2014-03-19 23:02:37.000000000 +0100
 +@@ -5,8 +5,8 @@
 + DATA_built = uuid-ossp.sql
 + DATA = uninstall_uuid-ossp.sql
 + 
 +-SHLIB_LINK += $(OSSP_UUID_LIBS)
 ++SHLIB_LINK += -lmd
 +
 + ifdef USE_PGXS
 + PG_CONFIG = pg_config
 + PGXS := $(shell $(PG_CONFIG) --pgxs)
 +--- contrib/uuid-ossp/uuid-ossp.c.orig	2014-03-17 20:38:14.000000000 +0100
 ++++ contrib/uuid-ossp/uuid-ossp.c	2014-03-19 23:01:59.000000000 +0100
 +@@ -6,6 +6,10 @@
 +  *
 +  * $PostgreSQL: pgsql/contrib/uuid-ossp/uuid-ossp.c,v 1.12 2010/01/02 16:57:33 momjian Exp $
 +  *
 ++ * Modified to use FreeBSD's built in uuid instead of ossp:
 ++ * Copyright (c) 2009 Andrew Gierth
 ++ *
 ++ * URL: http://pgfoundry.org/projects/uuid-freebsd
 +  *-------------------------------------------------------------------------
 +  */
 + 
 +@@ -14,27 +18,14 @@
 + #include "utils/builtins.h"
 + #include "utils/uuid.h"
 + 
 +-/*
 +- * There's some confusion over the location of the uuid.h header file.
 +- * On Debian, it's installed as ossp/uuid.h, while on Fedora, or if you
 +- * install ossp-uuid from a tarball, it's installed as uuid.h. Don't know
 +- * what other systems do.
 +- */
 +-#ifdef HAVE_OSSP_UUID_H
 +-#include <ossp/uuid.h>
 +-#else
 +-#ifdef HAVE_UUID_H
 +-#include <uuid.h>
 +-#else
 +-#error OSSP uuid.h not found
 +-#endif
 +-#endif
 +-
 +-/* better both be 16 */
 +-#if (UUID_LEN != UUID_LEN_BIN)
 +-#error UUID length mismatch
 +-#endif
 ++/* OS has a uuid_hash that conflicts with ours; kill it*/
 ++/* explicit path since we do _not_ want to get any other version */
 ++#define uuid_hash freebsd_uuid_hash
 ++#include "/usr/include/uuid.h"
 ++#undef uuid_hash
 + 
 ++#include <md5.h>
 ++#include <sha.h>
 + 
 + PG_MODULE_MAGIC;
 + 
 +@@ -64,163 +55,175 @@
 + PG_FUNCTION_INFO_V1(uuid_generate_v4);
 + PG_FUNCTION_INFO_V1(uuid_generate_v5);
 + 
 +-static void
 +-pguuid_complain(uuid_rc_t rc)
 +-{
 +-	char	   *err = uuid_error(rc);
 +-
 +-	if (err != NULL)
 +-		ereport(ERROR,
 +-				(errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
 +-				 errmsg("OSSP uuid library failure: %s", err)));
 +-	else
 +-		ereport(ERROR,
 +-				(errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
 +-				 errmsg("OSSP uuid library failure: error code %d", rc)));
 +-}
 ++/* we assume that the string representation is portable and that the
 ++ * native binary representation might not be. But for *ns, we assume
 ++ * that pg's internal storage of uuids is the simple byte-oriented
 ++ * binary format. */
 + 
 +-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_rc_t	rc;
 +-
 +-	rc = uuid_export(uuid, UUID_FMT_STR, &ptr, &len);
 +-	if (rc != UUID_RC_OK)
 +-		pguuid_complain(rc);
 +-
 +-	return buf;
 +-}
 +-
 +-
 +-static void
 +-string_to_uuid(const char *str, uuid_t *uuid)
 ++static Datum
 ++internal_uuid_create(int v, unsigned char *ns, char *ptr, int len)
 + {
 +-	uuid_rc_t	rc;
 +-
 +-	rc = uuid_import(uuid, UUID_FMT_STR, str, UUID_LEN_STR + 1);
 +-	if (rc != UUID_RC_OK)
 +-		pguuid_complain(rc);
 +-}
 ++	char strbuf[40];
 + 
 ++	switch (v)
 ++	{
 ++	case 0:	 /* constant-value uuids: nil, or namespace uuids */
 ++		strlcpy(strbuf, ptr, 37);
 ++		break;
 ++
 ++	case 4: default:   /* random uuid */
 ++	{
 ++		sprintf(strbuf, "%08lx-%04x-%04x-%04x-%04x%08lx",
 ++			(unsigned long) arc4random(),
 ++			(unsigned) (arc4random() & 0xffff),
 ++			(unsigned) ((arc4random() & 0xfff) | 0x4000),
 ++			(unsigned) ((arc4random() & 0x3fff) | 0x8000),
 ++			(unsigned) (arc4random() & 0xffff),
 ++			(unsigned long) arc4random());
 ++		break;
 ++	}
 ++		
 ++	case 1:	 /* time/node-based uuids */
 ++	{
 ++		uuid_t uu;
 ++		uint32_t status = uuid_s_ok;
 ++		char *str = NULL;
 ++
 ++		uuid_create(&uu, &status);
 ++
 ++		if (status == uuid_s_ok)
 ++		{
 ++		uuid_to_string(&uu, &str, &status);
 ++		if (status == uuid_s_ok)
 ++		{
 ++			strlcpy(strbuf, str, 37);
 ++
 ++			/* PTR, if set, replaces the trailing characters of the uuid;
 ++			 * this is to support v1mc, where a random multicast MAC is
 ++			 * used instead of the physical one
 ++			 */
 ++			
 ++			if (ptr && len <= 36)
 ++			strcpy(strbuf + (36 - len), ptr);
 ++		}
 ++		if (str)
 ++			free(str);
 ++		}
 + 
 +-static Datum
 +-special_uuid_value(const char *name)
 +-{
 +-	uuid_t	   *uuid;
 +-	char	   *str;
 +-	uuid_rc_t	rc;
 +-
 +-	rc = uuid_create(&uuid);
 +-	if (rc != UUID_RC_OK)
 +-		pguuid_complain(rc);
 +-	rc = uuid_load(uuid, name);
 +-	if (rc != UUID_RC_OK)
 +-		pguuid_complain(rc);
 +-	str = uuid_to_string(uuid);
 +-	rc = uuid_destroy(uuid);
 +-	if (rc != UUID_RC_OK)
 +-		pguuid_complain(rc);
 ++		if (status != uuid_s_ok)
 ++		{
 ++		ereport(ERROR,
 ++			(errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
 ++			 errmsg("FreeBSD uuid library failure: %d", (int) status)));
 ++		}
 ++		
 ++		break;
 ++	}
 ++
 ++	case 3:	 /* namespace-based MD5 uuids */
 ++	{
 ++		/* we could use pg's md5(), but we're already pulling in libmd */
 ++		MD5_CTX ctx;
 ++		unsigned char buf[16];
 ++
 ++		MD5Init(&ctx);
 ++		MD5Update(&ctx, ns, 16);
 ++		MD5Update(&ctx, (unsigned char *)ptr, len);
 ++		MD5Final(buf, &ctx);
 ++
 ++		sprintf(strbuf,
 ++			"%02x%02x%02x%02x-"
 ++			"%02x%02x-%02x%02x-%02x%02x-"
 ++			"%02x%02x%02x%02x%02x%02x",
 ++			buf[0], buf[1], buf[2], buf[3],
 ++			buf[4], buf[5], ((buf[6] & 0xf) | 0x30), buf[7],
 ++			((buf[8] & 0x3F) | 0x80), buf[9], buf[10], buf[11],
 ++			buf[12], buf[13], buf[14], buf[15]);
 ++
 ++		break;
 ++	}
 ++
 ++	case 5:	 /* namespace-based SHA1 uuids */
 ++	{
 ++		SHA_CTX ctx;
 ++		unsigned char buf[20];
 ++
 ++		SHA1_Init(&ctx);
 ++		SHA1_Update(&ctx, ns, 16);
 ++		SHA1_Update(&ctx, (unsigned char *)ptr, len);
 ++		SHA1_Final(buf, &ctx);
 ++
 ++		sprintf(strbuf,
 ++			"%02x%02x%02x%02x-"
 ++			"%02x%02x-%02x%02x-%02x%02x-"
 ++			"%02x%02x%02x%02x%02x%02x",
 ++			buf[0], buf[1], buf[2], buf[3],
 ++			buf[4], buf[5], ((buf[6] & 0xf) | 0x30), buf[7],
 ++			((buf[8] & 0x3F) | 0x80), buf[9], buf[10], buf[11],
 ++			buf[12], buf[13], buf[14], buf[15]);
 ++
 ++			break;
 ++		}
 ++	}
 + 
 +-	return DirectFunctionCall1(uuid_in, CStringGetDatum(str));
 ++	return DirectFunctionCall1(uuid_in, CStringGetDatum(strbuf));
 + }
 + 
 + 
 + Datum
 + uuid_nil(PG_FUNCTION_ARGS)
 + {
 +-	return special_uuid_value("nil");
 ++	return internal_uuid_create(0, NULL, "00000000-0000-0000-0000-000000000000", 36);
 + }
 + 
 + 
 + Datum
 + uuid_ns_dns(PG_FUNCTION_ARGS)
 + {
 +-	return special_uuid_value("ns:DNS");
 ++	return internal_uuid_create(0, NULL, "6ba7b810-9dad-11d1-80b4-00c04fd430c8", 36);
 + }
 + 
 + 
 + Datum
 + uuid_ns_url(PG_FUNCTION_ARGS)
 + {
 +-	return special_uuid_value("ns:URL");
 ++	return internal_uuid_create(0, NULL, "6ba7b811-9dad-11d1-80b4-00c04fd430c8", 36);
 + }
 + 
 + 
 + Datum
 + uuid_ns_oid(PG_FUNCTION_ARGS)
 + {
 +-	return special_uuid_value("ns:OID");
 ++	return internal_uuid_create(0, NULL, "6ba7b812-9dad-11d1-80b4-00c04fd430c8", 36);
 + }
 + 
 + 
 + 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_rc_t	rc;
 +-
 +-	rc = uuid_create(&uuid);
 +-	if (rc != UUID_RC_OK)
 +-		pguuid_complain(rc);
 +-	rc = uuid_make(uuid, mode, ns, name);
 +-	if (rc != UUID_RC_OK)
 +-		pguuid_complain(rc);
 +-	str = uuid_to_string(uuid);
 +-	rc = uuid_destroy(uuid);
 +-	if (rc != UUID_RC_OK)
 +-		pguuid_complain(rc);
 +-
 +-	return DirectFunctionCall1(uuid_in, CStringGetDatum(str));
 ++	return internal_uuid_create(0, NULL, "6ba7b814-9dad-11d1-80b4-00c04fd430c8", 36);
 + }
 + 
 + 
 + Datum
 + uuid_generate_v1(PG_FUNCTION_ARGS)
 + {
 +-	return uuid_generate_internal(UUID_MAKE_V1, NULL, NULL);
 ++	return internal_uuid_create(1, NULL, NULL, 0);
 + }
 + 
 + 
 + 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_rc_t	rc;
 +-
 +-	rc = uuid_create(&ns_uuid);
 +-	if (rc != UUID_RC_OK)
 +-		pguuid_complain(rc);
 +-	string_to_uuid(DatumGetCString(DirectFunctionCall1(uuid_out, UUIDPGetDatum(ns))),
 +-				   ns_uuid);
 +-
 +-	result = uuid_generate_internal(mode,
 +-									ns_uuid,
 +-									text_to_cstring(name));
 +-
 +-	rc = uuid_destroy(ns_uuid);
 +-	if (rc != UUID_RC_OK)
 +-		pguuid_complain(rc);
 ++	char buf[20];
 + 
 +-	return result;
 ++	sprintf(buf, "-%04x-%04x%08lx",
 ++		(unsigned)((arc4random() & 0x3FFF) | 0x8000),
 ++		/* set IEEE802 multicast and local-admin bits */
 ++		(unsigned)((arc4random() & 0xffff) | 0x0300),
 ++		(unsigned long) arc4random());
 ++		
 ++	return internal_uuid_create(1, NULL, buf, 18);
 + }
 + 
 + 
 +@@ -230,14 +233,15 @@
 + 	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);
 ++	return internal_uuid_create(3, (unsigned char *)ns,
 ++				VARDATA(name), VARSIZE(name) - VARHDRSZ);
 + }
 + 
 + 
 + Datum
 + uuid_generate_v4(PG_FUNCTION_ARGS)
 + {
 +-	return uuid_generate_internal(UUID_MAKE_V4, NULL, NULL);
 ++	return internal_uuid_create(4, NULL, NULL, 0);
 + }
 + 
 + 
 +@@ -247,5 +251,6 @@
 + 	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);
 ++	return internal_uuid_create(5, (unsigned char *)ns,
 ++				VARDATA(name), VARSIZE(name) - VARHDRSZ);
 + }
 
 Modified: head/databases/postgresql84-server/pkg-plist-contrib
 ==============================================================================
 --- head/databases/postgresql84-server/pkg-plist-contrib	Thu Mar 20 13:16:44 2014	(r348684)
 +++ head/databases/postgresql84-server/pkg-plist-contrib	Thu Mar 20 13:43:15 2014	(r348685)
 @@ -38,6 +38,7 @@ lib/postgresql/tablefunc.so
  lib/postgresql/test_parser.so
  lib/postgresql/timetravel.so
  lib/postgresql/tsearch2.so
 +lib/postgresql/uuid-ossp.so
  %%DOCSDIR%%/README-contrib
  %%DOCSDIR%%/contrib/README
  %%DOCSDIR%%/contrib/autoinc.example
 @@ -112,6 +113,8 @@ share/postgresql/contrib/uninstall_sslin
  share/postgresql/contrib/uninstall_tablefunc.sql
  share/postgresql/contrib/uninstall_test_parser.sql
  share/postgresql/contrib/uninstall_tsearch2.sql
 +share/postgresql/contrib/uninstall_uuid-ossp.sql
 +share/postgresql/contrib/uuid-ossp.sql
  share/postgresql/tsearch_data/xsyn_sample.rules
  @dirrmtry share/postgresql/tsearch_data
  @dirrmtry share/postgresql/contrib
 
 Modified: head/databases/postgresql90-contrib/Makefile
 ==============================================================================
 --- head/databases/postgresql90-contrib/Makefile	Thu Mar 20 13:16:44 2014	(r348684)
 +++ head/databases/postgresql90-contrib/Makefile	Thu Mar 20 13:43:15 2014	(r348685)
 @@ -23,13 +23,9 @@ INSTALL_DIRS=	contrib
  
  SLAVE_ONLY=	yes
  COMPONENT=	-contrib
 -CONFIGURE_ARGS+=--with-libxslt --with-libxml --with-openssl
 +CONFIGURE_ARGS+=--with-libxslt --with-libxml --with-openssl --with-ossp-uuid
  LDFLAGS+=	${PTHREAD_LIBS} -L${PREFIX}/lib
  
 -OPTIONS_DEFINE=	OSSP_UUID
 -OSSP_UUID_DESC=	Enable / disable ossp-uuid support
 -OPTIONS_DEFAULT=	OSSP_UUID
 -
  post-install:
  	@- ${INSTALL_DATA} ${WRKSRC}/contrib/README ${STAGEDIR}${DOCSDIR}/contrib/README
  
 
 Modified: head/databases/postgresql90-server/Makefile
 ==============================================================================
 --- head/databases/postgresql90-server/Makefile	Thu Mar 20 13:16:44 2014	(r348684)
 +++ head/databases/postgresql90-server/Makefile	Thu Mar 20 13:43:15 2014	(r348685)
 @@ -1,7 +1,7 @@
  # Created by: Marc G. Fournier <scrappy@FreeBSD.org>
  # $FreeBSD$
  
 -DISTVERSION?=	9.0.16
 +DISTVERSION?=	9.0.17
  PORTREVISION=	0
  PKGNAMESUFFIX?=	${DISTVERSION:R:S/.//}${COMPONENT}
  
 
 Modified: head/databases/postgresql90-server/distinfo
 ==============================================================================
 --- head/databases/postgresql90-server/distinfo	Thu Mar 20 13:16:44 2014	(r348684)
 +++ head/databases/postgresql90-server/distinfo	Thu Mar 20 13:43:15 2014	(r348685)
 @@ -1,4 +1,4 @@
 -SHA256 (postgresql/postgresql-9.0.16.tar.bz2) = 900f6ab00fc36c94b17430e7cb22499708025da1e34d7a70aefaf9a875f0fabf
 -SIZE (postgresql/postgresql-9.0.16.tar.bz2) = 14956681
 +SHA256 (postgresql/postgresql-9.0.17.tar.bz2) = d2f6d09cf941e7cbab6ee399f14080dbe822af58fda9fd132efb05c2b7d160ad
 +SIZE (postgresql/postgresql-9.0.17.tar.bz2) = 14961682
  SHA256 (postgresql/pg-9015-icu-2014-02-10.diff.gz) = ee4a9a9cac56842ed532597f3e9e52ca2363f809a9283c01b2514df19173763a
  SIZE (postgresql/pg-9015-icu-2014-02-10.diff.gz) = 4386
 
 Added: head/databases/postgresql90-server/files/patch-contrib-uuid
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ head/databases/postgresql90-server/files/patch-contrib-uuid	Thu Mar 20 13:43:15 2014	(r348685)
 @@ -0,0 +1,371 @@
 +--- contrib/uuid-ossp/Makefile.orig	2014-03-17 20:38:14.000000000 +0100
 ++++ contrib/uuid-ossp/Makefile	2014-03-19 23:02:37.000000000 +0100
 +@@ -5,8 +5,8 @@
 + DATA_built = uuid-ossp.sql
 + DATA = uninstall_uuid-ossp.sql
 + 
 +-SHLIB_LINK += $(OSSP_UUID_LIBS)
 ++SHLIB_LINK += -lmd
 +
 + ifdef USE_PGXS
 + PG_CONFIG = pg_config
 + PGXS := $(shell $(PG_CONFIG) --pgxs)
 +--- contrib/uuid-ossp/uuid-ossp.c.orig	2014-03-17 20:38:14.000000000 +0100
 ++++ contrib/uuid-ossp/uuid-ossp.c	2014-03-19 23:01:59.000000000 +0100
 +@@ -6,6 +6,10 @@
 +  *
 +  * $PostgreSQL: pgsql/contrib/uuid-ossp/uuid-ossp.c,v 1.12 2010/01/02 16:57:33 momjian Exp $
 +  *
 ++ * Modified to use FreeBSD's built in uuid instead of ossp:
 ++ * Copyright (c) 2009 Andrew Gierth
 ++ *
 ++ * URL: http://pgfoundry.org/projects/uuid-freebsd
 +  *-------------------------------------------------------------------------
 +  */
 + 
 +@@ -14,27 +18,14 @@
 + #include "utils/builtins.h"
 + #include "utils/uuid.h"
 + 
 +-/*
 +- * There's some confusion over the location of the uuid.h header file.
 +- * On Debian, it's installed as ossp/uuid.h, while on Fedora, or if you
 +- * install ossp-uuid from a tarball, it's installed as uuid.h. Don't know
 +- * what other systems do.
 +- */
 +-#ifdef HAVE_OSSP_UUID_H
 +-#include <ossp/uuid.h>
 +-#else
 +-#ifdef HAVE_UUID_H
 +-#include <uuid.h>
 +-#else
 +-#error OSSP uuid.h not found
 +-#endif
 +-#endif
 +-
 +-/* better both be 16 */
 +-#if (UUID_LEN != UUID_LEN_BIN)
 +-#error UUID length mismatch
 +-#endif
 ++/* OS has a uuid_hash that conflicts with ours; kill it*/
 ++/* explicit path since we do _not_ want to get any other version */
 ++#define uuid_hash freebsd_uuid_hash
 ++#include "/usr/include/uuid.h"
 ++#undef uuid_hash
 + 
 ++#include <md5.h>
 ++#include <sha.h>
 + 
 + PG_MODULE_MAGIC;
 + 
 +@@ -64,163 +55,175 @@
 + PG_FUNCTION_INFO_V1(uuid_generate_v4);
 + PG_FUNCTION_INFO_V1(uuid_generate_v5);
 + 
 +-static void
 +-pguuid_complain(uuid_rc_t rc)
 +-{
 +-	char	   *err = uuid_error(rc);
 +-
 +-	if (err != NULL)
 +-		ereport(ERROR,
 +-				(errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
 +-				 errmsg("OSSP uuid library failure: %s", err)));
 +-	else
 +-		ereport(ERROR,
 +-				(errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
 +-				 errmsg("OSSP uuid library failure: error code %d", rc)));
 +-}
 ++/* we assume that the string representation is portable and that the
 ++ * native binary representation might not be. But for *ns, we assume
 ++ * that pg's internal storage of uuids is the simple byte-oriented
 ++ * binary format. */
 + 
 +-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_rc_t	rc;
 +-
 +-	rc = uuid_export(uuid, UUID_FMT_STR, &ptr, &len);
 +-	if (rc != UUID_RC_OK)
 +-		pguuid_complain(rc);
 +-
 +-	return buf;
 +-}
 +-
 +-
 +-static void
 +-string_to_uuid(const char *str, uuid_t *uuid)
 ++static Datum
 ++internal_uuid_create(int v, unsigned char *ns, char *ptr, int len)
 + {
 +-	uuid_rc_t	rc;
 +-
 +-	rc = uuid_import(uuid, UUID_FMT_STR, str, UUID_LEN_STR + 1);
 +-	if (rc != UUID_RC_OK)
 +-		pguuid_complain(rc);
 +-}
 ++	char strbuf[40];
 + 
 ++	switch (v)
 ++	{
 ++	case 0:	 /* constant-value uuids: nil, or namespace uuids */
 ++		strlcpy(strbuf, ptr, 37);
 ++		break;
 ++
 ++	case 4: default:   /* random uuid */
 ++	{
 ++		sprintf(strbuf, "%08lx-%04x-%04x-%04x-%04x%08lx",
 ++			(unsigned long) arc4random(),
 ++			(unsigned) (arc4random() & 0xffff),
 ++			(unsigned) ((arc4random() & 0xfff) | 0x4000),
 ++			(unsigned) ((arc4random() & 0x3fff) | 0x8000),
 ++			(unsigned) (arc4random() & 0xffff),
 ++			(unsigned long) arc4random());
 ++		break;
 ++	}
 ++		
 ++	case 1:	 /* time/node-based uuids */
 ++	{
 ++		uuid_t uu;
 ++		uint32_t status = uuid_s_ok;
 ++		char *str = NULL;
 ++
 ++		uuid_create(&uu, &status);
 ++
 ++		if (status == uuid_s_ok)
 ++		{
 ++		uuid_to_string(&uu, &str, &status);
 ++		if (status == uuid_s_ok)
 ++		{
 ++			strlcpy(strbuf, str, 37);
 ++
 ++			/* PTR, if set, replaces the trailing characters of the uuid;
 ++			 * this is to support v1mc, where a random multicast MAC is
 ++			 * used instead of the physical one
 ++			 */
 ++			
 ++			if (ptr && len <= 36)
 ++			strcpy(strbuf + (36 - len), ptr);
 ++		}
 ++		if (str)
 ++			free(str);
 ++		}
 + 
 +-static Datum
 +-special_uuid_value(const char *name)
 +-{
 +-	uuid_t	   *uuid;
 +-	char	   *str;
 +-	uuid_rc_t	rc;
 +-
 +-	rc = uuid_create(&uuid);
 +-	if (rc != UUID_RC_OK)
 +-		pguuid_complain(rc);
 +-	rc = uuid_load(uuid, name);
 +-	if (rc != UUID_RC_OK)
 +-		pguuid_complain(rc);
 +-	str = uuid_to_string(uuid);
 +-	rc = uuid_destroy(uuid);
 +-	if (rc != UUID_RC_OK)
 +-		pguuid_complain(rc);
 ++		if (status != uuid_s_ok)
 ++		{
 ++		ereport(ERROR,
 ++			(errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
 ++			 errmsg("FreeBSD uuid library failure: %d", (int) status)));
 ++		}
 ++		
 ++		break;
 ++	}
 ++
 ++	case 3:	 /* namespace-based MD5 uuids */
 ++	{
 ++		/* we could use pg's md5(), but we're already pulling in libmd */
 ++		MD5_CTX ctx;
 ++		unsigned char buf[16];
 ++
 ++		MD5Init(&ctx);
 ++		MD5Update(&ctx, ns, 16);
 ++		MD5Update(&ctx, (unsigned char *)ptr, len);
 ++		MD5Final(buf, &ctx);
 ++
 ++		sprintf(strbuf,
 ++			"%02x%02x%02x%02x-"
 ++			"%02x%02x-%02x%02x-%02x%02x-"
 ++			"%02x%02x%02x%02x%02x%02x",
 ++			buf[0], buf[1], buf[2], buf[3],
 ++			buf[4], buf[5], ((buf[6] & 0xf) | 0x30), buf[7],
 ++			((buf[8] & 0x3F) | 0x80), buf[9], buf[10], buf[11],
 ++			buf[12], buf[13], buf[14], buf[15]);
 ++
 ++		break;
 ++	}
 ++
 ++	case 5:	 /* namespace-based SHA1 uuids */
 ++	{
 ++		SHA_CTX ctx;
 ++		unsigned char buf[20];
 ++
 ++		SHA1_Init(&ctx);
 ++		SHA1_Update(&ctx, ns, 16);
 ++		SHA1_Update(&ctx, (unsigned char *)ptr, len);
 ++		SHA1_Final(buf, &ctx);
 ++
 ++		sprintf(strbuf,
 ++			"%02x%02x%02x%02x-"
 ++			"%02x%02x-%02x%02x-%02x%02x-"
 ++			"%02x%02x%02x%02x%02x%02x",
 ++			buf[0], buf[1], buf[2], buf[3],
 ++			buf[4], buf[5], ((buf[6] & 0xf) | 0x30), buf[7],
 ++			((buf[8] & 0x3F) | 0x80), buf[9], buf[10], buf[11],
 ++			buf[12], buf[13], buf[14], buf[15]);
 ++
 ++			break;
 ++		}
 ++	}
 + 
 +-	return DirectFunctionCall1(uuid_in, CStringGetDatum(str));
 ++	return DirectFunctionCall1(uuid_in, CStringGetDatum(strbuf));
 + }
 + 
 + 
 + Datum
 + uuid_nil(PG_FUNCTION_ARGS)
 + {
 +-	return special_uuid_value("nil");
 ++	return internal_uuid_create(0, NULL, "00000000-0000-0000-0000-000000000000", 36);
 + }
 + 
 + 
 + Datum
 + uuid_ns_dns(PG_FUNCTION_ARGS)
 + {
 +-	return special_uuid_value("ns:DNS");
 ++	return internal_uuid_create(0, NULL, "6ba7b810-9dad-11d1-80b4-00c04fd430c8", 36);
 + }
 + 
 + 
 + Datum
 + uuid_ns_url(PG_FUNCTION_ARGS)
 + {
 +-	return special_uuid_value("ns:URL");
 ++	return internal_uuid_create(0, NULL, "6ba7b811-9dad-11d1-80b4-00c04fd430c8", 36);
 + }
 + 
 + 
 + Datum
 + uuid_ns_oid(PG_FUNCTION_ARGS)
 + {
 +-	return special_uuid_value("ns:OID");
 ++	return internal_uuid_create(0, NULL, "6ba7b812-9dad-11d1-80b4-00c04fd430c8", 36);
 + }
 + 
 + 
 + 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_rc_t	rc;
 +-
 +-	rc = uuid_create(&uuid);
 +-	if (rc != UUID_RC_OK)
 +-		pguuid_complain(rc);
 +-	rc = uuid_make(uuid, mode, ns, name);
 +-	if (rc != UUID_RC_OK)
 +-		pguuid_complain(rc);
 +-	str = uuid_to_string(uuid);
 +-	rc = uuid_destroy(uuid);
 +-	if (rc != UUID_RC_OK)
 +-		pguuid_complain(rc);
 +-
 +-	return DirectFunctionCall1(uuid_in, CStringGetDatum(str));
 ++	return internal_uuid_create(0, NULL, "6ba7b814-9dad-11d1-80b4-00c04fd430c8", 36);
 + }
 + 
 + 
 + Datum
 + uuid_generate_v1(PG_FUNCTION_ARGS)
 + {
 +-	return uuid_generate_internal(UUID_MAKE_V1, NULL, NULL);
 ++	return internal_uuid_create(1, NULL, NULL, 0);
 + }
 + 
 + 
 + 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_rc_t	rc;
 +-
 +-	rc = uuid_create(&ns_uuid);
 +-	if (rc != UUID_RC_OK)
 +-		pguuid_complain(rc);
 +-	string_to_uuid(DatumGetCString(DirectFunctionCall1(uuid_out, UUIDPGetDatum(ns))),
 +-				   ns_uuid);
 +-
 +-	result = uuid_generate_internal(mode,
 +-									ns_uuid,
 +-									text_to_cstring(name));
 +-
 +-	rc = uuid_destroy(ns_uuid);
 +-	if (rc != UUID_RC_OK)
 +-		pguuid_complain(rc);
 ++	char buf[20];
 + 
 +-	return result;
 ++	sprintf(buf, "-%04x-%04x%08lx",
 ++		(unsigned)((arc4random() & 0x3FFF) | 0x8000),
 ++		/* set IEEE802 multicast and local-admin bits */
 ++		(unsigned)((arc4random() & 0xffff) | 0x0300),
 ++		(unsigned long) arc4random());
 ++		
 ++	return internal_uuid_create(1, NULL, buf, 18);
 + }
 + 
 + 
 +@@ -230,14 +233,15 @@
 + 	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);
 ++	return internal_uuid_create(3, (unsigned char *)ns,
 ++				VARDATA(name), VARSIZE(name) - VARHDRSZ);
 + }
 + 
 + 
 + Datum
 + uuid_generate_v4(PG_FUNCTION_ARGS)
 + {
 +-	return uuid_generate_internal(UUID_MAKE_V4, NULL, NULL);
 ++	return internal_uuid_create(4, NULL, NULL, 0);
 + }
 + 
 + 
 +@@ -247,5 +251,6 @@
 + 	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);
 ++	return internal_uuid_create(5, (unsigned char *)ns,
 ++				VARDATA(name), VARSIZE(name) - VARHDRSZ);
 + }
 
 Modified: head/databases/postgresql90-server/pkg-plist-contrib
 ==============================================================================
 --- head/databases/postgresql90-server/pkg-plist-contrib	Thu Mar 20 13:16:44 2014	(r348684)
 +++ head/databases/postgresql90-server/pkg-plist-contrib	Thu Mar 20 13:43:15 2014	(r348685)
 @@ -43,7 +43,7 @@ lib/postgresql/test_parser.so
  lib/postgresql/timetravel.so
  lib/postgresql/tsearch2.so
  lib/postgresql/unaccent.so
 -%%OSSP%%lib/postgresql/uuid-ossp.so
 +lib/postgresql/uuid-ossp.so
  %%DOCSDIR%%/README-contrib
  %%DOCSDIR%%/contrib/README
  %%DOCSDIR%%/contrib/autoinc.example
 @@ -88,8 +88,8 @@ share/postgresql/contrib/test_parser.sql
  share/postgresql/contrib/timetravel.sql
  share/postgresql/contrib/tsearch2.sql
  share/postgresql/contrib/unaccent.sql
 -%%OSSP%%share/postgresql/contrib/uninstall_uuid-ossp.sql
 -%%OSSP%%share/postgresql/contrib/uuid-ossp.sql
 +share/postgresql/contrib/uninstall_uuid-ossp.sql
 +share/postgresql/contrib/uuid-ossp.sql
  share/postgresql/contrib/uninstall__int.sql
  share/postgresql/contrib/uninstall_adminpack.sql
  share/postgresql/contrib/uninstall_btree_gin.sql
 
 Modified: head/databases/postgresql91-contrib/Makefile
 ==============================================================================
 --- head/databases/postgresql91-contrib/Makefile	Thu Mar 20 13:16:44 2014	(r348684)
 +++ head/databases/postgresql91-contrib/Makefile	Thu Mar 20 13:43:15 2014	(r348685)
 @@ -22,13 +22,9 @@ INSTALL_DIRS=	contrib
  
  SLAVE_ONLY=	yes
  COMPONENT=	-contrib
 -CONFIGURE_ARGS+=--with-libxslt --with-libxml --with-openssl
 +CONFIGURE_ARGS+=--with-libxslt --with-libxml --with-openssl --with-ossp-uuid
  LDFLAGS+=	${PTHREAD_LIBS} -L${PREFIX}/lib
  
 -OPTIONS_DEFINE=	OSSP_UUID
 -OSSP_UUID_DESC=	Enable / disable ossp-uuid support
 -OPTIONS_DEFAULT=	OSSP_UUID
 -
  post-install:
  	@- ${INSTALL_DATA} ${WRKSRC}/contrib/README ${STAGEDIR}${DOCSDIR}/extension/README
  
 
 Modified: head/databases/postgresql91-server/Makefile
 ==============================================================================
 --- head/databases/postgresql91-server/Makefile	Thu Mar 20 13:16:44 2014	(r348684)
 +++ head/databases/postgresql91-server/Makefile	Thu Mar 20 13:43:15 2014	(r348685)
 @@ -2,7 +2,7 @@
  # $FreeBSD$
  
  PORTNAME?=	postgresql
 -DISTVERSION?=	9.1.12
 +DISTVERSION?=	9.1.13
  PORTREVISION?=	0
  CATEGORIES?=	databases
  MASTER_SITES=	PGSQL
 
 Modified: head/databases/postgresql91-server/distinfo
 ==============================================================================
 --- head/databases/postgresql91-server/distinfo	Thu Mar 20 13:16:44 2014	(r348684)
 +++ head/databases/postgresql91-server/distinfo	Thu Mar 20 13:43:15 2014	(r348685)
 @@ -1,4 +1,4 @@
 -SHA256 (postgresql/postgresql-9.1.12.tar.bz2) = 0b267ebab5feb39ad6ef945b9588787886e7f7e5284467921d18cc7b76bcb383
 -SIZE (postgresql/postgresql-9.1.12.tar.bz2) = 15638909
 +SHA256 (postgresql/postgresql-9.1.13.tar.bz2) = 20f8aa5dfcb47688ca6b6c41340cac61712d9cf87c34d58b0a75bb2f85d89b7f
 +SIZE (postgresql/postgresql-9.1.13.tar.bz2) = 15652239
  SHA256 (postgresql/pg-923-icu-2014-02-10.diff.gz) = c7ca70433c819cea5fef0a9448da236b175d910177b18a8cb2ed9012a949aeb1
  SIZE (postgresql/pg-923-icu-2014-02-10.diff.gz) = 4440
 
 Added: head/databases/postgresql91-server/files/patch-contrib-uuid
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ head/databases/postgresql91-server/files/patch-contrib-uuid	Thu Mar 20 13:43:15 2014	(r348685)
 @@ -0,0 +1,393 @@
 +--- contrib/uuid-ossp/Makefile.orig	2014-03-17 20:36:46.000000000 +0100
 ++++ contrib/uuid-ossp/Makefile	2014-03-19 21:19:28.000000000 +0100
 +@@ -1,12 +1,14 @@
 + # contrib/uuid-ossp/Makefile
 ++# modified using http://pgfoundry.org/projects/uuid-freebsd/
 ++# to actually not use ossp, since uuid methods are all
 ++# built in into libc in FreeBSD /girgen@
 + 
 + MODULE_big = uuid-ossp
 + OBJS = uuid-ossp.o
 + 
 + EXTENSION = uuid-ossp
 + DATA = uuid-ossp--1.0.sql uuid-ossp--unpackaged--1.0.sql
 +-
 +-SHLIB_LINK += $(OSSP_UUID_LIBS)
 ++SHLIB_LINK = -lmd
 + 
 + ifdef USE_PGXS
 + PG_CONFIG = pg_config
 +--- contrib/uuid-ossp/uuid-ossp--1.0.sql.orig	2014-03-17 20:36:46.000000000 +0100
 ++++ contrib/uuid-ossp/uuid-ossp--1.0.sql	2014-03-19 21:19:28.000000000 +0100
 +@@ -1,5 +1,12 @@
 + /* contrib/uuid-ossp/uuid-ossp--1.0.sql */
 + 
 ++-- this module is modified by girgen@ for FreeBSD using
 ++-- http://pgfoundry.org/projects/uuid-freebsd/
 ++-- based on the work of Andrew Gierth.
 ++-- The name is still uuid-ossp to maintain verbatim compatibility
 ++-- with the original ossp based module, although the built-in libc
 ++-- routines are actually used instead, not ossp.
 ++
 + -- complain if script is sourced in psql, rather than via CREATE EXTENSION
 + \echo Use '''CREATE EXTENSION "uuid-ossp"''' to load this file. \quit
 + 
 +--- contrib/uuid-ossp/uuid-ossp.c.orig	2014-03-17 20:36:46.000000000 +0100
 ++++ contrib/uuid-ossp/uuid-ossp.c	2014-03-19 21:20:56.000000000 +0100
 +@@ -6,6 +6,10 @@
 +  *
 +  * contrib/uuid-ossp/uuid-ossp.c
 +  *
 ++ * Modified to use FreeBSD's built in uuid instead of ossp:
 ++ * Copyright (c) 2009 Andrew Gierth
 ++ *
 ++ * URL: http://pgfoundry.org/projects/uuid-freebsd
 +  *-------------------------------------------------------------------------
 +  */
 + 
 +@@ -14,27 +18,14 @@
 + #include "utils/builtins.h"
 + #include "utils/uuid.h"
 + 
 +-/*
 +- * There's some confusion over the location of the uuid.h header file.
 +- * On Debian, it's installed as ossp/uuid.h, while on Fedora, or if you
 +- * install ossp-uuid from a tarball, it's installed as uuid.h. Don't know
 +- * what other systems do.
 +- */
 +-#ifdef HAVE_OSSP_UUID_H
 +-#include <ossp/uuid.h>
 +-#else
 +-#ifdef HAVE_UUID_H
 +-#include <uuid.h>
 +-#else
 +-#error OSSP uuid.h not found
 +-#endif
 +-#endif
 +-
 +-/* better both be 16 */
 +-#if (UUID_LEN != UUID_LEN_BIN)
 +-#error UUID length mismatch
 +-#endif
 ++/* OS has a uuid_hash that conflicts with ours; kill it*/
 ++/* explicit path since we do _not_ want to get any other version */
 ++#define uuid_hash freebsd_uuid_hash
 ++#include "/usr/include/uuid.h"
 ++#undef uuid_hash
 + 
 ++#include <md5.h>
 ++#include <sha.h>
 + 
 + PG_MODULE_MAGIC;
 + 
 +@@ -64,163 +55,175 @@
 + PG_FUNCTION_INFO_V1(uuid_generate_v4);
 + PG_FUNCTION_INFO_V1(uuid_generate_v5);
 + 
 +-static void
 +-pguuid_complain(uuid_rc_t rc)
 +-{
 +-	char	   *err = uuid_error(rc);
 +-
 +-	if (err != NULL)
 +-		ereport(ERROR,
 +-				(errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
 +-				 errmsg("OSSP uuid library failure: %s", err)));
 +-	else
 +-		ereport(ERROR,
 +-				(errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
 +-				 errmsg("OSSP uuid library failure: error code %d", rc)));
 +-}
 ++/* we assume that the string representation is portable and that the
 ++ * native binary representation might not be. But for *ns, we assume
 ++ * that pg's internal storage of uuids is the simple byte-oriented
 
 *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
 _______________________________________________
 svn-ports-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-ports-all
 To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
 
>Unformatted:
