Tim Goodaire tgoodair
Tue Jul 5 16:08:25 PDT 2005
On Fri, Jul 01, 2005 at 05:37:19PM -0700, Ian Burrell wrote:
> There is a bug in the sample view in the psql_replication_check.pl. 
> It calculates the age incorrectly, returning the minutes part of the
> interval instead of total number of minutes.
> 
> The sample is:
> 
> CREATE VIEW replication_status AS
> SELECT customer_name AS object_name, 
> transaction_date, 
> date_part('minutes'::text, now() - transaction_date) AS age
> FROM customer_orders
> ORDER BY id DESC
> LIMIT 1;
> 
> SELECT  '2005-07-01 07:20:00'::timestamp - '2005-07-01 04:10'
>  ?column?
> ----------
>  03:10:00
> 
> SELECT date_part('minutes', '2005-07-01 07:20:00'::timestamp -
> '2005-07-01 04:10');
>  date_part
> -----------
>         10
> 
> Instead of returning the total length (190 minutes), it gives the 10
> minutes of 3 hours 10 minutes.
> 
> The right solution is use extract the epoch, the length in seconds,
> and divide by 60.
> 
> SELECT date_part('epoch', '2005-07-01 07:20:00'::timestamp -
> '2005-07-01 04:10') / 60 ;
>  ?column?
> ----------
>       190
> 
> For the example it shoud be:
> 
> date_part('epoch'::text, now() - transaction_date) / 60 AS age
> 
>  - Ian
> _______________________________________________
> Slony1-general mailing list
> Slony1-general at gborg.postgresql.org
> http://gborg.postgresql.org/mailman/listinfo/slony1-general

Right. I fixed that in the version that we're using here but forgot to
see about getting it fixed in slony CVS.


Thanks,
Tim

-- 
Tim Goodaire    416-673-4126    tgoodair at ca.afilias.info
Database Administrator, Afilias Canada Corp.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://gborg.postgresql.org/pipermail/slony1-general/attachments/20050705/512eb7b0/attachment.bin


More information about the Slony1-general mailing list