On Sat, Nov 23, 2013 at 5:26 AM, Pepijn Van Eeckhoudt <
[email protected]> wrote:

> Is datetime special in thuis context or will constant expression hoisting
> like this happen for any function?
>

SQLite must know that the function always gives the same output given the
same inputs.  No every function works that way.  Counterexamples include
random() and last_insert_rowid().  But most built-in functions are
factorable in the same way that datetime() is.

Currently there is no API to designate an application-defined function as
being "constant" in the sense that it always generates the same output
given the same inputs.  Hence, SQLite assumes the worst about
application-defined functions and never tries to factor them out of the
inner loop.  Probably we should add a new API that allows the application
to state auxiliary properties about application-defined functions (such as
whether or not it is "constant", whether or not it can return NULL, whether
or not it might change the encoding of its input parameters, etc.)  But
that has not been done yet.


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

Reply via email to