]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
:-) (CVS 82)
authordrh <drh@noemail.net>
Thu, 8 Jun 2000 16:26:24 +0000 (16:26 +0000)
committerdrh <drh@noemail.net>
Thu, 8 Jun 2000 16:26:24 +0000 (16:26 +0000)
FossilOrigin-Name: 33355b2d8d23b51e917961b7fb336bc1d454497f

manifest
manifest.uuid
src/parse.y
src/tokenize.c
src/vdbe.c
test/expr.test
test/main.test
test/select5.test
test/update.test

index c1cc5833eec75e6176f0798bc0484763bcb46041..233fc3ffe5fc704c6ed157a87003a27ed886fc45 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C :-)\s(CVS\s81)
-D 2000-06-08T15:10:47
+C :-)\s(CVS\s82)
+D 2000-06-08T16:26:24
 F COPYRIGHT 74a8a6531a42e124df07ab5599aad63870fa0bd4
 F Makefile.in 17ba1ccf8d2d40c627796bba8f72952365d6d644
 F README 51f6a4e7408b34afa5bc1c0485f61b6a4efb6958
@@ -13,38 +13,38 @@ F src/delete.c c267b93f7ccb5493b677fa18201880267c699aa8
 F src/expr.c 5790665132658362f1416755cc4060215c781e90
 F src/insert.c ac4edfff474589c00b2490f206317dc5822122e5
 F src/main.c e3297835b8e38ca726ac73f2c2bdb7cf08103197
-F src/parse.y 389687d20f2ac914205ebbd58cef72b8c70322b2
+F src/parse.y 03d246c261296ec85a72225ae3be999db1663e6d
 F src/select.c 3a12d76074fa57d7c39c4436bdeb8d7e1eb6fdf4
 F src/shell.c 3f4afc39a36e4824e8aa262623fd03568874799e
 F src/sqlite.h 58da0a8590133777b741f9836beaef3d58f40268
 F src/sqliteInt.h 0aac58ed2e9fe46f24411e2e012fe85cd3457129
 F src/tclsqlite.c 9f358618ae803bedf4fb96da5154fd45023bc1f7
-F src/tokenize.c cb9eacd12548ee1ae7089eb3177b38851d7f0a1f
+F src/tokenize.c 344754f81b55da5b19ea9504dfa16a9de68cd5ba
 F src/update.c d8d90df714bac99c68446a0c49f3d957ca6fc3c8
 F src/util.c 38e4bb5edf6fa92e677698c45785bf73c69b9e9f
-F src/vdbe.c 8a92c95cf66ff67e8fc122d6892b08b0e7801d9c
+F src/vdbe.c cc5598c00935ec9ec349467487182ddce9c00bce
 F src/vdbe.h 8f79f57c66ce1030f6371ff067b326d627a52c6d
 F src/where.c c9b90e7672f4662a83ef9a27a193020d69fe034c
 F test/all.test 0950c135cab7e60c07bd745ccfad1476211e5bd7
 F test/copy.test b77a1214bd7756f2849d5c4fa6e715c0ff0c34eb
 F test/dbbe.test 0a8e4293cf816e590dcbb01be4cd4e8f7f95bdc8
 F test/delete.test 30edd2c7484274fb2e7dbc4a1ac769bb330b322e
-F test/expr.test 7d017f1aa64c981b161408a015424cd90592bc16
+F test/expr.test 2209a2b06ea10ebb844b2c4ae08fe8345e5b87b2
 F test/in.test 962a605b6a3a619214f84d1950dfc44fcf0d8b8f
 F test/index.test 9f99dca2d904b8de330863a978587f136e2df65a
 F test/insert.test 66f4c3bd600fec8eb1e733b928cbe6fa885eff0c
 F test/insert2.test 732405e30331635af8d159fccabe835eea5cd0c6
-F test/main.test cf1e9035aca55da9ef6d3b73ab36c54b7514b83f
+F test/main.test a6c92ebc66b990b601a2f67bbd02404310a820e4
 F test/select1.test 64703852af34c85bb31b0a74bd73b340e8267f42
 F test/select2.test 3cd3c0f9d67e98b1b54af5853679b4a111224410
 F test/select3.test a9234b8424b6c6d71de534f43b91ade9be68e9cc
 F test/select4.test cb5374d7c87680e294ac749307459a5cc547609d
-F test/select5.test b6f8b6bef467764a3edaea4e7cb9b0eb8f02ccd8
+F test/select5.test 80ea257ce35e736c559bc6cd342361974e60a979
 F test/sort.test d582086c4bb7df3fbf50aa72e69d7e235e9f8e31
 F test/subselect.test bf8b251a92fb091973c1c469ce499dc9648a41d5
 F test/table.test d3e01e4916a99ade7d8f1d534ee1b36d57c00490
 F test/tester.tcl 95b286791e6256bb6db0165f9342c70fff549a62
-F test/update.test 69459302ea75cafac1479e60b0e36efb88123c0e
+F test/update.test b3f45984cd2b3aea6f24b6d77dc1e721ccaba244
 F test/vacuum.test 8becf5cfeb897108b35cdd996793e7f1df2f28fd
 F tool/gdbmdump.c 529e67c78d920606ba196326ea55b57b75fcc82b
 F tool/lemon.c 1f0e96515c12e9e413f5b8fdebc79ddcf18ddc9d
@@ -57,7 +57,7 @@ F www/c_interface.tcl 9ac800854272db5fe439e07b7435b243a5422293
 F www/changes.tcl 04e66b4257589ff78a7e1de93e9dda4725fb03d6
 F www/index.tcl 52e29a4eeda8d59e91af43c61fef177c5f2ffd53
 F www/sqlite.tcl 2f933ce18cffd34a0a020a82435ab937137970fd
-P bf98cf82a73c54c4eced04994bb1a019844dfc03
-R 147a3f5a92c9643c1c974e90b0fb5f44
+P 61c381e7e6c85619b7b494417956fc209c5b7b84
+R f79443a31154f60b0063b7fad1afe1ae
 U drh
-Z 583fb9f51c189b28ce13ee596d8aedf2
+Z a7a98045f3e2dce83769476787f9e43e
index 4d60e0e2ad0bacf63da493e30ed030c158fbb22f..18cd5ce85dfeb5979c00da7e5f2570b125edd1b5 100644 (file)
@@ -1 +1 @@
-61c381e7e6c85619b7b494417956fc209c5b7b84
\ No newline at end of file
+33355b2d8d23b51e917961b7fb336bc1d454497f
\ No newline at end of file
index 69f75e9525f3f8c388a55ba5872b34158e6544aa..2cb4c2ea7d95120589a46df9ef521dbbf9d27a8b 100644 (file)
 ** the parser.  Lemon will also generate a header file containing
 ** numeric codes for all of the tokens.
 **
-** @(#) $Id: parse.y,v 1.18 2000/06/08 15:10:47 drh Exp $
+** @(#) $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 {
-  sqliteSetNString(&pParse->zErrMsg,"syntax error near \"",0,TOKEN.z,TOKEN.n,
-                   "\"", 1, 0);
+  sqliteSetString(&pParse->zErrMsg,"syntax error",0);
   pParse->sErrToken = TOKEN;
 }
 %name sqliteParser
index b0f197efae2be2f6486244fa7411d5d6d75b7f51..c583930dde400d657b94400de9ec5675d3da913a 100644 (file)
@@ -27,7 +27,7 @@
 ** individual tokens and sends those tokens one-by-one over to the
 ** parser for analysis.
 **
-** $Id: tokenize.c,v 1.10 2000/06/08 13:36:40 drh Exp $
+** $Id: tokenize.c,v 1.11 2000/06/08 16:26:24 drh Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -211,7 +211,7 @@ int sqliteGetToken(const char *z, int *tokenType){
     case '!': {
       if( z[1]!='=' ){
         *tokenType = TK_ILLEGAL;
-        return 1;
+        return 2;
       }else{
         *tokenType = TK_NE;
         return 2;
@@ -245,23 +245,23 @@ int sqliteGetToken(const char *z, int *tokenType){
     }
     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++; }
-        if( (z[i]=='e' || z[i]=='E') &&
+        *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++; }
-        }
+      ){
+        i += 2;
+        while( z[i] && isdigit(z[i]) ){ i++; }
         *tokenType = TK_FLOAT;
       }else if( z[0]=='.' ){
         *tokenType = TK_FLOAT;
-      }else{
-        *tokenType = TK_INTEGER;
       }
       return i;
     }
