Subject | Re: [firebird-support] Re: Making evaluation of UDFs constant across a query |
---|---|
Author | Michael Ludwig |
Post date | 2011-03-21T22:26:36Z |
Mike Pomraning schrieb am 21.03.2011 um 16:25 (-0500):
demonstrates the unequality of the three expressions for me:
set count on;
with abc as (
select
current_timestamp as a,
timestamp 'now' as b,
cast( 'now' as timestamp ) as c
from utable as t1 cross join utable as t2 ) -- 20 * 20 = 400 rows
select * from abc where a <> b or a <> c;
Most of the times, everything's equal, so the result set has 0 rows.
But sometimes not, I get a result set of 83, 156, 235, 336 or 400 rows.
Sometimes B differs, sometimes C differs.
--
Michael Ludwig
> On Mon, Mar 21, 2011 at 2:08 PM, Michael Ludwig <milu71@...> wrote:Hi, FB 2.5 here.
> > select
> > current_timestamp,
> > cast( 'now' as timestamp )
> > from rdb$database;
> >
> > Both values are always identical, as I thought.
>
> Not always, at least under 2.1 for me.
> I find CURRENT_TIMESTAMP is constant across a query, TIMESTAMP 'now'I guess you're right. Here's another query (without sleep) that
> is constant across a query but not always equal to CURRENT_TIMESTAMP,
> and CAST('now' ...) is evaluated anew for every row.
demonstrates the unequality of the three expressions for me:
set count on;
with abc as (
select
current_timestamp as a,
timestamp 'now' as b,
cast( 'now' as timestamp ) as c
from utable as t1 cross join utable as t2 ) -- 20 * 20 = 400 rows
select * from abc where a <> b or a <> c;
Most of the times, everything's equal, so the result set has 0 rows.
But sometimes not, I get a result set of 83, 156, 235, 336 or 400 rows.
Sometimes B differs, sometimes C differs.
--
Michael Ludwig