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

:-) (CVS 24)

FossilOrigin-Name: 4cd98ebaeaedf66b258bbfa3a04d90c054294322
This commit is contained in:
drh
2000-05-31 17:59:25 +00:00
parent bf66fff0c5
commit 3aadb2e64c
5 changed files with 325 additions and 10 deletions

View File

@ -1,5 +1,5 @@
C :-)\s(CVS\s23)
D 2000-05-31T15:43:26
C :-)\s(CVS\s24)
D 2000-05-31T17:59:26
F COPYRIGHT 74a8a6531a42e124df07ab5599aad63870fa0bd4
F Makefile.in 7ac2fef265940d93a544cb454efa836451559a71
F README 6b5960603c7f8bf42fc022b4b6436f242f238dbb
@ -28,11 +28,12 @@ F src/where.c bed9a8360cbfbf712bdc397c8e22216a5e5f9800
F test/all.test 66a8a5b8291a472157944edcdce51a320ebd1f35
F test/copy.test 641bd3cfaab61c4ee32889587e21e4c70788a97a
F test/delete.test 814d53e3b0d2d7069fb17e005d4041454d6585d4
F test/expr.test 11e00880d2de0f60ff1ba7fdd4e09a0d72a01910
F test/expr.test 1f514623a568ebd351d0f1fe30c8f273681c1396
F test/index.test 8d4f26901a5582daa353fe3c8266cbf4a53af830
F test/insert.test 161bc67a4189738c559e3569323ceae31f4d49d6
F test/select1.test b994637d78e5b7f90c2032760f4c87aef8d461c1
F test/table.test 85d6f410d127ec508c6640f02d7c40d218414e81
F test/tester.tcl 70d25b7ced0a958bc377c72399b3dc6bf6a2d09e
F test/tester.tcl 44690d463c1dc83a4c76ccde07cc146a988600f6
F test/update.test 69459302ea75cafac1479e60b0e36efb88123c0e
F tool/gdbmdump.c 529e67c78d920606ba196326ea55b57b75fcc82b
F tool/lemon.c cff35578b3c4d1491021b6418016639ebe21b1a5
@ -44,7 +45,7 @@ F www/c_interface.tcl f875864edf7974157d1c257ca08de854660882a5
F www/changes.tcl 995d64c96978a996f0e9e46f2ce896355a7c87a7
F www/index.tcl 600e85c207929bedb9c6fd221aa7875fd8f43edf
F www/sqlite.tcl 7deb564df188ad4523adecfe2365de6d09f6dfd9
P d33ad08e0d909cfe731a5616fde6be0c681dc191
R f2d793ab815bb8215210937d7d1b9b7e
P 0b040cea57ee76103030c0d5ef571dc481a2b2d3
R 6c10963e34e77cc84c8f0379f7394fc1
U drh
Z 43bc792cf63b510b39bdc55742cfc1f7
Z 83085793cdd6972c96321a385eef56bb

View File

@ -1 +1 @@
0b040cea57ee76103030c0d5ef571dc481a2b2d3
4cd98ebaeaedf66b258bbfa3a04d90c054294322

View File

