Avoid leaking memory in an obscure case where the flattener adds an ORDER BY clause to the recursive part of a recursive query.

FossilOrigin-Name: 1f413aca00015100224273480e1ce39a76bf93ab
This commit is contained in:
dan
2014-03-21 19:27:54 +00:00
parent a22a75e5ca
commit 9afccba269
5 changed files with 45 additions and 12 deletions
+27
View File
@@ -385,6 +385,33 @@ do_execsql_test 7.5 {
)
} {14 28 42}
#-------------------------------------------------------------------------
# At one point the following was causing an assertion failure and a
# memory leak.
#
do_execsql_test 8.1 {
CREATE TABLE t7(y);
INSERT INTO t7 VALUES(NULL);
CREATE VIEW v AS SELECT * FROM t7 ORDER BY y;
}
do_execsql_test 8.2 {
WITH q(a) AS (
SELECT 1
UNION
SELECT a+1 FROM q, v WHERE a<5
)
SELECT * FROM q;
} {1 2 3 4 5}
do_execsql_test 8.3 {
WITH q(a) AS (
SELECT 1
UNION ALL
SELECT a+1 FROM q, v WHERE a<5
)
SELECT * FROM q;
} {1 2 3 4 5}
finish_test