SQLite Forum

RETURNING clause require cursor consumption
Login
I had been looking at the commit log and not the corresponding draft documentation for the release. It seems that the docs clarify that this is an implementation detail and undefined behavior:

https://www.sqlite.org/draft/lang_returning.html

>However, applications should not depend on this ordering. Future versions of SQLite might precompute the outputs and return them all before any rows have been modified, or it might save all the outputs into a buffer then play the buffer back after all database modifications have been applied. Or future versions of SQLite might use a mixture of these algorithms.

Seems like it is behaving as intended, although I'm a little concerned about integrating this into libraries that interop with Postgres where the behavior is different. It certainly caught me off-guard.