@@ -363,8 +363,8 @@ int sqliteRunParser(Parse *pParse, char *zSql, char **pzErrMsg){
         break;
       }
       case TK_ILLEGAL:
-        sqliteSetNString(pzErrMsg, "illegal token: \"", -1, 
-           pParse->sLastToken.z, pParse->sLastToken.n, 0);
+        sqliteSetNString(pzErrMsg, "unrecognized token: \"", -1, 
+           pParse->sLastToken.z, pParse->sLastToken.n, "\"", 1, 0);
         nErr++;
         break;
       default:
index 332eb0b9f5c8a1be52d44632977d8e2f26a8d7ca..b6b0759274c89a2af251d2583bf5f375663ea05a 100644 (file)
@@ -41,7 +41,7 @@
 ** But other routines are also provided to help in building up
 ** a program instruction by instruction.
 **
-** $Id: vdbe.c,v 1.29 2000/06/08 15:10:48 drh Exp $
+** $Id: vdbe.c,v 1.30 2000/06/08 16:26:25 drh Exp $
 */
 #include "sqliteInt.h"
 #include <unistd.h>
@@ -426,7 +426,7 @@ static int AggInsert(Agg *p, char *zKey){
   AggElem *pElem;
   int i;
   if( p->nHash <= p->nElem*2 ){
-    AggRehash(p, p->nElem*2 + 103);
+    AggRehash(p, p->nElem*2 + 19);
   }
   if( p->nHash==0 ) return 1;
   pElem = sqliteMalloc( sizeof(AggElem) + strlen(zKey) + 1 +
index 56744cd0a715dfde445b033e90f573c47d04d3ff..d6341958a2b91e5263e9b34a26a195807a731f69 100644 (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.6 2000/06/07 15:23:56 drh Exp $
+# $Id: expr.test,v 1.7 2000/06/08 16:26:25 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -144,6 +144,7 @@ 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
@@ -161,7 +162,20 @@ 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='a?c'} {t1 NOT GLOB t2} 0
+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
index 0052921ca17c090d8bf8c99b58fa97c2dc771ded..07763e6a293a4d3650a6305617b755a540212d13 100644 (file)
@@ -23,7 +23,7 @@
 # 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.1 2000/06/07 15:11:27 drh Exp $
+# $Id: main.test,v 1.2 2000/06/08 16:26:25 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -62,4 +62,49 @@ do_test main-2.0 {
   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
index 0fa0850d818072f71482ce3486f1c0c9aa8ac165..f6bd150979a026d8d584007f546c6ee26b5ada96 100644 (file)
@@ -24,7 +24,7 @@
 # focus of this file is testing aggregate functions and the
 # GROUP BY and HAVING clauses of SELECT statements.
 #
-# $Id: select5.test,v 1.2 2000/06/08 11:25:01 drh Exp $
+# $Id: select5.test,v 1.3 2000/06/08 16:26:25 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -59,4 +59,53 @@ 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
index cd0a2047d8869cc96550f03f63cd82aa0c15df8a..94e24205c8f6a5589a35b3940825f1e7ba02b3ac 100644 (file)
@@ -23,7 +23,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this file is testing the UPDATE statement.
 #
-# $Id: update.test,v 1.1 2000/05/30 03:12:22 drh Exp $
+# $Id: update.test,v 1.2 2000/06/08 16:26:25 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -110,6 +110,32 @@ 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}}