From: drh Date: Mon, 12 Jun 2000 12:20:48 +0000 (+0000) Subject: :-) (CVS 93) X-Git-Tag: version-3.6.10~6007 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6de4f4ca1ca752d073a17ca0d930bd4d70c71c75;p=thirdparty%2Fsqlite.git :-) (CVS 93) FossilOrigin-Name: 3c0540e6fb103402c3f37fd2df17f9786b363db0 --- diff --git a/manifest b/manifest index 63f336fadf..5e6b617fdc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C added\sthe\sfcnt()\sfunction\sfor\stesting\s(CVS\s92) -D 2000-06-11T23:50:13 +C :-)\s(CVS\s93) +D 2000-06-12T12:20:49 F COPYRIGHT 74a8a6531a42e124df07ab5599aad63870fa0bd4 F Makefile.in b5693de0513e32f6e51bf0d1c62ea0d6b9a6c5d6 F README 51f6a4e7408b34afa5bc1c0485f61b6a4efb6958 @@ -46,6 +46,7 @@ F test/table.test d3e01e4916a99ade7d8f1d534ee1b36d57c00490 F test/tester.tcl 95b286791e6256bb6db0165f9342c70fff549a62 F test/update.test b3f45984cd2b3aea6f24b6d77dc1e721ccaba244 F test/vacuum.test 8becf5cfeb897108b35cdd996793e7f1df2f28fd +F test/where.test bbab5a308055fb6087dc23d600b4ad2b72797397 F tool/gdbmdump.c 529e67c78d920606ba196326ea55b57b75fcc82b F tool/lemon.c 1f0e96515c12e9e413f5b8fdebc79ddcf18ddc9d F tool/lempar.c a1eec94d6eacc12332368660ec65f3b248853833 @@ -57,13 +58,13 @@ F www/arch.fig 4e26e9dca3c49724fc8f554c695ddea9f2413156 F www/arch.png c4d908b79065a72e7dcf19317f36d1324c550e87 F www/arch.tcl 4f6a9afecc099a27bba17b4f8cc9561abc15dc40 F www/c_interface.tcl 9ac800854272db5fe439e07b7435b243a5422293 -F www/changes.tcl 557a1c49e9dfca6da6d659ffc4eb202399b42b81 +F www/changes.tcl 49c6bb069304399f636a37c609da993cf4c38442 F www/fileformat.tcl b11435fcd2cf2238a1c5e6d16fe5e83bcd14d434 F www/index.tcl 4116afce6a8c63d68882d2b00aa10b079e0129cd F www/lang.tcl 1645e9107d75709be4c6099b643db235bbe0a151 F www/opcode.tcl 3cdc4bb2515fcfcbe853e3f0c91cd9199e82dadd F www/sqlite.tcl 5420eab24b539928f80ea9b3088e2549d34f438d -P d573b431ed766db2d38672334a0c81faa1dde353 -R a071d3d9a4a3d2d16791159e4a3e2df8 +P 0f93c27cddb4254f72305ca3a64b77c2e7772c56 +R bd5f521fe3a6a6c0433519a44fdb2003 U drh -Z beff43aecb1f6e4f53737f0253af3944 +Z 65d5d81332e112b45f79056cb6dde603 diff --git a/manifest.uuid b/manifest.uuid index 379b92c925..fa45e887f5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0f93c27cddb4254f72305ca3a64b77c2e7772c56 \ No newline at end of file +3c0540e6fb103402c3f37fd2df17f9786b363db0 \ No newline at end of file diff --git a/test/where.test b/test/where.test new file mode 100644 index 0000000000..8ee4d0d18e --- /dev/null +++ b/test/where.test @@ -0,0 +1,160 @@ +# Copyright (c) 1999, 2000 D. Richard Hipp +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. +# +# Author contact information: +# drh@hwaci.com +# http://www.hwaci.com/drh/ +# +#*********************************************************************** +# This file implements regression tests for SQLite library. The +# focus of this file is testing the use of indices in WHERE clases. +# +# $Id: where.test,v 1.1 2000/06/12 12:20:49 drh Exp $ + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +# Build some test data +# +do_test where-1.0 { + execsql { + CREATE TABLE t1(w int, x int, y int); + CREATE TABLE t2(p int, q int, r int, s int); + } + for {set i 1} {$i<=100} {incr i} { + set w $i + set x [expr {int(log($i)/log(2))}] + set y [expr {$i*$i + 2*$i + 1}] + execsql "INSERT INTO t1 VALUES($w,$x,$y)" + } + execsql { + INSERT INTO t2 SELECT 101-w, x, (SELECT max(y) FROM t1)+1-y, y FROM t1; + CREATE INDEX i1w ON t1(w); + CREATE INDEX i1xy ON t1(x,y); + CREATE INDEX i2p ON t2(p); + CREATE INDEX i2r ON t2(r); + CREATE INDEX i2qs ON t2(q, s); + } +} {} + +# Verify that queries use an index. We are using the special "fcnt(*)" +# function to verify the results. fcnt(*) returns the number of Fetch +# operations that have occurred up to the point where fcnt(*) is invoked. +# By verifing that fcnt(*) returns a small number we know that an index +# was used instead of an exhaustive search. +# +do_test where-1.1 { + execsql {SELECT x, y, fcnt(*) FROM t1 WHERE w=10} +} {3 121 2} +do_test where-1.2 { + execsql {SELECT x, y, fcnt(*) FROM t1 WHERE w=11} +} {3 144 2} +do_test where-1.3 { + execsql {SELECT x, y, fcnt(*) FROM t1 WHERE 11=w} +} {3 144 2} +do_test where-1.4 { + execsql {SELECT x, y, fcnt(*) FROM t1 WHERE 11=w AND x>2} +} {3 144 2} +do_test where-1.5 { + execsql {SELECT x, y, fcnt(*) FROM t1 WHERE y<200 AND w=11 AND x>2} +} {3 144 2} +do_test where-1.6 { + execsql {SELECT x, y, fcnt(*) FROM t1 WHERE y<200 AND x>2 AND w=11} +} {3 144 2} +do_test where-1.7 { + execsql {SELECT x, y, fcnt(*) FROM t1 WHERE w=11 AND y<200 AND x>2} +} {3 144 2} +do_test where-1.8 { + execsql {SELECT x, y, fcnt(*) FROM t1 WHERE w>10 AND y=144 AND x=3} +} {3 144 2} +do_test where-1.9 { + execsql {SELECT x, y, fcnt(*) FROM t1 WHERE y=144 AND w>10 AND x=3} +} {3 144 2} +do_test where-1.10 { + execsql {SELECT x, y, fcnt(*) FROM t1 WHERE x=3 AND w>=10 AND y=121} +} {3 121 2} +do_test where-1.11 { + execsql {SELECT x, y, fcnt(*) FROM t1 WHERE x=3 AND y=100 AND w<10} +} {3 100 2} + +# Do the same kind of thing except use a join as the data source. +# +do_test where-2.1 { + execsql { + SELECT w, p, fcnt(*) FROM t2, t1 + WHERE x=q AND y=s AND r=8977 + } +} {34 67 4} +do_test where-2.2 { + execsql { + SELECT w, p, fcnt(*) FROM t2, t1 + WHERE x=q AND s=y AND r=8977 + } +} {34 67 4} +do_test where-2.3 { + execsql { + SELECT w, p, fcnt(*) FROM t2, t1 + WHERE x=q AND s=y AND r=8977 AND w>10 + } +} {34 67 4} +do_test where-2.4 { + execsql { + SELECT w, p, fcnt(*) FROM t2, t1 + WHERE p<80 AND x=q AND s=y AND r=8977 AND w>10 + } +} {34 67 4} +do_test where-2.5 { + execsql { + SELECT w, p, fcnt(*) FROM t2, t1 + WHERE p<80 AND x=q AND 8977=r AND s=y AND w>10 + } +} {34 67 4} +do_test where-2.6 { + execsql { + SELECT w, p, fcnt(*) FROM t2, t1 + WHERE x=q AND p=77 AND s=y AND w>5 + } +} {24 77 4} +do_test where-2.7 { + execsql { + SELECT w, p, fcnt(*) FROM t1, t2 + WHERE x=q AND p>77 AND s=y AND w=5 + } +} {5 96 4} + +# Lets do a 3-way join. +# +do_test where-3.1 { + execsql { + SELECT A.w, B.p, C.w, fcnt(*) FROM t1 as A, t2 as B, t1 as C + WHERE C.w=101-B.p AND B.r=10202-A.y AND A.w=11 + } +} {11 90 11 6} +do_test where-3.2 { + execsql { + SELECT A.w, B.p, C.w, fcnt(*) FROM t1 as A, t2 as B, t1 as C + WHERE C.w=101-B.p AND B.r=10202-A.y AND A.w=12 + } +} {12 89 12 6} +do_test where-3.3 { + execsql { + SELECT A.w, B.p, C.w, fcnt(*) FROM t1 as A, t2 as B, t1 as C + WHERE A.w=15 AND B.p=C.w AND B.r=10202-A.y + } +} {15 86 86 6} + +finish_test diff --git a/www/changes.tcl b/www/changes.tcl index d5c64bba22..144df2a5bc 100644 --- a/www/changes.tcl +++ b/www/changes.tcl @@ -17,6 +17,12 @@ proc chng {date desc} { puts "

" } +chng {2000 June 11} { +
  • Added a fcnt() function which is designed to help write better. + test scripts. This function is not useful for anything other than + testing and debugging, as far as I know.
  • +} + chng {2000 June 8} {
  • Added lots of new test cases
  • Fix a few bugs discovered while adding test cases