@ -23,7 +23,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing expressions.
#
# $Id: expr.test,v 1.1 2000/05/30 03:28:36 drh Exp $
# $Id: expr.test,v 1.2 2000/05/31 17:59:26 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -62,6 +62,32 @@ test_expr expr-1.20 {i1=20, i2=20} {i2<>i1} 0
test_expr expr-1.21 {i1=20, i2=20} {i2==i1} 1
test_expr expr-1.22 {i1=1, i2=2, r1=3.0} {i1+i2*r1} {7}
test_expr expr-1.23 {i1=1, i2=2, r1=3.0} {(i1+i2)*r1} {9}
test_expr expr-1.24 {i1=1, i2=2} {min(i1,i2,i1+i2,i1-i2)} {-1}
test_expr expr-1.25 {i1=1, i2=2} {max(i1,i2,i1+i2,i1-i2)} {3}
test_expr expr-2.1 {r1=1.23, r2=2.34} {r1+r2} 3.57
test_expr expr-2.2 {r1=1.23, r2=2.34} {r1-r2} -1.11
test_expr expr-2.3 {r1=1.23, r2=2.34} {r1*r2} 2.8782
test_expr expr-2.4 {r1=1.23, r2=2.34} {r1/r2} 0.525641
test_expr expr-2.5 {r1=1.23, r2=2.34} {r2/r1} 1.90244
test_expr expr-2.6 {r1=1.23, r2=2.34} {r2<r1} 0
test_expr expr-2.7 {r1=1.23, r2=2.34} {r2<=r1} 0
test_expr expr-2.8 {r1=1.23, r2=2.34} {r2>r1} 1
test_expr expr-2.9 {r1=1.23, r2=2.34} {r2>=r1} 1
test_expr expr-2.10 {r1=1.23, r2=2.34} {r2!=r1} 1
test_expr expr-2.11 {r1=1.23, r2=2.34} {r2=r1} 0
test_expr expr-2.12 {r1=1.23, r2=2.34} {r2<>r1} 1
test_expr expr-2.13 {r1=1.23, r2=2.34} {r2==r1} 0
test_expr expr-2.14 {r1=2.34, r2=2.34} {r2<r1} 0
test_expr expr-2.15 {r1=2.34, r2=2.34} {r2<=r1} 1
test_expr expr-2.16 {r1=2.34, r2=2.34} {r2>r1} 0
test_expr expr-2.17 {r1=2.34, r2=2.34} {r2>=r1} 1
test_expr expr-2.18 {r1=2.34, r2=2.34} {r2!=r1} 0
test_expr expr-2.19 {r1=2.34, r2=2.34} {r2=r1} 1
test_expr expr-2.20 {r1=2.34, r2=2.34} {r2<>r1} 0
test_expr expr-2.21 {r1=2.34, r2=2.34} {r2==r1} 1
test_expr expr-2.22 {r1=1.23, r2=2.34} {min(r1,r2,r1+r2,r1-r2)} {-1.11}
test_expr expr-2.23 {r1=1.23, r2=2.34} {max(r1,r2,r1+r2,r1-r2)} {3.57}
finish_test

275
test/select1.test Normal file
View File

