summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2b5a368)
raw | patch | inline | side by side (parent: 2b5a368)
author | Sebastian Harl <sh@tokkee.org> | |
Wed, 9 May 2012 15:24:19 +0000 (17:24 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Wed, 9 May 2012 15:24:19 +0000 (17:24 +0200) |
src/postrr.h.in | patch | blob | history | |
src/postrr.sql.in | patch | blob | history | |
src/rrtimeslice.c | patch | blob | history | |
src/uninstall_postrr.sql | patch | blob | history |
diff --git a/src/postrr.h.in b/src/postrr.h.in
index 2d32f1cf5511a234d3eab03050b5e5a8fff7991f..bca014a9d47591294dd7dfb4702ee9dfb7c2d3ab 100644 (file)
--- a/src/postrr.h.in
+++ b/src/postrr.h.in
/* casts */
Datum
rrtimeslice_to_rrtimeslice(PG_FUNCTION_ARGS);
+Datum
+rrtimeslice_to_timestamp(PG_FUNCTION_ARGS);
/* comparison operators */
Datum
diff --git a/src/postrr.sql.in b/src/postrr.sql.in
index 8596cf8e66d3162726ba670535e77e5dfaa9d0a7..ed51ab676f2de477039986a248bcbde81c482bf8 100644 (file)
--- a/src/postrr.sql.in
+++ b/src/postrr.sql.in
WITH FUNCTION RRTimeslice(rrtimeslice, integer, boolean)
AS IMPLICIT;
+CREATE OR REPLACE FUNCTION Tstamp(rrtimeslice)
+ RETURNS timestamp
+ AS 'postrr-@POSTRR_MAJOR_VERSION@.@POSTRR_MINOR_VERSION@', 'rrtimeslice_to_timestamp'
+ LANGUAGE 'C' IMMUTABLE STRICT;
+
+CREATE CAST (rrtimeslice AS timestamp)
+ WITH FUNCTION Tstamp(rrtimeslice);
+ -- EXPLICIT
+
CREATE OR REPLACE FUNCTION rrtimeslice_seq_eq(rrtimeslice, rrtimeslice)
RETURNS boolean
AS 'postrr-@POSTRR_MAJOR_VERSION@.@POSTRR_MINOR_VERSION@', 'rrtimeslice_seq_eq'
diff --git a/src/rrtimeslice.c b/src/rrtimeslice.c
index a91a9de95981a1fa840e29d6630a435b74961dba..7207dea04bdab2a0414360197209bd7d4a253165 100644 (file)
--- a/src/rrtimeslice.c
+++ b/src/rrtimeslice.c
PG_FUNCTION_INFO_V1(rrtimeslice_typmodout);
PG_FUNCTION_INFO_V1(rrtimeslice_to_rrtimeslice);
+PG_FUNCTION_INFO_V1(rrtimeslice_to_timestamp);
PG_FUNCTION_INFO_V1(rrtimeslice_seq_eq);
PG_FUNCTION_INFO_V1(rrtimeslice_seq_ne);
PG_RETURN_RRTIMESLICE_P(tslice);
} /* rrtimeslice_to_rrtimeslice */
+Datum
+rrtimeslice_to_timestamp(PG_FUNCTION_ARGS)
+{
+ rrtimeslice_t *tslice;
+
+ if (PG_NARGS() != 1)
+ ereport(ERROR, (
+ errmsg("rrtimeslice_to_timestamp() "
+ "expects one argument"),
+ errhint("Usage: rrtimeslice_to_timestamp"
+ "(rrtimeslice)")
+ ));
+
+ tslice = PG_GETARG_RRTIMESLICE_P(0);
+ PG_RETURN_TIMESTAMP(tslice->tstamp);
+} /* rrtimeslice_to_timestamp */
+
int
rrtimeslice_seq_cmp_internal(rrtimeslice_t *ts1, rrtimeslice_t *ts2)
{
index ce5e945daccdc9bd1227cd2a80941540ba3af079..e670f27cdcd9f1cf47b4ccd4ddf0f60547ac12ef 100644 (file)
--- a/src/uninstall_postrr.sql
+++ b/src/uninstall_postrr.sql
DROP CAST IF EXISTS (rrtimeslice AS rrtimeslice);
DROP FUNCTION IF EXISTS RRTimeslice(rrtimeslice, integer, boolean);
+DROP CAST IF EXISTS (rrtimeslice AS timestamp);
+DROP FUNCTION IF EXISTS Tstamp(rrtimeslice);
DROP TYPE RRTimeslice CASCADE;
DROP FUNCTION IF EXISTS RRTimeslice_typmodin(cstring[]);
DROP FUNCTION IF EXISTS RRTimeslice_typmodout(integer);