Files
TheRock/rocm-systems/projects/rocprofiler-sdk/external/sqlite/test/coveridxscan.test
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

120 lines
2.7 KiB
Plaintext

# 2012 September 17
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
#
# Tests for the optimization which attempts to use a covering index
# for a full-table scan (under the theory that the index will be smaller
# and require less I/O and hence will run faster.)
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix coveridxscan
do_test 1.1 {
db eval {
CREATE TABLE t1(a,b,c);
INSERT INTO t1 VALUES(5,4,3), (4,8,2), (3,2,1);
CREATE INDEX t1ab ON t1(a,b);
CREATE INDEX t1b ON t1(b);
SELECT a FROM t1;
}
# covering index used for the scan, hence values are increasing
} {3 4 5}
do_test 1.2 {
db eval {
SELECT a, c FROM t1;
}
# There is no covering index, hence the values are in rowid order
} {5 3 4 2 3 1}
do_test 1.3 {
db eval {
SELECT b FROM t1;
}
# Choice of two indices: use the one with fewest columns
} {2 4 8}
do_test 2.1 {
optimization_control db cover-idx-scan 0
db eval {SELECT a FROM t1}
# With the optimization turned off, output in rowid order
} {5 4 3}
do_test 2.2 {
db eval {SELECT a, c FROM t1}
} {5 3 4 2 3 1}
do_test 2.3 {
db eval {SELECT b FROM t1}
} {4 8 2}
db close
sqlite3_shutdown
sqlite3_config_cis 0
sqlite3 db test.db
do_test 3.1 {
db eval {SELECT a FROM t1}
# With the optimization configured off, output in rowid order
} {5 4 3}
do_test 3.2 {
db eval {SELECT a, c FROM t1}
} {5 3 4 2 3 1}
do_test 3.3 {
db eval {SELECT b FROM t1}
} {4 8 2}
db close
sqlite3_shutdown
sqlite3_config_cis 1
sqlite3 db test.db
# The CIS optimization is enabled again. Covering indices are once again
# used for all table scans.
do_test 4.1 {
db eval {SELECT a FROM t1}
} {3 4 5}
do_test 4.2 {
db eval {SELECT a, c FROM t1}
} {5 3 4 2 3 1}
do_test 4.3 {
db eval {SELECT b FROM t1}
} {2 4 8}
#-------------------------------------------------------------------------
# Test that indexes with large numbers of columns can be correctly
# identified as covering indexes.
reset_db
set L [list]
for {set i 1} {$i<120} {incr i} {
lappend L "c$i"
}
set cols [join $L ,]
do_execsql_test 5.1.0 "
CREATE TABLE t1(a, b, c, $cols, PRIMARY KEY(a, b, c)) WITHOUT ROWID;
CREATE INDEX i1 ON t1($cols);
CREATE TABLE t2(i INTEGER PRIMARY KEY, $cols);
CREATE INDEX i2 ON t2($cols);
"
do_eqp_test 5.1.1 {
SELECT * FROM t1 ORDER BY c1, c2;
} {SCAN t1 USING COVERING INDEX i1}
do_eqp_test 5.1.2 {
SELECT * FROM t2 ORDER BY c1, c2;
} {SCAN t2 USING COVERING INDEX i2}
finish_test