summaryrefslogtreecommitdiff
blob: 6b34e2e4f9d81a7029138c7a0c74d5a7d6adc71f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
https://sqlite.org/src/info/e8275b415a2f03bee
https://sqlite.org/src/info/7fc2994434c7d9ed

--- /src/select.c
+++ /src/select.c
@@ -2318,6 +2318,13 @@
   Expr *pLimit;                 /* Saved LIMIT and OFFSET */
   int regLimit, regOffset;      /* Registers used by LIMIT and OFFSET */
 
+#ifndef SQLITE_OMIT_WINDOWFUNC
+  if( p->pWin ){
+    sqlite3ErrorMsg(pParse, "cannot use window functions in recursive queries");
+    return;
+  }
+#endif
+
   /* Obtain authorization to do a recursive query */
   if( sqlite3AuthCheck(pParse, SQLITE_RECURSIVE, 0, 0, 0) ) return;
 
--- /test/with1.test
+++ /test/with1.test
@@ -865,6 +865,27 @@
   SELECT * FROM i;
 } {1 {recursive aggregate queries not supported}}
 
+# Or window-function recursive queries. Ticket e8275b41.
+#
+ifcapable windowfunc {
+  do_catchsql_test 16.2 {
+    WITH RECURSIVE
+      i(x) AS (VALUES(1) UNION SELECT count(*) OVER () FROM i)
+      SELECT * FROM i;
+  } {1 {cannot use window functions in recursive queries}}
+  do_catchsql_test 16.3 {
+    WITH RECURSIVE
+      t(id, parent) AS (VALUES(1,2)),
+      q(id, parent, rn) AS (
+          VALUES(1,2,3)
+          UNION ALL
+          SELECT t.*, ROW_NUMBER() OVER (ORDER BY t.id) AS rn
+          FROM q JOIN t ON t.parent = q.id
+          )
+        SELECT * FROM q;
+  } {1 {cannot use window functions in recursive queries}}
+}
+
 #-------------------------------------------------------------------------
 do_execsql_test 17.1 {
   WITH x(a) AS (