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

:-) (CVS 47)

FossilOrigin-Name: 729d6586b8377d0e6cefa64c8cf3d883e9f0ddc3
This commit is contained in:
drh
2000-06-03 19:19:41 +00:00
parent 7020f6516c
commit 8be51133aa
7 changed files with 112 additions and 21 deletions

View File

@ -215,3 +215,4 @@ clean:
rm -f *.o sqlite libsqlite.a sqlite.h
rm -f lemon lempar.c parse.* sqlite.tar.gz
rm -f $(PUBLISH)
rm -f *.da *.bb *.bbg gmon.out

View File

@ -1,7 +1,7 @@
C added\sdefault\svalues\s(CVS\s46)
D 2000-06-03T18:06:52
C :-)\s(CVS\s47)
D 2000-06-03T19:19:41
F COPYRIGHT 74a8a6531a42e124df07ab5599aad63870fa0bd4
F Makefile.in 3d367d6699f6fb987d0041a9d3b4dbf4308c8983
F Makefile.in 20a035ae94ec7574d7a5f09301d3f6f5f9cb7ef0
F README 51f6a4e7408b34afa5bc1c0485f61b6a4efb6958
F configure 00a5b5c82147a576fa6e82d7c1b0d55c321d6d2c x
F configure.in 6ccfd5fc80517f7cfe605a7fc7e0f62d962a233c
@ -10,10 +10,10 @@ F src/build.c 15c4f3844774baa882435223119a18c33810ee94
F src/dbbe.c ae8b5d2cdb4fa7dd11313059984be9457fa77f63
F src/dbbe.h a8a46f71238e0f09f3ec08fd9d1c8c7f4cdc49bf
F src/delete.c e11433c14ed5cc8553cba14296b3baa3c23054bc
F src/expr.c baab49f0db860d27fdc41e6cd0bde1c437189ac8
F src/expr.c 6df33b3a42039e1eb1eb556c84a4b190a8eca8ca
F src/insert.c 62951015437a96d388f43b591437d489719872fb
F src/main.c ed15e0132659ace7f44ea2dbcdd21c232af3dbd5
F src/parse.y 64d9e4808993e9384ba9557f7168ac3dab6cb89f
F src/parse.y 9ec486608b7b4daaccf4ad9f05eef1a26a008fb8
F src/select.c 2f4ae48deae2c5c94a89b3bc4fef2fe96c575e9f
F src/shell.c bd658f9208bc20ce565c3f687836155772ca939a
F src/sqlite.h 58da0a8590133777b741f9836beaef3d58f40268
@ -27,8 +27,8 @@ F src/vdbe.h ab574c91c6328c5795f68b84074fbcf860eae70e
F src/where.c bed9a8360cbfbf712bdc397c8e22216a5e5f9800
F test/all.test 0950c135cab7e60c07bd745ccfad1476211e5bd7
F test/copy.test 6b218a41dc6469491049b50ee105f76282f2547d
F test/delete.test 9b2515aa621fb5df46c640fdef39c876b9a5fc4b
F test/expr.test f3fc925935533082911dfa5fde9b22e382b3132f
F test/delete.test 30451333f89479d2deb5410edd3f3cce67339944
F test/expr.test db6984d2a6e86118dfce68edade6539495f29022
F test/index.test 9f99dca2d904b8de330863a978587f136e2df65a
F test/insert.test b4c186ffa4b97a231643726f3bcee29815b24eaf
F test/select1.test a0b00df77e85adff75c338e487718c5d31f69e3a
@ -47,7 +47,7 @@ F www/c_interface.tcl 8867d76ddd416d2fbd41e4cb3de8efa9cef105a5
F www/changes.tcl 7d6ed774362dea0c9687d4efbafd939c1c48fd81
F www/index.tcl 0096a3e00b1364fb2c3e06941aa8c31454b6d06a
F www/sqlite.tcl 2f933ce18cffd34a0a020a82435ab937137970fd
P 3e88142e908de02b5c8243c47dc9ca237cb7f011
R 75efbb82189fa0b34c50ac1e66e30b8e
P 27c0678623de37f3166cb9952989fd03484cdb8d
R 55ab5057755afd4eb3d30546b6144ca3
U drh
Z c2845300f99ec90b3961e47b3598d5e7
Z 47b79d9e980f5d785c73e416f1cd2177

