summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 230d094)
raw | patch | inline | side by side (parent: 230d094)
author | Sebastian Harl <sh@tokkee.org> | |
Thu, 3 May 2012 19:44:08 +0000 (21:44 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Thu, 3 May 2012 19:44:08 +0000 (21:44 +0200) |
src/postrr.h.in | patch | blob | history | |
src/postrr.sql.in | patch | blob | history | |
src/rrtimeslice.c | patch | blob | history |
diff --git a/src/postrr.h.in b/src/postrr.h.in
index 92025db3589fe438f457000ed41f985558e048c5..9a25d4e9f0c76375cbaab4a97c6ac85273644e2a 100644 (file)
--- a/src/postrr.h.in
+++ b/src/postrr.h.in
rrtimeslice_ge(PG_FUNCTION_ARGS);
Datum
rrtimeslice_cmp(PG_FUNCTION_ARGS);
+Datum
+rrtimeslice_hash(PG_FUNCTION_ARGS);
/*
* internal (not fmgr-callable) functions
diff --git a/src/postrr.sql.in b/src/postrr.sql.in
index ffdb3a718350859625acbef996c37a5db570c733..c2b48212784d066231cd4f7d8d27d76c81307e4a 100644 (file)
--- a/src/postrr.sql.in
+++ b/src/postrr.sql.in
AS 'postrr-@POSTRR_MAJOR_VERSION@.@POSTRR_MINOR_VERSION@', 'rrtimeslice_cmp'
LANGUAGE 'C' IMMUTABLE STRICT;
+CREATE OR REPLACE FUNCTION RRTimeslice_hash(rrtimeslice)
+ RETURNS integer
+ AS 'postrr-@POSTRR_MAJOR_VERSION@.@POSTRR_MINOR_VERSION@', 'rrtimeslice_hash'
+ LANGUAGE 'C' IMMUTABLE STRICT;
+
CREATE OPERATOR = (
LEFTARG = RRTimeslice,
RIGHTARG = RRTimeslice,
OPERATOR 5 > ,
FUNCTION 1 RRTimeslice_cmp(rrtimeslice, rrtimeslice);
+CREATE OPERATOR CLASS rrtimeslice_hash_ops
+ FOR TYPE RRTimeslice USING hash AS
+ OPERATOR 1 = ,
+ FUNCTION 1 RRTimeslice_hash(rrtimeslice);
+
CREATE TYPE CData;
CREATE OR REPLACE FUNCTION CData_validate(integer)
diff --git a/src/rrtimeslice.c b/src/rrtimeslice.c
index d34da914a53713f40e9c5589ed424209868791a7..b08662292178e979c71c1d1c9e41bcb9855d6fe8 100644 (file)
--- a/src/rrtimeslice.c
+++ b/src/rrtimeslice.c
#include <fmgr.h>
/* Postgres utilities */
+#include <access/hash.h>
#include <executor/spi.h>
#include <utils/array.h>
#include <utils/datetime.h>
PG_FUNCTION_INFO_V1(rrtimeslice_le);
PG_FUNCTION_INFO_V1(rrtimeslice_ge);
PG_FUNCTION_INFO_V1(rrtimeslice_cmp);
+PG_FUNCTION_INFO_V1(rrtimeslice_hash);
/*
* public API
PG_RETURN_INT32(rrtimeslice_cmp_internal(ts1, ts2));
} /* rrtimeslice_ge */
+Datum
+rrtimeslice_hash(PG_FUNCTION_ARGS)
+{
+ rrtimeslice_t *ts = PG_GETARG_RRTIMESLICE_P(0);
+ return hash_uint32(ts->seq);
+} /* rrtimeslice_hash */
+
/* vim: set tw=78 sw=4 ts=4 noexpandtab : */