SQLite Forum

Is the call order of functions in a statement strictly left-to-right?
Hi, all,

i thought i knew this, but now have doubts...

i am implementing a UDF for the Fossil SCM for which the order of UDF calls in a given statement is important, and need to know for certain whether the functions will be called in the order they appear in the SQL, or whether they may be called in an arbitrary order?


For the curious...

The UDF references a piece of app-global state which has its own C-level cursor, the UDF is to be used something like:

SELECT fcard(0), -- 0 == step the internal cursor
   fcard(1), -- 1 = grab the 1st field from the current internal row
   fcard(2), -- 2nd field
   fcard(3), -- 3rd field
   fcard(4); -- 4th field

The UDF is not marked with `SQLITE_DETERMINISTIC`, so no calls should be optimized away.

For proper functioning, it's critical that the `fcard(0)` call be executed before the others to step the internal cursor, else the other calls would not behave properly.

Edit: i have since found a nicer solution which doesn't require a UDF, but am still curious about the call order guarantees.