On Mon, Feb 17, 2014 at 11:47 AM, Stephan Beal <sgb...@googlemail.com>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 canonical example is a now() function which returns time(NULL) (there
> was a long thread on this topic a few months back).
>
> My concrete questions:
>
> - Does such function need to make the guaranty itself or is marking it as
> SQLITE_DETERMINISTIC enough to keep sqlite from calling it twice in one
> statement?
>

The is a constraint on the function implementation, that allows SQLite to
perform certain optimizations in the generated VDBE code that would
otherwise not be valid.  So the function must guarantee that it will always
return the same values given the same inputs.


>
> - Can "within a single SQL statement" be interpreted as "within the
> lifetime of a given preparation of a given sqlite3_stmt handle" without
> distorting the truth too much, or is there a more complex definition
> involving subselects and such?
>
>
In call to the function within any subquery or trigger must return the same
value if it has the same inputs.

But the return value can change after each sqlite3_reset().

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

Reply via email to