pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Unexpected Statement Caching with CURRENT_TIMESTAMP
3+ messages / 3 participants
[nested] [flat]

* Unexpected Statement Caching with CURRENT_TIMESTAMP
@ 2006-08-11 00:37  Nicholas E. Wakefield <nwakefield@KineticNetworks.com>
  0 siblings, 2 replies; 3+ messages in thread

From: Nicholas E. Wakefield @ 2006-08-11 00:37 UTC (permalink / raw)
  To: pgsql-jdbc

I'm executing 'SELECT CURRENT_TIMESTAMP' from a statement object with
auto commit off and prepare threshold set to 1. I'm finding that the
result comes back the same for after multiple calls and instantiations
of the statement object(The same happens for a prepared statement).
However this does not occur when I perform a commit before or after
every call.

Is this expected behaviour?



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Unexpected Statement Caching with CURRENT_TIMESTAMP
@ 2006-08-11 01:05  Dave Cramer <pg@fastcrypt.com>
  parent: Nicholas E. Wakefield <nwakefield@KineticNetworks.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Dave Cramer @ 2006-08-11 01:05 UTC (permalink / raw)
  To: Nicholas E. Wakefield <nwakefield@KineticNetworks.com>; +Cc: pgsql-jdbc

Nicholas,

Yes this is expected behaviour. The time is the time when you started  
the transaction. It has nothing to do with JDBC.

Dave
On 10-Aug-06, at 8:37 PM, Nicholas E. Wakefield wrote:

> I'm executing 'SELECT CURRENT_TIMESTAMP' from a statement object with
> auto commit off and prepare threshold set to 1. I'm finding that the
> result comes back the same for after multiple calls and instantiations
> of the statement object(The same happens for a prepared statement).
> However this does not occur when I perform a commit before or after
> every call.
>
> Is this expected behaviour?
>
> ---------------------------(end of  
> broadcast)---------------------------
> TIP 6: explain analyze is your friend
>




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Unexpected Statement Caching with CURRENT_TIMESTAMP
@ 2006-08-11 08:29  Markus Schaber <schabi@logix-tt.com>
  parent: Nicholas E. Wakefield <nwakefield@KineticNetworks.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Markus Schaber @ 2006-08-11 08:29 UTC (permalink / raw)
  To: Nicholas E. Wakefield <nwakefield@KineticNetworks.com>; +Cc: pgsql-jdbc

Hi, Nicolas,

Nicholas E. Wakefield wrote:
> I'm executing 'SELECT CURRENT_TIMESTAMP' from a statement object with
> auto commit off and prepare threshold set to 1. I'm finding that the
> result comes back the same for after multiple calls and instantiations
> of the statement object(The same happens for a prepared statement).
> However this does not occur when I perform a commit before or after
> every call.
> 
> Is this expected behaviour?

Yes, it's expected, intended and documented in the PostgreSQL docs:
http://www.postgresql.org/docs/8.1/static/functions-datetime.html

SELECT timeofday(); returns a clock that advances even during
transactions. As it returns a textual representation, you may need to
cast it to a timestamp in some query contexts, though:

select timeofday(); -- returns text
select timeofday()::timestamp; -- returns timestamp - postgresql variant
select CAST(timeofday() AS timestamp) ; -- returns timestamp in sql99

HTH,
Markus
-- 
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf.     | Software Development GIS

Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2006-08-11 08:29 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-08-11 00:37 Unexpected Statement Caching with CURRENT_TIMESTAMP Nicholas E. Wakefield <nwakefield@KineticNetworks.com>
2006-08-11 01:05 ` Dave Cramer <pg@fastcrypt.com>
2006-08-11 08:29 ` Markus Schaber <schabi@logix-tt.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox