Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | :-) (CVS 82) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
33355b2d8d23b51e917961b7fb336bc1 |
User & Date: | drh 2000-06-08 16:26:24.000 |
Context
2000-06-08
| ||
16:54 | :-) (CVS 83) (check-in: 2e5786d101 user: drh tags: trunk) | |
16:26 | :-) (CVS 82) (check-in: 33355b2d8d user: drh tags: trunk) | |
15:10 | :-) (CVS 81) (check-in: 61c381e7e6 user: drh tags: trunk) | |
Changes
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 37 38 39 40 41 42 | ** ************************************************************************* ** 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.19 2000/06/08 16:26:24 drh Exp $ */ %token_prefix TK_ %token_type {Token} %extra_argument {Parse *pParse} %syntax_error { sqliteSetString(&pParse->zErrMsg,"syntax error",0); pParse->sErrToken = TOKEN; } %name sqliteParser %include { #include "sqliteInt.h" #include "parse.h" } |
︙ | ︙ |
Changes to src/tokenize.c.
︙ | ︙ | |||
23 24 25 26 27 28 29 | ************************************************************************* ** An tokenizer for SQL ** ** This file contains C code that splits an SQL input string up into ** individual tokens and sends those tokens one-by-one over to the ** parser for analysis. ** | | | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | ************************************************************************* ** An tokenizer for SQL ** ** This file contains C code that splits an SQL input string up into ** individual tokens and sends those tokens one-by-one over to the ** parser for analysis. ** ** $Id: tokenize.c,v 1.11 2000/06/08 16:26:24 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> #include <stdlib.h> /* ** All the keywords of the SQL language are stored as in a hash |
︙ | ︙ | |||
207 208 209 210 211 212 213 | *tokenType = TK_GT; return 1; } } case '!': { if( z[1]!='=' ){ *tokenType = TK_ILLEGAL; | | | 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | *tokenType = TK_GT; return 1; } } case '!': { if( z[1]!='=' ){ *tokenType = TK_ILLEGAL; return 2; }else{ *tokenType = TK_NE; return 2; } } case ',': { *tokenType = TK_COMMA; |
︙ | ︙ | |||
241 242 243 244 245 246 247 248 249 250 251 | *tokenType = TK_DOT; return 1; } /* Fall thru into the next case */ } case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { for(i=1; z[i] && isdigit(z[i]); i++){} if( z[i]=='.' ){ i++; while( z[i] && isdigit(z[i]) ){ i++; } | > > > | | | | < < < | 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 | *tokenType = TK_DOT; return 1; } /* Fall thru into the next case */ } case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { *tokenType = TK_INTEGER; for(i=1; z[i] && isdigit(z[i]); i++){} if( z[i]=='.' ){ i++; while( z[i] && isdigit(z[i]) ){ i++; } *tokenType = TK_FLOAT; } if( (z[i]=='e' || z[i]=='E') && ( isdigit(z[i+1]) || ((z[i+1]=='+' || z[i+1]=='-') && isdigit(z[i+2])) ) ){ i += 2; while( z[i] && isdigit(z[i]) ){ i++; } *tokenType = TK_FLOAT; }else if( z[0]=='.' ){ *tokenType = TK_FLOAT; } return i; } case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': |
︙ | ︙ | |||
359 360 361 362 363 364 365 | } #endif } #endif break; } case TK_ILLEGAL: | | | | 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | } #endif } #endif break; } case TK_ILLEGAL: sqliteSetNString(pzErrMsg, "unrecognized token: \"", -1, pParse->sLastToken.z, pParse->sLastToken.n, "\"", 1, 0); nErr++; break; default: sqliteParser(pEngine, tokenType, pParse->sLastToken, pParse); if( pParse->zErrMsg && pParse->sErrToken.z ){ sqliteSetNString(pzErrMsg, "near \"", -1, pParse->sErrToken.z, pParse->sErrToken.n, |
︙ | ︙ |
Changes to src/vdbe.c.
︙ | ︙ | |||
37 38 39 40 41 42 43 | ** inplicit conversion from one type to the other occurs as necessary. ** ** Most of the code in this file is taken up by the sqliteVdbeExec() ** function which does the work of interpreting a VDBE program. ** But other routines are also provided to help in building up ** a program instruction by instruction. ** | | | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | ** inplicit conversion from one type to the other occurs as necessary. ** ** Most of the code in this file is taken up by the sqliteVdbeExec() ** function which does the work of interpreting a VDBE program. ** But other routines are also provided to help in building up ** a program instruction by instruction. ** ** $Id: vdbe.c,v 1.30 2000/06/08 16:26:25 drh Exp $ */ #include "sqliteInt.h" #include <unistd.h> /* ** SQL is translated into a sequence of instructions to be ** executed by a virtual machine. Each instruction is an instance |
︙ | ︙ | |||
422 423 424 425 426 427 428 | ** ** Return 0 on success and 1 if memory is exhausted. */ static int AggInsert(Agg *p, char *zKey){ AggElem *pElem; int i; if( p->nHash <= p->nElem*2 ){ | | | 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 | ** ** Return 0 on success and 1 if memory is exhausted. */ static int AggInsert(Agg *p, char *zKey){ AggElem *pElem; int i; if( p->nHash <= p->nElem*2 ){ AggRehash(p, p->nElem*2 + 19); } if( p->nHash==0 ) return 1; pElem = sqliteMalloc( sizeof(AggElem) + strlen(zKey) + 1 + (p->nMem-1)*sizeof(pElem->aMem[0]) ); if( pElem==0 ) return 1; pElem->zKey = (char*)&pElem->aMem[p->nMem]; strcpy(pElem->zKey, zKey); |
︙ | ︙ |
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.7 2000/06/08 16:26:25 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)} |
︙ | ︙ | |||
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | 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.5b {t1='ac', 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-5.9 {t1='abc', t2='A%_C'} {t1 LIKE t2} 1 test_expr expr-5.9b {t1='ac', t2='A%_C'} {t1 LIKE t2} 0 test_expr expr-5.10 {t1='abxyzzyc', t2='A%_C'} {t1 LIKE t2} 1 test_expr expr-5.11 {t1='abc', t2='xyz'} {t1 NOT LIKE t2} 1 test_expr expr-5.12 {t1='abc', t2='ABC'} {t1 NOT 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 test_expr expr-6.11 {t1='abc', t2='xyz'} {t1 NOT GLOB t2} 1 | > | > > > > > > > > > > > > > | 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 | 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.5b {t1='ac', 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-5.8b {t1='abxyzzycy', t2='A%CX'} {t1 LIKE t2} 0 test_expr expr-5.9 {t1='abc', t2='A%_C'} {t1 LIKE t2} 1 test_expr expr-5.9b {t1='ac', t2='A%_C'} {t1 LIKE t2} 0 test_expr expr-5.10 {t1='abxyzzyc', t2='A%_C'} {t1 LIKE t2} 1 test_expr expr-5.11 {t1='abc', t2='xyz'} {t1 NOT LIKE t2} 1 test_expr expr-5.12 {t1='abc', t2='ABC'} {t1 NOT 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 test_expr expr-6.11 {t1='abc', t2='xyz'} {t1 NOT GLOB t2} 1 test_expr expr-6.12 {t1='abc', t2='abc'} {t1 NOT GLOB t2} 0 test_expr expr-6.13 {t1='abc', t2='a[bx]c'} {t1 GLOB t2} 1 test_expr expr-6.14 {t1='abc', t2='a[cx]c'} {t1 GLOB t2} 0 test_expr expr-6.15 {t1='abc', t2='a[a-d]c'} {t1 GLOB t2} 1 test_expr expr-6.16 {t1='abc', t2='a[^a-d]c'} {t1 GLOB t2} 0 test_expr expr-6.17 {t1='abc', t2='a[A-Dc]c'} {t1 GLOB t2} 0 test_expr expr-6.18 {t1='abc', t2='a[^A-Dc]c'} {t1 GLOB t2} 1 test_expr expr-6.19 {t1='abc', t2='a[]b]c'} {t1 GLOB t2} 1 test_expr expr-6.20 {t1='abc', t2='a[^]b]c'} {t1 GLOB t2} 0 test_expr expr-6.21 {t1='abcdefg', t2='a*[de]g'} {t1 GLOB t2} 0 test_expr expr-6.22 {t1='abcdefg', t2='a*[^de]g'} {t1 GLOB t2} 1 test_expr expr-6.23 {t1='abcdefg', t2='a*?g'} {t1 GLOB t2} 1 test_expr expr-6.24 {t1='ac', t2='a*c'} {t1 GLOB t2} 1 test_expr expr-6.25 {t1='ac', 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);} |
︙ | ︙ |
Changes to test/main.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 exercising the code in main.c. # | | | 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 exercising the code in main.c. # # $Id: main.test,v 1.2 2000/06/08 16:26:25 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Tests of the sqlite_complete() function. # do_test main-1.1 { |
︙ | ︙ | |||
57 58 59 60 61 62 63 64 65 | file mkdir testdb set fd [open testdb/sqlite_master.tbl w] puts $fd hi! close $fd set v [catch {sqlite db testdb} msg] lappend v $msg } {0 {}} finish_test | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 57 58 59 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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | file mkdir testdb set fd [open testdb/sqlite_master.tbl w] puts $fd hi! close $fd set v [catch {sqlite db testdb} msg] lappend v $msg } {0 {}} # Here are some tests for tokenize.c. # do_test main-3.1 { catch {db close} file delete -force testdb sqlite db testdb set v [catch {execsql {SELECT * from T1 where x!!5}} msg] lappend v $msg } {1 {unrecognized token: "!!"}} do_test main-3.2 { catch {db close} file delete -force testdb sqlite db testdb set v [catch {execsql {SELECT * from T1 where ~x}} msg] lappend v $msg } {1 {unrecognized token: "~"}} do_test main-3.3 { catch {db close} file delete -force testdb sqlite db testdb execsql { create table T1(X REAL); insert into T1 values(.5); insert into T1 values(0.5e2); insert into T1 values(0.5e-002); insert into T1 values(5e-002); insert into T1 values(-5.0e-2); insert into T1 values(-5.1e-2); insert into T1 values(.5e2); insert into T1 values(.5E+02); insert into T1 values(5E+02); insert into T1 values(5.E+03); select x*10 from T1 order by x*5; } } {-0.51 -0.5 0.05 0.5 5 500 500 500 5000 50000} do_test main-3.4 { set v [catch {execsql {create bogus}} msg] lappend v $msg } {1 {near "bogus": syntax error}} do_test main-3.5 { set v [catch {execsql {create}} msg] lappend v $msg } {1 {near "create": syntax error}} finish_test |
Changes to test/select5.test.
︙ | ︙ | |||
20 21 22 23 24 25 26 | # http://www.hwaci.com/drh/ # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing aggregate functions and the # GROUP BY and HAVING clauses of SELECT statements. # | | | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | # http://www.hwaci.com/drh/ # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing aggregate functions and the # GROUP BY and HAVING clauses of SELECT statements. # # $Id: select5.test,v 1.3 2000/06/08 16:26:25 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Build some test data # set fd [open data1.txt w] |
︙ | ︙ | |||
54 55 56 57 58 59 60 61 62 | } {5 15 6 8 7 4 8 2 9 1 10 1} do_test select5-1.2 { execsql {SELECT y, count(*) FROM t1 GROUP BY y ORDER BY count(*), y} } {9 1 10 1 8 2 7 4 6 8 5 15} do_test select5-1.3 { execsql {SELECT count(*), y FROM t1 GROUP BY y ORDER BY count(*), y} } {1 9 1 10 2 8 4 7 8 6 15 5} finish_test | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 54 55 56 57 58 59 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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | } {5 15 6 8 7 4 8 2 9 1 10 1} do_test select5-1.2 { execsql {SELECT y, count(*) FROM t1 GROUP BY y ORDER BY count(*), y} } {9 1 10 1 8 2 7 4 6 8 5 15} do_test select5-1.3 { execsql {SELECT count(*), y FROM t1 GROUP BY y ORDER BY count(*), y} } {1 9 1 10 2 8 4 7 8 6 15 5} # Some error messages associated with aggregates and GROUP BY # do_test select5-2.1 { set v [catch {execsql { SELECT y, count(*) FROM t1 GROUP BY z ORDER BY y }} msg] lappend v $msg } {1 {no such field: z}} do_test select5-2.2 { set v [catch {execsql { SELECT y, count(*) FROM t1 GROUP BY z(y) ORDER BY y }} msg] lappend v $msg } {1 {no such function: z}} do_test select5-2.3 { set v [catch {execsql { SELECT y, count(*) FROM t1 GROUP BY y HAVING count(*)<3 ORDER BY y }} msg] lappend v $msg } {0 {8 2 9 1 10 1}} do_test select5-2.4 { set v [catch {execsql { SELECT y, count(*) FROM t1 GROUP BY y HAVING z(y)<3 ORDER BY y }} msg] lappend v $msg } {1 {no such function: z}} do_test select5-2.5 { set v [catch {execsql { SELECT y, count(*) FROM t1 GROUP BY y HAVING count(*)<z ORDER BY y }} msg] lappend v $msg } {1 {no such field: z}} # Get the Agg function to rehash in vdbe.c # do_test select5-3.1 { execsql { SELECT x, count(*), avg(y) FROM t1 GROUP BY x HAVING x<4 ORDER BY x } } {1 1 5 2 1 5 3 1 5} # Run the AVG() function when the count is zero. # do_test select5-4.1 { execsql { SELECT avg(x) FROM t1 WHERE x>100 } } {} finish_test |
Changes to test/update.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 UPDATE 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 UPDATE statement. # # $Id: update.test,v 1.2 2000/06/08 16:26:25 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Try to update an non-existent table # do_test update-1.1 { |
︙ | ︙ | |||
106 107 108 109 110 111 112 113 114 115 116 117 118 119 | execsql {UPDATE test1 SET f2=11 WHERE f1==1025} execsql {SELECT * FROM test1 ORDER BY f1} } {2 1 4 2 8 3 16 4 32 5 64 6 128 7 256 8 512 9 1025 11} do_test update-3.12 { execsql {SELECT * FROM test1 WHERE f1=1025} } {1025 11} finish_test | > > > > > > > > > > > > > > > > > > > > > > > > > > | 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 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 | execsql {UPDATE test1 SET f2=11 WHERE f1==1025} execsql {SELECT * FROM test1 ORDER BY f1} } {2 1 4 2 8 3 16 4 32 5 64 6 128 7 256 8 512 9 1025 11} do_test update-3.12 { execsql {SELECT * FROM test1 WHERE f1=1025} } {1025 11} # Error messages # do_test update-4.1 { set v [catch {execsql { UPDATE test1 SET x=11 WHERE f1=1025 }} msg] lappend v $msg } {1 {no such field: x}} do_test update-4.2 { set v [catch {execsql { UPDATE test1 SET f1=x(11) WHERE f1=1025 }} msg] lappend v $msg } {1 {no such function: x}} do_test update-4.3 { set v [catch {execsql { UPDATE test1 SET f1=11 WHERE x=1025 }} msg] lappend v $msg } {1 {no such field: x}} do_test update-4.4 { set v [catch {execsql { UPDATE test1 SET f1=11 WHERE x(f1)=1025 }} msg] lappend v $msg } {1 {no such function: x}} finish_test |