Skip site navigation (1) Skip section navigation (2)

Re: implement query_start for pg_stat_activity

From: Neil Conway <neilc(at)samurai(dot)com>
To: PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: implement query_start for pg_stat_activity
Date: 2003-02-19 20:45:00
Message-ID: 1045687500.585.413.camel@tokyo (view raw, whole thread or download thread mbox)
Thread:
Lists: pgsql-patches
On Wed, 2003-02-19 at 00:27, Neil Conway wrote:
> This patch implements the TODO item
> 
>     - Add start time to pg_stat_activity

I've attached a revised version of the patch with the following changes:

- use longer function names, as suggested by Tom

- (unrelated) replace some instances where snprintf() was called with a
constant buffer size with sizeof

- documentation improvements

- update regression tests

- change the method of finding the current date & time -- it's still an
ugly hack, although arguably less so. Now we do:

AbsoluteTime sec;
int usec;

sec = GetCurrentAbsoluteTimeUsec(&usec);

/* when displaying the time */
Timestamp result;

#ifdef HAVE_INT64_TIMESTAMP
result = (((sec - ((date2j(2000, 1, 1) - date2j(1970, 1, 1)) * 86400))
		   * INT64CONST(1000000)) + usec);
#else
result = (sec + (usec * 1.0e-6) - ((date2j(2000, 1, 1) -
				date2j(1970, 1, 1)) * 86400));
#endif

which is the same method now() uses internally.

Cheers,

Neil
-- 
Neil Conway <neilc(at)samurai(dot)com> || PGP Key ID: DB3C29FC



Attachment: stat_activity_start-2.patch
Description: text/x-patch (42.9 KB)

In response to

Responses

pgsql-patches by date

Next:From: Bruce MomjianDate: 2003-02-19 21:37:50
Subject: Re: pg_avd
Previous:From: Jeroen HabetsDate: 2003-02-19 17:18:16
Subject: Patch AbstractJdbc1Statement.setBoolean support BIT and INTEGER columns

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group