I tested the following query (from SQLite documentation):

CREATE TABLE edge(aa INT, bb INT);

WITH RECURSIVE nodes(x) AS (
   SELECT 59
   UNION
   SELECT aa FROM edge JOIN nodes ON bb=x
   UNION
   SELECT bb FROM edge JOIN nodes ON aa=x
)
SELECT x FROM nodes;

ERROR: 42P19: recursive reference to query "nodes" must not appear within its non-recursive term
LINE 4:    SELECT aa FROM edge JOIN nodes ON bb=x
                                    ^
LOCATION:  checkWellFormedRecursionWalker, parse_cte.c:960

This well-formedness check apparently needs to be enhanced to allow for more than two branches in the union.


Reply via email to