1
0
mirror of https://github.com/sqlite/sqlite.git synced 2026-10-23 21:49:02 +03:00

Improve tests in bestindexF.test. No changes to non-test code.

FossilOrigin-Name: 347d4d34c1815827e7049e57830c1fff67f6eb16ae5cc00839e35d94bac81e92
This commit is contained in:
dan
2025-12-18 16:05:05 +00:00
parent 4461335b00
commit ce46f82bc4
3 changed files with 139 additions and 32 deletions

View File

@@ -1,5 +1,5 @@
C Better\sorderByConsumed\slogic\sin\sthe\svt02.c\stest\svirtual\stable.
D 2025-12-18T15:35:50.492
C Improve\stests\sin\sbestindexF.test.\sNo\schanges\sto\snon-test\scode.
D 2025-12-18T16:05:05.184
F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -918,7 +918,7 @@ F test/bestindexB.test 328b97b69cd1a20928d5997f9ecb04d2e00f1d18e19ab27f9e9adb44d
F test/bestindexC.test 95b4a527b1a5d07951d731604a6d4cf7e5a806b39cea0e7819d4c9667e11c3fc
F test/bestindexD.test 6a8f6f84990bcf17dfa59652a1f935beddb7afd96f8302830fbc86b0a13df3c3
F test/bestindexE.test 297f3ea8500a8f3c17d6f78e55bdfee089064c6144ee84a110bd005a03338f49
F test/bestindexF.test ea06ec01aa82cea997c02eb2a8f07f4eb83582a2afb0b8d6416189d08777a537
F test/bestindexF.test 32b5975a28d73ab2def2a2ef49d10ab992182ca62679e179907fe187d735f62d
F test/between.test e7587149796101cbe8d5f8abae8d2a7b87f04d8226610aa1091615005dcf4d54
F test/bigfile.test aa74f4e5db51c8e54a1d9de9fa65d01d1eb20b59
F test/bigfile2.test 1b489a3a39ae90c7f027b79110d6b4e1dbc71bfc
@@ -2187,8 +2187,8 @@ F tool/version-info.c 33d0390ef484b3b1cb685d59362be891ea162123cea181cb8e6d2cf6dd
F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
F tool/warnings.sh d924598cf2f55a4ecbc2aeb055c10bd5f48114793e7ba25f9585435da29e7e98
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P acc95f24cc034408de1e9225aef4dae8bf76beec812c152bea32db95f7d2b854
R 690b929b38217f93c8bcc4c1a9492cf4
U drh
Z 70ea1398d8aa129f5457ba79d55fdf37
P 612c1ece6752e3318fc688717ad6a82219b85df7d32e4e07dbc2f361a5aeeee4
R 580ea8657cb3efb5b82ff2a1e13c7fc2
U dan
Z 99a67f6205f5b3113357bf79d420e775
# Remove this line to create a well-formed Fossil manifest.

View File

@@ -1 +1 @@
612c1ece6752e3318fc688717ad6a82219b85df7d32e4e07dbc2f361a5aeeee4
347d4d34c1815827e7049e57830c1fff67f6eb16ae5cc00839e35d94bac81e92

View File

