OSSP CVS Repository

ossp - Difference in ossp-pkg/uuid/pgsql/uuid.c versions 1.3 and 1.4
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/uuid/pgsql/uuid.c 1.3 -> 1.4

--- uuid.c       2006/02/07 08:19:15     1.3
+++ uuid.c       2006/05/11 18:32:07     1.4
@@ -39,10 +39,11 @@
 /*  PostgreSQL (part 2/2) headers */
 #include "fmgr.h"
 #include "lib/stringinfo.h"
+#include "access/hash.h"
 
 /* internal UUID datum data structure */
 typedef struct {
-    char uuid_bin[UUID_LEN_BIN];
+    unsigned char uuid_bin[UUID_LEN_BIN];
 } uuid_datum_t;
 
 /* forward declarations */
@@ -50,9 +51,15 @@
 Datum pg_uuid_out    (PG_FUNCTION_ARGS);
 Datum pg_uuid_recv   (PG_FUNCTION_ARGS);
 Datum pg_uuid_send   (PG_FUNCTION_ARGS);
+Datum pg_uuid_hash   (PG_FUNCTION_ARGS);
 Datum pg_uuid_make   (PG_FUNCTION_ARGS);
 Datum pg_uuid_eq     (PG_FUNCTION_ARGS);
 Datum pg_uuid_ne     (PG_FUNCTION_ARGS);
+Datum pg_uuid_lt     (PG_FUNCTION_ARGS);
+Datum pg_uuid_gt     (PG_FUNCTION_ARGS);
+Datum pg_uuid_le     (PG_FUNCTION_ARGS);
+Datum pg_uuid_ge     (PG_FUNCTION_ARGS);
+Datum pg_uuid_cmp    (PG_FUNCTION_ARGS);
 
 /* API function: uuid_in */
 PG_FUNCTION_INFO_V1(pg_uuid_in);
@@ -323,6 +330,23 @@
     PG_RETURN_POINTER(uuid_datum);
 }
 
+/* API function: uuid_hash */
+PG_FUNCTION_INFO_V1(pg_uuid_hash);
+Datum pg_uuid_hash(PG_FUNCTION_ARGS)
+{
+    uuid_datum_t *uuid_datum;
+
+    /* sanity check input argument */
+    if ((uuid_datum = (uuid_datum_t *)PG_GETARG_POINTER(0)) == NULL) {
+        ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
+                errmsg("invalid UUID datum argument")));
+        PG_RETURN_NULL();
+    }
+
+    /* return hash value of the UUID */
+    PG_RETURN_INT32(hash_any(uuid_datum->uuid_bin, sizeof(uuid_datum->uuid_bin)));
+}
+
 /* INTERNAL function: _uuid_cmp */
 static int _uuid_cmp(PG_FUNCTION_ARGS)
 {
@@ -407,3 +431,53 @@
     PG_RETURN_BOOL(rc != 0);
 }
 
+/* API function: uuid_lt */
+PG_FUNCTION_INFO_V1(pg_uuid_lt);
+Datum pg_uuid_lt(PG_FUNCTION_ARGS)
+{
+    int rc;
+
+    rc = _uuid_cmp(fcinfo);
+    PG_RETURN_BOOL(rc == -1);
+}
+
+/* API function: uuid_gt */
+PG_FUNCTION_INFO_V1(pg_uuid_gt);
+Datum pg_uuid_gt(PG_FUNCTION_ARGS)
+{
+    int rc;
+
+    rc = _uuid_cmp(fcinfo);
+    PG_RETURN_BOOL(rc == 1);
+}
+
+/* API function: uuid_le */
+PG_FUNCTION_INFO_V1(pg_uuid_le);
+Datum pg_uuid_le(PG_FUNCTION_ARGS)
+{
+    int rc;
+
+    rc = _uuid_cmp(fcinfo);
+    PG_RETURN_BOOL(rc < 1);
+}
+
+/* API function: uuid_ge */
+PG_FUNCTION_INFO_V1(pg_uuid_ge);
+Datum pg_uuid_ge(PG_FUNCTION_ARGS)
+{
+    int rc;
+
+    rc = _uuid_cmp(fcinfo);
+    PG_RETURN_BOOL(rc > -1);
+}
+
+/* API function: uuid_cmp */
+PG_FUNCTION_INFO_V1(pg_uuid_cmp);
+Datum pg_uuid_cmp(PG_FUNCTION_ARGS)
+{
+    int rc;
+
+    rc = _uuid_cmp(fcinfo);
+    PG_RETURN_INT32(rc);
+}
+

CVSTrac 2.0.1