I was experimenting with ways to return only the last row of a recursive CTE, when I came across some curious behaviour.
The following two examples were run from the shell of 3.8.7.2: 1) PRAGMA reverse_unordered_selects = OFF; WITH RECURSIVE i(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM i LIMIT 5) SELECT * FROM i; 1 2 3 4 5 2) PRAGMA reverse_unordered_selects = ON; WITH RECURSIVE i(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM i LIMIT 5) SELECT * FROM i; 1 2 3 4 5 The documentation for PRAGMA reverse_unordered_selects states that "SQLite makes no guarantees about the order of results if a SELECT omits the ORDER BY clause. Even so, the order of results does not change from one run to the next...", so one would expect example 2 to output the results in the reverse order of example 1. I could not find anything in the documentation that suggests these results are expected. If this is not a bug, then this behaviour should be mentioned on either the Pragma, or WITH Clause documentation pages. ~Jaak -- View this message in context: http://sqlite.1065341.n5.nabble.com/PRAGMA-reverse-unordered-selects-and-CTEs-tp79300.html Sent from the SQLite mailing list archive at Nabble.com. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users