Correctly initialize the iSelectId of FROM clause terms that are a self
join of a reused materialized subquery. Without this, the EXPLAIN QUERY PLAN output for the query will identify the subquery using the uninitialized (and arbitrary) iSelectId. FossilOrigin-Name: 43c9ae371f6250fee98a7c4011726eff8ad37f5a97add4f490ac3a2dd501a0d2
This commit is contained in:
@@ -990,5 +990,19 @@ do_execsql_test 18.2 {
|
||||
SELECT 1 FROM xyz;
|
||||
} 1
|
||||
|
||||
# EXPLAIN QUERY PLAN on a self-join of a CTE
|
||||
#
|
||||
do_execsql_test 19.1 {
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1(x);
|
||||
EXPLAIN QUERY PLAN
|
||||
WITH
|
||||
x1(a) AS (values(100))
|
||||
INSERT INTO t1(x)
|
||||
SELECT * FROM (WITH x2(y) AS (SELECT * FROM x1) SELECT y+a FROM x1, x2);
|
||||
SELECT * FROM t1;
|
||||
} {0 0 0 {SCAN SUBQUERY 1} 0 1 1 {SCAN SUBQUERY 1}}
|
||||
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
Reference in New Issue
Block a user