Code

RRTimeslice: added a cast to timestamp.
[postrr.git] / src / rrtimeslice.c
index a91a9de95981a1fa840e29d6630a435b74961dba..7207dea04bdab2a0414360197209bd7d4a253165 100644 (file)
@@ -207,6 +207,7 @@ PG_FUNCTION_INFO_V1(rrtimeslice_typmodin);
 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);
@@ -472,6 +473,23 @@ rrtimeslice_to_rrtimeslice(PG_FUNCTION_ARGS)
        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)
 {