On Sat, 14 Sep 2013 17:19:22 +0400
Yuriy Kaminskiy <[email protected]> wrote:

> > Notwithstanding the timezone you want to use, 
> > 
> > explain select * 
> >           from entry 
> >          where bankdate >= date('now', 'start of month') 
> >            and bankdate < date('now', 'start of month', '-1 day');
> > 
> > will generate the following code:
> 
> And there are another pitfall in this query: date('now') is *RACY*.
> That is, if you execute this query *exactly* at midnight at month
> boundary, first and second DATE() invocation may refer to *different*
> months.
> 
> And if your query return several rows, and there will be month
> boundary between sqlite3_step(), your query also can return data from
> two month.

That's a disappointment, and nonstandard behavior.  It means SELECT is
not atomic.  

The notion of "now" should not change while the query is being
processed.  "date('now', 'start of month')" should return the same
value no matter how many times it appears it the query, and no matter
how long it takes to process the results.  

--jkl

_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to