On 2014/02/17 18:47, Stephan Beal wrote:
Hi, all,
Regarding SQLITE_DETERMINISTIC:
http://www.sqlite.org/c3ref/create_function.html
does specifying that flag guaranty that sqlite3 will only call my
"deterministic" function one time during any given SQL statement, or must
my function actually guaranty that deterministic behaviour itself?
The flag is telling SQLite that your function will behave determinsitcally, i.e. it won't change the output for the same inputs
within a single query. SQLite then uses this information to "maybe" cache the output and re-use it, but there is no guarantee the
optimisation is possible within every query situation, so it is very much possible SQLite can call your function again within the
same query, you have to make your function behave deterministically if you tell SQLite that it is so - else query results can be
undefined.
The OP seems to have "tested" SQLite's determinism with adding a very indeterministic function, so what I was trying to point out is
either his function isn't behaving deterministically and/or he did not specify the flag to let SQLite know - but to your question
specifically, no the flag does not force determinism (AFAICT), it only allows the optimisation, or more specifically, NOT specifying
the flag forces SQLIte to call the function every time and not expect determinsitic results (even if your return values are constant).
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users