Re: OT: using column in an interval

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: OT: using column in an interval
Дата
Msg-id 12667.1143243718@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: OT: using column in an interval  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Список pgsql-admin
Stephan Szabo <sszabo@megazone.bigpanda.com> writes:
> On Thu, 23 Mar 2006, Bradley Kieser wrote:
>> last_backup: timestamp
>> backup_unit: integer - Represents day, week, quarter, annual, etc. The
>> text is stored in backup_code (e.g. 'days', 'months')
>> backup_period: integer - Represents the skip factor.

> CAST( backup_period || ' ' || backup_code AS interval) should give you an
> interval. If the units were constant, I'd say that using integer *
> interval is a better idea, but I think you'd need a function that say took
> backup_unit and gave back an interval of 1 <unit> to make that work, but
> that would possibly be cleaner overall.

This really seems like a case of a poorly chosen representation.  Why
not just have the backup interval as an interval column, ie

last_backup: timestamptz (not timestamp, btw)
backup_interval: interval, can be eg '3 days' or '1 month' or whatever.

Then you can do

WHERE last_backup + backup_interval <= current_timestamp

            regards, tom lane

В списке pgsql-admin по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: Continuous On-line Backups
Следующее
От: "Sriram Dandapani"
Дата:
Сообщение: WAL file naming convention