On Fri, Mar 9, 2012 at 12:04 PM, Max Vlasov <max.vla...@gmail.com> wrote:

> So looks on the way from 3.6.10 to 3.7.10 something was really fixed
> related to this issue, but seems like not everything.
>
>
Don't know whether this is serious or a problem at all, but I spent some
time with such queries and narrowed the random part to
(the table still the same, auto-incremented id from 1 to 1000)

Select  id,  (abs(random() % 1000)) as rndid
from TestTable
where id <= rndid
order by id desc
limit 5

which in 3.7.10 returns results like

id  / rndid
"442"    "84"
"441"    "134"
"440"    "135"
"439"    "805"
"438"    "971"

Looks like rndid is evaluated only once for comparison, but produces
different random-originated results for output.I remember there was a
discussion about it and even different versions behave differently. I think
that either rndid here should contain the value evaluated for where or
comparison should be performed for every row separately

What also puzzles me is that another variation of the original query

Select
  id,  (abs(random() % (ToValue-FromValue + 1))) as actualrndid
from
  TestTable
left join
  (Select  1 as FromValue, 1000 as ToValue) StatTable
where id<=actualrndid
order by id desc
limit 10

...always returns for left (id) column random values from 800 to 900 (no
other ranges), but if I change ToValue-FromValue to 999 (no other
modifications to the query), id column starts returning values from
different part of 1..1000 range (the version is still the same, 3.7.10)

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

Reply via email to