Sat Jul 2 01:37:17 PDT 2005
- Previous message: [Slony1-general] PATCH: autoconf not run for slony-1.1.0, so make rpm fails
- Next message: [Slony1-general] Bug in tools/psql_replication_check.pl
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: [Slony1-general] PATCH: autoconf not run for slony-1.1.0, so make rpm fails
- Next message: [Slony1-general] Bug in tools/psql_replication_check.pl
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Slony1-general mailing list