View File

@ -1 +1 @@
27c0678623de37f3166cb9952989fd03484cdb8d
729d6586b8377d0e6cefa64c8cf3d883e9f0ddc3

View File

@ -23,7 +23,7 @@
*************************************************************************
** This file contains C code routines used for processing expressions
**
** $Id: expr.c,v 1.3 2000/06/03 18:06:53 drh Exp $
** $Id: expr.c,v 1.4 2000/06/03 19:19:41 drh Exp $
*/
#include "sqliteInt.h"
@ -364,11 +364,11 @@ void sqliteExprCode(Parse *pParse, Expr *pExpr){
case TK_ISNULL:
case TK_NOTNULL: {
int dest;
sqliteVdbeAddOp(v, OP_Integer, 0, 0, 0, 0);
sqliteVdbeAddOp(v, OP_Integer, 1, 0, 0, 0);
sqliteExprCode(pParse, pExpr->pLeft);
dest = sqliteVdbeCurrentAddr(v) + 2;
sqliteVdbeAddOp(v, op, 0, dest, 0, 0);
sqliteVdbeAddOp(v, OP_AddImm, 1, 0, 0, 0);
sqliteVdbeAddOp(v, OP_AddImm, -1, 0, 0, 0);
break;
}
case TK_FUNCTION: {

View File

@ -26,7 +26,7 @@
** the parser. Lemon will also generate a header file containing
** numeric codes for all of the tokens.
**
** @(#) $Id: parse.y,v 1.7 2000/06/03 18:06:53 drh Exp $
** @(#) $Id: parse.y,v 1.8 2000/06/03 19:19:41 drh Exp $
*/
%token_prefix TK_
%token_type {Token}
@ -242,6 +242,7 @@ item(A) ::= MINUS FLOAT(X). {
sqliteSetNString(&A->token.z, "-", 1, X.z, X.n, 0);
}
item(A) ::= STRING(X). {A = sqliteExpr(TK_STRING, 0, 0, &X);}
item(A) ::= NULL. {A = sqliteExpr(TK_NULL, 0, 0, 0);}
%type fieldlist_opt {IdList*}
%destructor fieldlist_opt {sqliteIdListDelete($$);}
@ -255,11 +256,12 @@ fieldlist(A) ::= ID(Y). {A = sqliteIdListAppend(0,&Y);}
%left OR.
%left AND.
%right NOT.
%left EQ NE ISNULL NOTNULL IS LIKE GLOB.
%left GT GE LT LE.
%left PLUS MINUS.
%left STAR SLASH PERCENT.
%right NOT.
%right UMINUS.
%type expr {Expr*}
%destructor expr {sqliteExprDelete($$);}
@ -293,8 +295,8 @@ expr(A) ::= expr(X) SLASH expr(Y). {A = sqliteExpr(TK_SLASH, X, Y, 0);}
expr(A) ::= expr(X) ISNULL. {A = sqliteExpr(TK_ISNULL, X, 0, 0);}
expr(A) ::= expr(X) NOTNULL. {A = sqliteExpr(TK_NOTNULL, X, 0, 0);}
expr(A) ::= NOT expr(X). {A = sqliteExpr(TK_NOT, X, 0, 0);}
expr(A) ::= MINUS expr(X). [NOT] {A = sqliteExpr(TK_UMINUS, X, 0, 0);}
expr(A) ::= PLUS expr(X). [NOT] {A = X;}
expr(A) ::= MINUS expr(X). [UMINUS] {A = sqliteExpr(TK_UMINUS, X, 0, 0);}
expr(A) ::= PLUS expr(X). [UMINUS] {A = X;}
%type exprlist {ExprList*}
%destructor exprlist {sqliteExprListDelete($$);}

View File

@ -23,7 +23,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing the DELETE FROM statement.
#
# $Id: delete.test,v 1.3 2000/06/03 18:06:53 drh Exp $
# $Id: delete.test,v 1.4 2000/06/03 19:19:42 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -66,5 +66,17 @@ do_test delete-3.1d {
execsql {SELECT * FROM table1 ORDER BY f1}
} {1 2 4 16}
# Semantic errors in the WHERE clause
#
do_test delete-4.1 {
execsql {CREATE TABLE table2(f1 int, f2 int)}
set v [catch {execsql {DELETE FROM table2 WHERE f3=5}} msg]
lappend v $msg
} {1 {no such field: f3}}
do_test delete-4.2 {
set v [catch {execsql {DELETE FROM table2 WHERE xyzzy(f1+4)}} msg]
lappend v $msg
} {1 {no such function: xyzzy}}
finish_test

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.3 2000/05/31 18:33:10 drh Exp $
# $Id: expr.test,v 1.4 2000/06/03 19:19:42 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -64,7 +64,18 @@ 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-1.26 {i1=1, i2=2} {max(i1,i2,i1+i2,i1-i2)} {3}
test_expr expr-1.27 {i1=1, i2=2} {i1==1 AND i2=2} {1}
test_expr expr-1.28 {i1=1, i2=2} {i1=2 AND i2=1} {0}
test_expr expr-1.29 {i1=1, i2=2} {i1=1 AND i2=1} {0}
test_expr expr-1.30 {i1=1, i2=2} {i1=2 AND i2=2} {0}
test_expr expr-1.31 {i1=1, i2=2} {i1==1 OR i2=2} {1}
test_expr expr-1.32 {i1=1, i2=2} {i1=2 OR i2=1} {0}
test_expr expr-1.33 {i1=1, i2=2} {i1=1 OR i2=1} {1}
test_expr expr-1.34 {i1=1, i2=2} {i1=2 OR i2=2} {1}
test_expr expr-1.35 {i1=1, i2=2} {i1-i2=-1} {1}
test_expr expr-1.36 {i1=1, i2=0} {not i1} {0}
test_expr expr-1.37 {i1=1, i2=NULL} {not i2} {1}
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
@ -114,6 +125,10 @@ test_expr expr-3.21 {t1='abc', t2='abc'} {t1<>t2} 0
test_expr expr-3.22 {t1='abc', t2='xyz'} {t1!=t2} 1
test_expr expr-3.23 {t1='xyz', t2='abc'} {t1!=t2} 1
test_expr expr-3.24 {t1='abc', t2='abc'} {t1!=t2} 0
test_expr expr-3.25 {t1=NULL, t2='hi'} {t1 isnull} 1
test_expr expr-3.26 {t1=NULL, t2='hi'} {t2 isnull} 0
test_expr expr-3.27 {t1=NULL, t2='hi'} {t1 notnull} 0
test_expr expr-3.28 {t1=NULL, t2='hi'} {t2 notnull} 1
test_expr expr-4.1 {t1='abc', t2='Abc'} {t1<t2} 0
test_expr expr-4.2 {t1='abc', t2='Abc'} {t1>t2} 1
@ -129,4 +144,65 @@ test_expr expr-5.6 {t1='abxyzzyc', t2='A%C'} {t1 LIKE t2} 1
test_expr expr-5.7 {t1='abxyzzy', t2='A%C'} {t1 LIKE t2} 0
test_expr expr-5.8 {t1='abxyzzycx', t2='A%C'} {t1 LIKE t2} 0
test_expr expr-6.1 {t1='abc', t2='xyz'} {t1 GLOB t2} 0
test_expr expr-6.2 {t1='abc', t2='ABC'} {t1 GLOB t2} 0
test_expr expr-6.3 {t1='abc', t2='A?C'} {t1 GLOB t2} 0
test_expr expr-6.4 {t1='abc', t2='a?c'} {t1 GLOB t2} 1
test_expr expr-6.5 {t1='abc', t2='abc?'} {t1 GLOB t2} 0
test_expr expr-6.6 {t1='abc', t2='A*C'} {t1 GLOB t2} 0
test_expr expr-6.7 {t1='abc', t2='a*c'} {t1 GLOB t2} 1
test_expr expr-6.8 {t1='abxyzzyc', t2='a*c'} {t1 GLOB t2} 1
test_expr expr-6.9 {t1='abxyzzy', t2='a*c'} {t1 GLOB t2} 0
test_expr expr-6.10 {t1='abxyzzycx', t2='a*c'} {t1 GLOB t2} 0
# The sqliteExprIfFalse and sqliteExprIfTrue routines are only
# executed as part of a WHERE clause. Create a table suitable
# for testing these functions.
#
execsql {DROP TABLE test1}
execsql {CREATE TABLE test1(a int, b int);}
for {set i 1} {$i<=20} {incr i} {
execsql "INSERT INTO test1 VALUES($i,[expr {int(pow(2,$i))}])"
}
execsql "INSERT INTO test1 VALUES(NULL,0)"
do_test expr-7.1 {
execsql {SELECT * FROM test1 ORDER BY a}
} {{} 0 1 2 2 4 3 8 4 16 5 32 6 64 7 128 8 256 9 512 10 1024 11 2048 12 4096 13 8192 14 16384 15 32768 16 65536 17 131072 18 262144 19 524288 20 1048576}
proc test_expr2 {name expr result} {
do_test $name [format {
execsql {SELECT a FROM test1 WHERE %s ORDER BY a}
} $expr] $result
}
test_expr2 expr-7.2 {a<10 AND a>8} {9}
test_expr2 expr-7.3 {a<=10 AND a>=8} {8 9 10}
test_expr2 expr-7.4 {a>=8 AND a<=10} {8 9 10}
test_expr2 expr-7.5 {a>=20 OR a<=1} {{} 1 20}
test_expr2 expr-7.6 {b!=4 AND a<=3} {{} 1 3}
test_expr2 expr-7.7 {b==8 OR b==16 OR b==32} {3 4 5}
test_expr2 expr-7.8 {NOT b<>8 OR b==1024} {3 10}
test_expr2 expr-7.9 {b LIKE '10%'} {10 20}
test_expr2 expr-7.10 {b LIKE '_4'} {6}
test_expr2 expr-7.11 {a GLOB '1?'} {10 11 12 13 14 15 16 17 18 19}
test_expr2 expr-7.12 {b GLOB '1*4'} {10 14}
test_expr2 expr-7.13 {b GLOB '*1[456]'} {4}
test_expr2 expr-7.14 {a ISNULL} {{}}
test_expr2 expr-7.15 {a NOTNULL AND a<3} {1 2}
test_expr2 expr-7.16 {a AND a<3} {1 2}
test_expr2 expr-7.17 {NOT a} {{}}
test_expr2 expr-7.18 {a==11 OR (b>1000 AND b<2000)} {10 11}
test_expr2 expr-7.19 {a<=1 OR a>=20} {{} 1 20}
test_expr2 expr-7.20 {a<1 OR a>20} {{}}
test_expr2 expr-7.21 {a>19 OR a<1} {{} 20}
test_expr2 expr-7.22 {a!=1 OR a=100} \
{{} 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20}
test_expr2 expr-7.23 {(a notnull AND a<4) OR a==8} {1 2 3 8}
test_expr2 expr-7.24 {a LIKE '2_' OR a==8} {8 20}
test_expr2 expr-7.25 {a GLOB '2?' OR a==8} {8 20}
test_expr2 expr-7.26 {a isnull OR a=8} {{} 8}
test_expr2 expr-7.27 {a notnull OR a=8} \
{1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20}
finish_test