Simon Slavin wrote:
> On 14 Sep 2013, at 10:41pm, Yuriy Kaminskiy <yum...@gmail.com> wrote:
> 
>> ... and I'd call even that difference between CURRENT_* and *('now') rather
>> "query optimizer artifact" rather than "documented feature one can rely 
>> upon".
>> Anyway, one way or other, it is BROKEN.
> 
> I would agree with you if the labels were different.  But 'CURRENT_TIME' 
> means 'current'.  If those keywords were STATEMENT_TIME, STATEMENT_DATE and 
> STATEMENT_TIMESTAMP then that behaviour would definitely be wrong.

Wow. Are you *REALLY* arguing that
  SELECT * FROM t WHERE CURRENT_TIME <> CURRENT_TIME;
that randomly (!) returning rows any less broken than
  SELECT * FROM t WHERE 2*2 <> 4;
also randomly returning rows?

Sure, there can be several way to interpret CURRENT_* and *('now'). However,
some of them can be useful (transaction, statement), and others (step) - cannot
be. And some (sub-expression, the way it "works" currently) are purely insane.

IMO, 'now' evaluation *MUST* be consistent within statement (think about query
from OP - `... WHERE day BETWEEN date('now','start of month') AND date('now',
'start of month','+1 month')` - unless you have statement-level consistency, it
*randomly* will cover *one* or *two* months).

And there are good arguments that they *should* be consistent within transaction
(point of transaction is that you have *consistent* view of database; evaluating
CURRENT_*/'now' more than once within transaction, obviously, provide
*inconsistent* view).

And while we are talking about "procedural elements", obviously, volatile global
constants and ​impure functions are *more* from "procedural world" than from
"SQL world" (constants are expected to be constant, function from constant
arguments are expected to return same value each time, query optimizer should be
free to reorder and eliminate function calls, flatten queries, reorder joins,
etc; you cannot do that with "volatile constants" or impure functions).

PS sure, if you ask in uni's math dept, you'll find some interpretation of math
where `2*2 <> 4`; using them them in product targeted to to general public would
be insane; using them *randomly* (as it happens with CURRENT_TIME <>
CURRENT_TIME) - beyond insane.

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to