Subject | Re: [firebird-support] Re: Making evaluation of UDFs constant across a query |
---|---|
Author | Geoff Worboys |
Post date | 2011-04-05T08:47:05Z |
Paul Vinkenoog wrote:
the special case of literal 'now' it is certainly surprising.
I noticed it while writing a stored procedure to do some
performance testing. eg:
A = TIMESTAMP 'now';
-- do some time consuming stuff.
B = TIMESTAMP 'now';
From that I got the unexpected result of: (B - A) == 0;
(Sort of like using CURRENT_TIMESTAMP in this sort of situation
but the value of TIMESTAMP 'now' is slightly different to
CURRENT_TIMESTAMP too.)
When I changed the code to
A = CAST('now' AS TIMESTAMP);
-- do some time consuming stuff.
B = CAST('now' AS TIMESTAMP);
I got the expected result of (B > A).
[...]
anyone had any explanation for the behaviour.
I was working with FB v2.5 when I saw this, but I imagine the
problem may exist on v2.1 too.
--
Geoff Worboys
Telesis Computing
> That very surprising. timestamp '<string>' is supposed to beI imagine it must be the same thing for most literals, but
> just shorthand syntax for cast('<string>' as timestamp), so
> if the result differs, that's rather alarming.
the special case of literal 'now' it is certainly surprising.
I noticed it while writing a stored procedure to do some
performance testing. eg:
A = TIMESTAMP 'now';
-- do some time consuming stuff.
B = TIMESTAMP 'now';
From that I got the unexpected result of: (B - A) == 0;
(Sort of like using CURRENT_TIMESTAMP in this sort of situation
but the value of TIMESTAMP 'now' is slightly different to
CURRENT_TIMESTAMP too.)
When I changed the code to
A = CAST('now' AS TIMESTAMP);
-- do some time consuming stuff.
B = CAST('now' AS TIMESTAMP);
I got the expected result of (B > A).
[...]
> I'd definitely call this a bug, but maybe someone can explainSeems buggish to me. But thought I'd bump the thread to see if
> why it "should be" this way?
anyone had any explanation for the behaviour.
I was working with FB v2.5 when I saw this, but I imagine the
problem may exist on v2.1 too.
--
Geoff Worboys
Telesis Computing