Re: how to add seconds to a TimestampTz

From: "Sailesh Krishnamurthy" <skrishnamurthy(at)aminsight(dot)com>
To: "'Alvaro Herrera'" <alvherre(at)commandprompt(dot)com>, "'Hackers'" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: how to add seconds to a TimestampTz
Date: 2007-03-15 02:21:29
Message-ID: 003001c766a9$c3f1ac10$8a01a8c0@plum
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

If you read the autovacuum_naptime into an Interval object once, why can't
you just use timestamptz_pl_interval ? You won't be using the interval
input/output repeatedly surely.

Regards
Sailesh

--
Sailesh Krishnamurthy
Amalgamated Insight
[W] (650) 242-3503
[C] (650) 804-6585

-----Original Message-----
From: pgsql-hackers-owner(at)postgresql(dot)org
[mailto:pgsql-hackers-owner(at)postgresql(dot)org] On Behalf Of Alvaro Herrera
Sent: Wednesday, March 14, 2007 3:46 PM
To: Hackers
Subject: [HACKERS] how to add seconds to a TimestampTz

Is there a better way than going to time_t and back? I am currently
using this:

db->next_worker =
time_t_to_timestamptz(timestamptz_to_time_t(current_time) +
autovacuum_naptime);

(db->next_worker is a TimestampTz, as is current_time.
autovacuum_naptime is integer for a number of seconds)

but it doesn't seem clean, and the comments in the functions more or
less say that their use is discouraged.

I saw about doing it via the interval input/output but that's an awful
lot of work ...

Is this the first time this is going to be done in the backend?

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2007-03-15 04:58:30 Re: how to add seconds to a TimestampTz
Previous Message Trent Shipley 2007-03-15 01:12:22 Re: My honours project - databases using dynamically attached entity-properties