@ -0,0 +1,275 @@
# 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 SELECT statement.
#
# $Id: select1.test,v 1.1 2000/05/31 17:59:27 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# Try to select on a non-existant table.
#
do_test select-1.1 {
set v [catch {execsql {SELECT * FROM test1}} msg]
lappend v $msg
} {1 {no such table: test1}}
execsql {CREATE TABLE test1(f1 int, f2 int)}
do_test select-1.2 {
set v [catch {execsql {SELECT * FROM test1, test2}} msg]
lappend v $msg
} {1 {no such table: test2}}
do_test select-1.3 {
set v [catch {execsql {SELECT * FROM test2, test1}} msg]
lappend v $msg
} {1 {no such table: test2}}
execsql {INSERT INTO test1(f1,f2) VALUES(11,22)}
# Make sure the fields are extracted correctly.
#
do_test select-1.4 {
execsql {SELECT f1 FROM test1}
} {11}
do_test select-1.5 {
execsql {SELECT f2 FROM test1}
} {22}
do_test select-1.6 {
execsql {SELECT f2, f1 FROM test1}
} {22 11}
do_test select-1.7 {
execsql {SELECT f1, f2 FROM test1}
} {11 22}
do_test select-1.8 {
execsql {SELECT * FROM test1}
} {11 22}
execsql {CREATE TABLE test2(r1 real, r2 real)}
execsql {INSERT INTO test2(r1,r2) VALUES(1.1,2.2)}
do_test select-1.9 {
execsql {SELECT * FROM test1, test2}
} {11 22 1.1 2.2}
do_test select-1.10 {
execsql {SELECT test1.f1, test2.r1 FROM test1, test2}
} {11 1.1}
do_test select-1.11 {
execsql {SELECT test1.f1, test2.r1 FROM test2, test1}
} {11 1.1}
do_test select-1.12 {
execsql {SELECT max(test1.f1,test2.r1), min(test1.f2,test2.r2)
FROM test2, test1}
} {11 2.2}
do_test select-1.13 {
execsql {SELECT min(test1.f1,test2.r1), max(test1.f2,test2.r2)
FROM test1, test2}
} {1.1 22}
execsql {DROP TABLE test2}
execsql {DELETE FROM test1}
execsql {INSERT INTO test1 VALUES(11,22)}
execsql {INSERT INTO test1 VALUES(33,44)}
# Error messges from sqliteExprCheck
#
do_test select-2.1 {
set v [catch {execsql {SELECT count(f1,f2) FROM test1}} msg]
lappend v $msg
} {1 {too many arguments to function count()}}
do_test select-2.2 {
set v [catch {execsql {SELECT count(f1) FROM test1}} msg]
lappend v $msg
} {0 2}
do_test select-2.3 {
set v [catch {execsql {SELECT Count() FROM test1}} msg]
lappend v $msg
} {0 2}
do_test select-2.4 {
set v [catch {execsql {SELECT COUNT(*) FROM test1}} msg]
lappend v $msg
} {0 2}
do_test select-2.5 {
set v [catch {execsql {SELECT COUNT(*)+1 FROM test1}} msg]
lappend v $msg
} {1 {no such function: COUNT}}
do_test select-2.6 {
set v [catch {execsql {SELECT min(*) FROM test1}} msg]
lappend v $msg
} {1 {too few arguments to function min()}}
do_test select-2.7 {
set v [catch {execsql {SELECT Min(f1) FROM test1}} msg]
lappend v $msg
} {0 11}
do_test select-2.8 {
set v [catch {execsql {SELECT MIN(f1,f2) FROM test1}} msg]
lappend v [lsort $msg]
} {0 {11 33}}
do_test select-2.9 {
set v [catch {execsql {SELECT MAX(*) FROM test1}} msg]
lappend v $msg
} {1 {too few arguments to function MAX()}}
do_test select-2.10 {
set v [catch {execsql {SELECT Max(f1) FROM test1}} msg]
lappend v $msg
} {0 33}
do_test select-2.11 {
set v [catch {execsql {SELECT max(f1,f2) FROM test1}} msg]
lappend v [lsort $msg]
} {0 {22 44}}
do_test select-2.12 {
set v [catch {execsql {SELECT MAX(f1,f2)+1 FROM test1}} msg]
lappend v [lsort $msg]
} {0 {23 45}}
do_test select-2.13 {
set v [catch {execsql {SELECT MAX(f1)+1 FROM test1}} msg]
lappend v $msg
} {1 {too few arguments to function MAX()}}
do_test select-2.14 {
set v [catch {execsql {SELECT SUM(*) FROM test1}} msg]
lappend v $msg
} {1 {too few arguments to function SUM()}}
do_test select-2.15 {
set v [catch {execsql {SELECT Sum(f1) FROM test1}} msg]
lappend v $msg
} {0 44}
do_test select-2.16 {
set v [catch {execsql {SELECT sum(f1,f2) FROM test1}} msg]
lappend v $msg
} {1 {too many arguments to function sum()}}
do_test select-2.17 {
set v [catch {execsql {SELECT SUM(f1)+1 FROM test1}} msg]
lappend v $msg
} {1 {no such function: SUM}}
do_test select-2.18 {
set v [catch {execsql {SELECT XYZZY(f1) FROM test1}} msg]
lappend v $msg
} {1 {no such function: XYZZY}}
do_test select-2.19 {
set v [catch {execsql {SELECT SUM(min(f1,f2)) FROM test1}} msg]
lappend v $msg
} {0 44}
do_test select-2.20 {
set v [catch {execsql {SELECT SUM(min(f1)) FROM test1}} msg]
lappend v $msg
} {1 {too few arguments to function min()}}
# WHERE clause expressions
#
do_test select-3.1 {
set v [catch {execsql {SELECT f1 FROM test1 WHERE f1<11}} msg]
lappend v $msg
} {0 {}}
do_test select-3.2 {
set v [catch {execsql {SELECT f1 FROM test1 WHERE f1<=11}} msg]
lappend v $msg
} {0 11}
do_test select-3.3 {
set v [catch {execsql {SELECT f1 FROM test1 WHERE f1=11}} msg]
lappend v $msg
} {0 11}
do_test select-3.4 {
set v [catch {execsql {SELECT f1 FROM test1 WHERE f1>=11}} msg]
lappend v [lsort $msg]
} {0 {11 33}}
do_test select-3.5 {
set v [catch {execsql {SELECT f1 FROM test1 WHERE f1>11}} msg]
lappend v [lsort $msg]
} {0 33}
do_test select-3.6 {
set v [catch {execsql {SELECT f1 FROM test1 WHERE f1!=11}} msg]
lappend v [lsort $msg]
} {0 33}
do_test select-3.7 {
set v [catch {execsql {SELECT f1 FROM test1 WHERE min(f1,f2)!=11}} msg]
lappend v [lsort $msg]
} {0 33}
do_test select-3.8 {
set v [catch {execsql {SELECT f1 FROM test1 WHERE max(f1,f2)!=11}} msg]
lappend v [lsort $msg]
} {0 {11 33}}
do_test select-3.9 {
set v [catch {execsql {SELECT f1 FROM test1 WHERE count(f1,f2)!=11}} msg]
lappend v $msg
} {1 {no such function: count}}
# ORDER BY expressions
#
do_test select-4.1 {
set v [catch {execsql {SELECT f1 FROM test1 ORDER BY f1}} msg]
lappend v $msg
} {0 {11 33}}
do_test select-4.2 {
set v [catch {execsql {SELECT f1 FROM test1 ORDER BY -f1}} msg]
lappend v $msg
} {0 {33 11}}
do_test select-4.3 {
set v [catch {execsql {SELECT f1 FROM test1 ORDER BY min(f1,f2)}} msg]
lappend v $msg
} {0 {11 33}}
do_test select-4.4 {
set v [catch {execsql {SELECT f1 FROM test1 ORDER BY min(f1)}} msg]
lappend v $msg
} {1 {too few arguments to function min()}}
# ORDER BY ignored on an aggregate query
#
do_test select-5.1 {
set v [catch {execsql {SELECT max(f1) FROM test1 ORDER BY f2}} msg]
lappend v $msg
} {0 33}
execsql {CREATE TABLE test2(t1 test, t2 text)}
execsql {INSERT INTO test2 VALUES('abc','xyz')}
# Check for field naming
#
do_test select-6.1 {
set v [catch {execsql2 {SELECT f1 FROM test1 ORDER BY f2}} msg]
lappend v $msg
} {0 {f1 11 f1 33}}
do_test select-6.2 {
set v [catch {execsql2 {SELECT f1 as xyzzy FROM test1 ORDER BY f2}} msg]
lappend v $msg
} {0 {xyzzy 11 xyzzy 33}}
do_test select-6.3 {
set v [catch {execsql2 {SELECT f1 as "xyzzy" FROM test1 ORDER BY f2}} msg]
lappend v $msg
} {0 {xyzzy 11 xyzzy 33}}
do_test select-6.4 {
set v [catch {execsql2 {SELECT f1+F2 as xyzzy FROM test1 ORDER BY f2}} msg]
lappend v $msg
} {0 {xyzzy 33 xyzzy 77}}
do_test select-6.5 {
set v [catch {execsql2 {SELECT test1.f1+F2 FROM test1 ORDER BY f2}} msg]
lappend v $msg
} {0 {field1 33 field1 77}}
do_test select-6.6 {
set v [catch {execsql2 {SELECT test1.f1+F2, t1 FROM test1, test2
ORDER BY f2}} msg]
lappend v $msg
} {0 {field1 33 test2.t1 abc field1 77 test2.t1 abc}}
finish_test

View File

@ -23,7 +23,7 @@
# This file implements some common TCL routines used for regression
# testing the SQLite library
#
# $Id: tester.tcl,v 1.3 2000/05/30 00:51:27 drh Exp $
# $Id: tester.tcl,v 1.4 2000/05/31 17:59:27 drh Exp $
# Create a test database
#
@ -89,3 +89,16 @@ proc execsql {sql} {
}
return $result
}
# Another procedure to execute SQL. This one includes the field
# names in the returned list.
#
proc execsql2 {sql} {
set result {}
db eval $sql data {
foreach f $data(*) {
lappend result $f $data($f)
}
}
return $result
}