dbTalk Databases Forums  

[BUGS] BUG #2198: Now returns always same date and time during a session

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] BUG #2198: Now returns always same date and time during a session in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Jacques Gollion
 
Posts: n/a

Default [BUGS] BUG #2198: Now returns always same date and time during a session - 01-23-2006 , 10:59 AM







The following bug has been logged online:

Bug reference: 2198
Logged by: Jacques Gollion
Email address: jgollion (AT) sambatechnologies (DOT) com
PostgreSQL version: 8.1.2
Operating system: Windows 2000
Description: Now returns always same date and time during a session
Details:

The following functions returns the first time the right date and time but
when called at several date and time returns the date that was returned at
the first call. To get again the right date, it is necessary do disconnect
and reconnect.

================================================== =
CREATE OR REPLACE FUNCTION getserverdate(szdatetime_p "varchar")
RETURNS "varchar" AS
$BODY$
DECLARE tNow_l timestamp ;
DECLARE szdatetime_l VARCHAR(128);

begin
szdatetime_l := '-1';
tNow_l := Now();
RAISE LOG ' tNow_l = %', tNow_l;
szdatetime_l := TO_CHAR(tNow_l,'YYYYMMDDHH24MISS');
RAISE LOG ' szdatetime_l = %', szdatetime_l;
return szdatetime_l;

END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION getserverdate(szdatetime_p "varchar") OWNER TO postgres;
GRANT EXECUTE ON FUNCTION getserverdate(szdatetime_p "varchar") TO public;
GRANT EXECUTE ON FUNCTION getserverdate(szdatetime_p "varchar") TO
postgres;
GRANT EXECUTE ON FUNCTION getserverdate(szdatetime_p "varchar") TO client;
GRANT EXECUTE ON FUNCTION getserverdate(szdatetime_p "varchar") TO batch;

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] BUG #2198: Now returns always same date and time during a session - 01-23-2006 , 11:29 AM






"Jacques Gollion" <jgollion (AT) sambatechnologies (DOT) com> writes:
Quote:
The following functions returns the first time the right date and time but
when called at several date and time returns the date that was returned at
the first call.
Please read
http://www.postgresql.org/docs/8.1/s...TETIME-CURRENT

Quote:
To get again the right date, it is necessary do disconnect and reconnect.
A fresh transaction is sufficient.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend


Reply With Quote
  #3  
Old   
Michael Fuhr
 
Posts: n/a

Default Re: [BUGS] BUG #2198: Now returns always same date and time during a session - 01-23-2006 , 11:38 AM



On Mon, Jan 23, 2006 at 11:40:43AM +0000, Jacques Gollion wrote:
Quote:
The following functions returns the first time the right date and time but
when called at several date and time returns the date that was returned at
the first call.
See "Current Date/Time" in the documentation:

http://www.postgresql.org/docs/8.1/i...TETIME-CURRENT

"It is important to know that CURRENT_TIMESTAMP and related functions
return the start time of the current transaction; their values do
not change during the transaction. This is considered a feature:
the intent is to allow a single transaction to have a consistent
notion of the 'current' time, so that multiple modifications within
the same transaction bear the same time stamp."

"There is also the function timeofday() which returns the wall-clock
time and advances during transactions."

Quote:
To get again the right date, it is necessary do disconnect and reconnect.
Do you have autocommit disabled? I'd guess all of your function
calls are happening in the same transaction. You shouldn't have
to reconnect; starting a new transaction should work.

--
Michael Fuhr

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.