diff -cbNBdr pguuid/sql/pguuid.sql pguuid_text/sql/pguuid.sql
*** pguuid/sql/pguuid.sql	Tue Jun 10 23:22:22 2003
--- pguuid_text/sql/pguuid.sql	Thu Oct  2 13:26:22 2003
***************
*** 202,207 ****
--- 203,215 ----
  AS '$libdir/pguuid', 'util_uuid_macaddr'
  LANGUAGE 'C';
  
+ CREATE OR REPLACE FUNCTION uuid_text(uuid)
+ RETURNS text
+ STRICT
+ AS '$libdir/pguuid','util_uuid_text'
+ LANGUAGE 'C';
+ 
+ 
  -- Create cast
  CREATE CAST (uuid AS timestamp)
  WITH FUNCTION uuid_timestamp(uuid)
***************
*** 210,215 ****
--- 218,229 ----
  CREATE CAST (uuid AS macaddr)
  WITH FUNCTION uuid_macaddr(uuid)
  AS IMPLICIT;
+ 
+ CREATE CAST (uuid AS text)
+ WITH FUNCTION uuid_text(uuid)
+ AS IMPLICIT;
+ 
+ 
  --
  --	eof
  --
diff -cbNBdr pguuid/src/util_text.c pguuid_text/src/util_text.c
*** pguuid/src/util_text.c	Wed Dec 31 17:00:00 1969
--- pguuid_text/src/util_text.c	Thu Oct  2 13:24:02 2003
***************
*** 0 ****
--- 1,36 ----
+ #include <uuid.h>
+ 
+ #include <postgres.h>
+ #include <fmgr.h>
+ 
+ #include <utils/timestamp.h>
+ #include <utils/inet.h>
+ 
+ #include <time.h>
+ #include <string.h>
+ #include <sys/time.h>
+ #include <sys/types.h>
+ 
+ PG_FUNCTION_INFO_V1(util_uuid_text);
+ Datum
+ util_uuid_text(PG_FUNCTION_ARGS)
+ {
+ 	char *s;
+ 	text *result;
+ 	int len;
+ 
+ 	uuid_p val = (uuid_p) PG_GETARG_POINTER(0);
+ 
+ 	s = (char*) palloc(sizeof(char) * 36);
+ 	s[0] = '\0';
+ 	uuid_unparse(val, s);
+ 
+ 	len = strlen(s);
+ 
+ 	result = (text *) palloc(VARHDRSZ + len);
+ 	VARATT_SIZEP(result) = len + VARHDRSZ;
+ 	memcpy(VARDATA(result),s,len);
+ 	pfree(s);
+ 
+ 	PG_RETURN_TEXT_P(result);
+ }