On Tue, Mar 22, 2011 at 06:25:04PM +0700, Dan Kennedy scratched on the wall:
> SQLite assumes that the result of each expression in the WHERE > clause depends only on its inputs. If the input arguments are > the same, the output should be do. Since random() has no inputs, > SQLite figures that it must always return the same value. To what degree? And expression like "...WHERE 20 <= (random()%100)" has no "inputs" other than constants, but is still evaluated once per row. Or is it just raw functions and column references, and not the expression as a whole? Either way, it would seem a function with no inputs should always be considered non-constant. Unless someone writes a function that boils down to func(){return VALUE;}, it is very likely the function references some external value or state, and is unlikely to return the same value. I realize that most systems will only evaluates random() once, even in a larger expression, but I've always found it nice that SQLite did not in expressions like the one I gave. It makes it much easier to sample data. -j -- Jay A. Kreibich < J A Y @ K R E I B I.C H > "Intelligence is like underwear: it is important that you have it, but showing it to the wrong people has the tendency to make them feel uncomfortable." -- Angela Johnson _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users