1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

Have sqlite3_stmt_scanstatus_v2() return an NCYCLE value for all loops, not just virtual tables ones. The value returned is the sum of the NCYCLE counts for the various opcodes that move or read data from the table or index cursor associated with the loop.

FossilOrigin-Name: 9499b2f51e8174c6b8a67840c92ba23b7dd1dc8dc2b91fca0c5dc07b71662149
This commit is contained in:
dan
2022-12-06 18:48:06 +00:00
parent 29226fc023
commit 2adb309ead
7 changed files with 95 additions and 63 deletions

View File

@ -88,8 +88,8 @@ proc get_graph {stmt} {
proc do_graph_test {tn sql res} {
db eval $sql
set stmt [db version -last-stmt-ptr]
set graph [string trim [get_graph $stmt]]
set graph [regsub -all {nCycle=[0-9]+} $graph nCycle=nnn]
uplevel [list do_test $tn [list set {} $graph] [string trim $res]]
}
@ -119,9 +119,9 @@ do_graph_test 1.3 {
SELECT (SELECT a FROM t1 WHERE b=x) FROM t2 WHERE y=2
} {
QUERY (nCycle=nnn)
--SCAN t2
--SCAN t2 (nCycle=nnn)
--CORRELATED SCALAR SUBQUERY 1 (nCycle=nnn)
----SCAN t1
----SCAN t1 (nCycle=nnn)
}
do_graph_test 1.4 {
@ -132,9 +132,9 @@ do_graph_test 1.4 {
} {
QUERY (nCycle=nnn)
--MATERIALIZE v2 (nCycle=nnn)
----SCAN t2
--SCAN v2
--SCAN t1
----SCAN t2 (nCycle=nnn)
--SCAN v2 (nCycle=nnn)
--SCAN t1 (nCycle=nnn)
--USE TEMP B-TREE FOR ORDER BY (nCycle=nnn)
}
@ -154,6 +154,25 @@ QUERY (nCycle=nnn)
--SCAN ft VIRTUAL TABLE INDEX 0:M1 (nCycle=nnn)
}
#-------------------------------------------------------------------------
reset_db
do_execsql_test 3.0 {
CREATE TABLE x1(a, b);
CREATE TABLE x2(c, d);
WITH s(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<1000)
INSERT INTO x1 SELECT i, i FROM s;
INSERT INTO x2 SELECT a, b FROM x1;
}
do_graph_test 2.1 {
SELECT * FROM x1, x2 WHERE c=+a;
} {
QUERY (nCycle=nnn)
--SCAN x1 (nCycle=nnn)
--SEARCH x2 USING AUTOMATIC COVERING INDEX (c=?) (nCycle=nnn)
}
finish_test