On Thu, 12 Dec 2002 04:56 pm, Peter Nixon wrote: > Hi Guys > > I thought someone might find this usefull. I use posgres and freeradius > with modified queries to use the extended VSA start and stop times of a > session to save EVER doing an update on your database (everything is an > insert). This allows me to scale to approximately 500 times more accounting > requests per DB than I would otherwise be able to do. However there is a > nasty problem that when a cisco loses ntp time sync it starts outputting > the datetime with a fullstop "." in front to specifiy that the time may be > wrong. This then means that inserts will fail as the data is no longer in > valid date format. This function strips the fullstop. > > /* > * --- Peter Nixon [ [EMAIL PROTECTED] ] > * Remove . from the start of time fields (routers that have lost ntp > timesync temporarily) > * * Used as: > * insert int mytable values (strip_dot('.16:46:02.356 EET Wed Dec 11 > 2002')); > */ > > CREATE OR REPLACE function strip_dot (text) returns text as ' > my $datetime = $_[0]; > $datetime =~ s/^\\.*//; > return $datetime; > ' language 'plperl';
Come to think of it, the following is even more useful :-) CREATE OR REPLACE function strip_dot (text) returns timestamp as ' my $datetime = $_[0]; $datetime =~ s/^\\.*//; return $datetime; ' language 'plperl'; -- Peter Nixon http://www.peternixon.net/ PGP Key: http://www.peternixon.net/public.asc - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html