@@ -108,25 +108,43 @@ proc vtab_command {method args} {
set ::vtab_orderby [$hdl orderby]
set ::vtab_distinct [$hdl distinct]
if {$::vtab_orderby == "{column 0 desc 1}" || $::vtab_distinct==1} {
return [list orderby 1]
# Set idxNum to 1 if DISTINCT is to be used in xFilter.
#
set idxStr [list ""]
if {$::vtab_distinct==2 || $::vtab_distinct==3} {
set idxStr [list DISTINCT]
}
set orderby 0
if {$::vtab_orderby == "{column 0 desc 1}"
|| $::vtab_orderby == "{column 0 desc 0}"
} {
set orderby 1
if {$::vtab_distinct==1 || $::vtab_distinct==2} {
lappend idxStr "ORDER BY ((a+2)%5)"
} else {
set sort "ORDER BY a"
if {$::vtab_orderby == "{column 0 desc 1}"} {
append sort " DESC"
}
lappend idxStr $sort
}
} else {
lappend idxStr ""
}
return [list orderby $orderby idxstr $idxStr]
return ""
}
xFilter {
set sql {
SELECT 1, 2, 'a', 555
UNION ALL
SELECT 2, 2, 'a', NULL
UNION ALL
SELECT 3, 1, 'b', 'text'
UNION ALL
SELECT 4, 1, 'a', 3.14
UNION ALL
SELECT 5, 1, 'b', 0
}
set idxstr [lindex $args 1]
set distinct [lindex $idxstr 0]
set orderby [lindex $idxstr 1]
set sql "
SELECT $distinct 0, a, b FROM real_t1 $orderby
"
return [list sql $sql]
}
}
@@ -134,26 +152,115 @@ proc vtab_command {method args} {
return {}
}
do_execsql_test 2.0 {
CREATE TABLE real_t1(a, b);
INSERT INTO real_t1 VALUES (1, 'a');
INSERT INTO real_t1 VALUES (2, 'a');
INSERT INTO real_t1 VALUES (1, 'a');
INSERT INTO real_t1 VALUES (2, 'b');
INSERT INTO real_t1 VALUES (1, 'b');
INSERT INTO real_t1 VALUES (2, 'b');
INSERT INTO real_t1 VALUES (3, 'a');
INSERT INTO real_t1 VALUES (4, 'b');
INSERT INTO real_t1 VALUES (3, 'a');
INSERT INTO real_t1 VALUES (4, 'b');
INSERT INTO real_t1 VALUES (3, 'a');
INSERT INTO real_t1 VALUES (4, 'b');
}
register_tcl_module db
do_execsql_test 2.0 {
CREATE VIRTUAL TABLE t1 USING tcl(vtab_command)
}
do_execsql_test 2.1 {
SELECT a, count(*) FROM t1 GROUP BY a ORDER BY a;
} {1 3 2 2}
SELECT a, b FROM t1
} {
1 a 2 a 1 a
2 b 1 b 2 b
3 a 4 b 3 a
4 b 3 a 4 b
}
do_test 2.2 {
list $::vtab_distinct $::vtab_orderby
} {0 {{column 0 desc 0}}}
# This is like do_execsql_test, except one value is prepended to the
# expected result - the P4 (idxStr) of the VFilter opcode. It is an error
# if $sql generates two or more VFilter instructions.
#
proc do_vtabsorter_test {tn sql expect} {
set vm [db eval "EXPLAIN $sql"]
do_execsql_test 2.3 {
SELECT a, count(*) FROM t1 GROUP BY a ORDER BY a DESC;
} {2 2 1 3}
set ii [lsearch $vm VFilter]
set ::res [lindex $vm [expr $ii+4]]
do_test 2.4 {
list $::vtab_distinct $::vtab_orderby
} {0 {{column 0 desc 1}}}
set iSort [lsearch $vm SorterSort]
if {$iSort>=0} {
error "query is using sorter"
}
uplevel [list do_test $tn.1 { set ::res } [lindex $expect 0]]
uplevel [list do_execsql_test $tn.2 $sql [lrange $expect 1 end]]
}
do_vtabsorter_test 2.2 {
SELECT a, b FROM t1
} { "{} {}"
1 a 2 a 1 a
2 b 1 b 2 b
3 a 4 b 3 a
4 b 3 a 4 b
}
do_vtabsorter_test 2.3 {
SELECT DISTINCT a FROM t1
} { "DISTINCT {ORDER BY ((a+2)%5)}"
3 4 1 2
}
do_vtabsorter_test 2.4 {
SELECT DISTINCT a FROM t1 ORDER BY a
} { "DISTINCT {ORDER BY a}"
1 2 3 4
}
do_vtabsorter_test 2.5 {
SELECT a FROM t1 ORDER BY a
} { "{} {ORDER BY a}"
1 1 1
2 2 2
3 3 3
4 4 4
}
do_vtabsorter_test 2.6 {
SELECT a, count(*) FROM t1 GROUP BY a ORDER BY a
} { "{} {ORDER BY a}"
1 3
2 3
3 3
4 3
}
do_vtabsorter_test 2.7 {
SELECT a, count(*) FROM t1 GROUP BY a
} { "{} {ORDER BY ((a+2)%5)}"
3 3
4 3
1 3
2 3
}
do_vtabsorter_test 2.8 {
SELECT DISTINCT a, count(*) FROM t1 GROUP BY a
} { "{} {ORDER BY ((a+2)%5)}"
3 3
4 3
1 3
2 3
}
finish_test