Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | :-) (CVS 47) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
729d6586b8377d0e6cefa64c8cf3d883 |
User & Date: | drh 2000-06-03 19:19:41.000 |
Context
2000-06-03
| ||
19:28 | :-) (CVS 48) (check-in: f766564165 user: drh tags: trunk) | |
19:19 | :-) (CVS 47) (check-in: 729d6586b8 user: drh tags: trunk) | |
18:06 | added default values (CVS 46) (check-in: 27c0678623 user: drh tags: trunk) | |
Changes
Changes to Makefile.in.
︙ | ︙ | |||
211 212 213 214 215 216 217 | publish: $(PUBLISH) scp $(PUBLISH) hwaci@oak.he.net:public_html/sw/sqlite clean: rm -f *.o sqlite libsqlite.a sqlite.h rm -f lemon lempar.c parse.* sqlite.tar.gz rm -f $(PUBLISH) | > | 211 212 213 214 215 216 217 218 | publish: $(PUBLISH) scp $(PUBLISH) hwaci@oak.he.net:public_html/sw/sqlite 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 |
Changes to src/expr.c.
︙ | ︙ | |||
19 20 21 22 23 24 25 | ** Author contact information: ** drh@hwaci.com ** http://www.hwaci.com/drh/ ** ************************************************************************* ** This file contains C code routines used for processing expressions ** | | | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | ** Author contact information: ** drh@hwaci.com ** http://www.hwaci.com/drh/ ** ************************************************************************* ** This file contains C code routines used for processing expressions ** ** $Id: expr.c,v 1.4 2000/06/03 19:19:41 drh Exp $ */ #include "sqliteInt.h" /* ** This routine walks an expression tree and resolves references to ** table fields. Nodes of the form ID.ID or ID resolve into an ** index to the table in the table list and a field offset. The opcode |
︙ | ︙ | |||
360 361 362 363 364 365 366 | sqliteExprCode(pParse, pExpr->pLeft); sqliteVdbeAddOp(v, op, 0, 0, 0, 0); break; } case TK_ISNULL: case TK_NOTNULL: { int dest; | | | | 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 | sqliteExprCode(pParse, pExpr->pLeft); sqliteVdbeAddOp(v, op, 0, 0, 0, 0); break; } case TK_ISNULL: case TK_NOTNULL: { int dest; 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); break; } case TK_FUNCTION: { int id = sqliteFuncId(&pExpr->token); int op; int i; ExprList *pList = pExpr->pList; |
︙ | ︙ |
Changes to src/parse.y.
︙ | ︙ | |||
22 23 24 25 26 27 28 | ** ************************************************************************* ** This file contains SQLite's grammar for SQL. Process this file ** using the lemon parser generator to generate C code that runs ** the parser. Lemon will also generate a header file containing ** numeric codes for all of the tokens. ** | | | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | ** ************************************************************************* ** This file contains SQLite's grammar for SQL. Process this file ** using the lemon parser generator to generate C code that runs ** the parser. Lemon will also generate a header file containing ** numeric codes for all of the tokens. ** ** @(#) $Id: parse.y,v 1.8 2000/06/03 19:19:41 drh Exp $ */ %token_prefix TK_ %token_type {Token} %extra_argument {Parse *pParse} %syntax_error { sqliteSetNString(&pParse->zErrMsg,"syntax error near \"",0,TOKEN.z,TOKEN.n, "\"", 1, 0); |
︙ | ︙ | |||
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | item(A) ::= PLUS FLOAT(X). {A = sqliteExpr(TK_FLOAT, 0, 0, &X);} item(A) ::= MINUS FLOAT(X). { A = sqliteExpr(TK_FLOAT, 0, 0, 0); A->token.z = 0; sqliteSetNString(&A->token.z, "-", 1, X.z, X.n, 0); } item(A) ::= STRING(X). {A = sqliteExpr(TK_STRING, 0, 0, &X);} %type fieldlist_opt {IdList*} %destructor fieldlist_opt {sqliteIdListDelete($$);} %type fieldlist {IdList*} %destructor fieldlist {sqliteIdListDelete($$);} fieldlist_opt(A) ::= . {A = 0;} fieldlist_opt(A) ::= LP fieldlist(X) RP. {A = X;} fieldlist(A) ::= fieldlist(X) COMMA ID(Y). {A = sqliteIdListAppend(X,&Y);} fieldlist(A) ::= ID(Y). {A = sqliteIdListAppend(0,&Y);} %left OR. %left AND. %left EQ NE ISNULL NOTNULL IS LIKE GLOB. %left GT GE LT LE. %left PLUS MINUS. %left STAR SLASH PERCENT. | > > | | 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | item(A) ::= PLUS FLOAT(X). {A = sqliteExpr(TK_FLOAT, 0, 0, &X);} item(A) ::= MINUS FLOAT(X). { A = sqliteExpr(TK_FLOAT, 0, 0, 0); A->token.z = 0; 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($$);} %type fieldlist {IdList*} %destructor fieldlist {sqliteIdListDelete($$);} fieldlist_opt(A) ::= . {A = 0;} fieldlist_opt(A) ::= LP fieldlist(X) RP. {A = X;} fieldlist(A) ::= fieldlist(X) COMMA ID(Y). {A = sqliteIdListAppend(X,&Y);} 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 UMINUS. %type expr {Expr*} %destructor expr {sqliteExprDelete($$);} expr(A) ::= LP expr(X) RP. {A = X;} expr(A) ::= ID(X). {A = sqliteExpr(TK_ID, 0, 0, &X);} expr(A) ::= NULL. {A = sqliteExpr(TK_NULL, 0, 0, 0);} |
︙ | ︙ | |||
289 290 291 292 293 294 295 | expr(A) ::= expr(X) PLUS expr(Y). {A = sqliteExpr(TK_PLUS, X, Y, 0);} expr(A) ::= expr(X) MINUS expr(Y). {A = sqliteExpr(TK_MINUS, X, Y, 0);} expr(A) ::= expr(X) STAR expr(Y). {A = sqliteExpr(TK_STAR, X, Y, 0);} 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);} | | | | 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | expr(A) ::= expr(X) PLUS expr(Y). {A = sqliteExpr(TK_PLUS, X, Y, 0);} expr(A) ::= expr(X) MINUS expr(Y). {A = sqliteExpr(TK_MINUS, X, Y, 0);} expr(A) ::= expr(X) STAR expr(Y). {A = sqliteExpr(TK_STAR, X, Y, 0);} 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). [UMINUS] {A = sqliteExpr(TK_UMINUS, X, 0, 0);} expr(A) ::= PLUS expr(X). [UMINUS] {A = X;} %type exprlist {ExprList*} %destructor exprlist {sqliteExprListDelete($$);} %type expritem {Expr*} %destructor expritem {sqliteExprDelete($$);} exprlist(A) ::= exprlist(X) COMMA expritem(Y). |
︙ | ︙ |
Changes to test/delete.test.
︙ | ︙ | |||
19 20 21 22 23 24 25 | # drh@hwaci.com # http://www.hwaci.com/drh/ # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the DELETE FROM statement. # | | | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | # drh@hwaci.com # http://www.hwaci.com/drh/ # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the DELETE FROM statement. # # $Id: delete.test,v 1.4 2000/06/03 19:19:42 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Try to delete from a non-existant table. # do_test delete-1.1 { |
︙ | ︙ | |||
62 63 64 65 66 67 68 | execsql {SELECT * FROM table1 ORDER BY f1} } {1 2 2 4 4 16} do_test delete-3.1d { execsql {DELETE FROM table1 WHERE f1=2} execsql {SELECT * FROM table1 ORDER BY f1} } {1 2 4 16} | > | > > > > > > > > > > > | 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | execsql {SELECT * FROM table1 ORDER BY f1} } {1 2 2 4 4 16} do_test delete-3.1d { execsql {DELETE FROM table1 WHERE f1=2} 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 |
Changes to test/expr.test.
︙ | ︙ | |||
19 20 21 22 23 24 25 | # drh@hwaci.com # http://www.hwaci.com/drh/ # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing expressions. # | | | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | # drh@hwaci.com # http://www.hwaci.com/drh/ # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing expressions. # # $Id: expr.test,v 1.4 2000/06/03 19:19:42 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Create a table to work with. # execsql {CREATE TABLE test1(i1 int, i2 int, r1 real, r2 real, t1 text, t2 text)} |
︙ | ︙ | |||
60 61 62 63 64 65 66 | test_expr expr-1.19 {i1=20, i2=20} {i2=i1} 1 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} | | > > > > > > > > > > > | 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | test_expr expr-1.19 {i1=20, i2=20} {i2=i1} 1 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-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 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 |
︙ | ︙ | |||
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | test_expr expr-3.18 {t1='abc', t2='abc'} {t1==t2} 1 test_expr expr-3.19 {t1='abc', t2='xyz'} {t1<>t2} 1 test_expr expr-3.20 {t1='xyz', t2='abc'} {t1<>t2} 1 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-4.1 {t1='abc', t2='Abc'} {t1<t2} 0 test_expr expr-4.2 {t1='abc', t2='Abc'} {t1>t2} 1 test_expr expr-4.3 {t1='abc', t2='Bbc'} {t1<t2} 1 test_expr expr-4.4 {t1='abc', t2='Bbc'} {t1>t2} 0 test_expr expr-5.1 {t1='abc', t2='xyz'} {t1 LIKE t2} 0 test_expr expr-5.2 {t1='abc', t2='ABC'} {t1 LIKE t2} 1 test_expr expr-5.3 {t1='abc', t2='A_C'} {t1 LIKE t2} 1 test_expr expr-5.4 {t1='abc', t2='abc_'} {t1 LIKE t2} 0 test_expr expr-5.5 {t1='abc', t2='A%C'} {t1 LIKE t2} 1 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 finish_test | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | test_expr expr-3.18 {t1='abc', t2='abc'} {t1==t2} 1 test_expr expr-3.19 {t1='abc', t2='xyz'} {t1<>t2} 1 test_expr expr-3.20 {t1='xyz', t2='abc'} {t1<>t2} 1 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 test_expr expr-4.3 {t1='abc', t2='Bbc'} {t1<t2} 1 test_expr expr-4.4 {t1='abc', t2='Bbc'} {t1>t2} 0 test_expr expr-5.1 {t1='abc', t2='xyz'} {t1 LIKE t2} 0 test_expr expr-5.2 {t1='abc', t2='ABC'} {t1 LIKE t2} 1 test_expr expr-5.3 {t1='abc', t2='A_C'} {t1 LIKE t2} 1 test_expr expr-5.4 {t1='abc', t2='abc_'} {t1 LIKE t2} 0 test_expr expr-5.5 {t1='abc', t2='A%C'} {t1 LIKE t2} 1 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 |