diff options
-rw-r--r-- | manifest | 21 | ||||
-rw-r--r-- | manifest.uuid | 2 | ||||
-rw-r--r-- | src/build.c | 70 | ||||
-rw-r--r-- | test/delete.test | 4 | ||||
-rw-r--r-- | test/index.test | 8 | ||||
-rw-r--r-- | test/insert.test | 6 | ||||
-rw-r--r-- | test/table.test | 22 | ||||
-rw-r--r-- | test/update.test | 119 |
8 files changed, 186 insertions, 66 deletions
@@ -1,12 +1,12 @@ -C :-)\s(CVS\s11) -D 2000-05-30T00:51:27 +C :-)\s(CVS\s12) +D 2000-05-30T03:12:21 F COPYRIGHT 74a8a6531a42e124df07ab5599aad63870fa0bd4 F Makefile.in 89921c1ee4de75275bfadfbac198396da31704d1 F README 6b5960603c7f8bf42fc022b4b6436f242f238dbb F configure 00a5b5c82147a576fa6e82d7c1b0d55c321d6d2c x F configure.in 6ccfd5fc80517f7cfe605a7fc7e0f62d962a233c F doc/lemon.html e233a3e97a779c7a87e1bc4528c664a58e49dd47 -F src/build.c 6c7b4b79ed4c2caeb33dd66c1e3c3d6e062f0d60 +F src/build.c 94d1bda19f4129991e4e8bef2278a0398a49b0ec F src/dbbe.c ab05293e89525041eaab8b4aca10516db3648792 F src/dbbe.h bedeb3a0985bb584458e7849fb59927e99e751e6 F src/main.c 25cce7bce0eb3ba10bada7c05f4b38dc6dbbc86f @@ -21,11 +21,12 @@ F src/vdbe.c 80132b6bb9a744d1990a1c16666d54baaff2dbc3 F src/vdbe.h e721ad308f2e6ca805cebc4dd0a196ce4419d030 F src/where.c 67ffea57920e16b33c580e9a9b9855b3ec9dea7b F test/all.test 66a8a5b8291a472157944edcdce51a320ebd1f35 -F test/delete.test bfa5a1d39b07a28f1e6c22044d78108ded6e60e7 -F test/index.test 37cd05c590469d72c5a9299b510eb6bea00ada28 -F test/insert.test e9a927aa60ff34bb04143a38e5628cc3074457b4 -F test/table.test 7eea7cd2a055b694fb1ba6b5de83ed7d78870b61 +F test/delete.test 814d53e3b0d2d7069fb17e005d4041454d6585d4 +F test/index.test 8d4f26901a5582daa353fe3c8266cbf4a53af830 +F test/insert.test 161bc67a4189738c559e3569323ceae31f4d49d6 +F test/table.test b1afc2f6d4989f9ce911acbf711ac5d7ae521eb7 F test/tester.tcl 70d25b7ced0a958bc377c72399b3dc6bf6a2d09e +F test/update.test 69459302ea75cafac1479e60b0e36efb88123c0e F tool/gdbmdump.c 529e67c78d920606ba196326ea55b57b75fcc82b F tool/lemon.c cff35578b3c4d1491021b6418016639ebe21b1a5 F tool/lempar.c a1eec94d6eacc12332368660ec65f3b248853833 @@ -35,7 +36,7 @@ F tool/renumberOps.awk 6d067177ad5f8d711b79577b462da9b3634bd0a9 F www/c_interface.tcl f875864edf7974157d1c257ca08de854660882a5 F www/index.tcl 2466d1b2e26c6f354b0acedee12025309a216799 F www/sqlite.tcl 947e067bcc347dc767af4c1a6e5a8d47d8404aa3 -P 1c1d9c0d4ad91cf0b077f4fff82499dcafae36d7 -R 3873d46fc99cb65f2b72af28e1592d68 +P 9818723ee127bc535e79f6876546cc027b4999e6 +R 1a430f86cc22b988f5aa7dc8de33740d U drh -Z eb44043639c5eea1b0351d3c17d1a099 +Z 3a408137acde4ba4c4136a81536a81e2 diff --git a/manifest.uuid b/manifest.uuid index 5b1ab8d8c..6fe94e9d6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9818723ee127bc535e79f6876546cc027b4999e6
\ No newline at end of file +20f2811fc19f937ed03bdb0e9d87a40c75452b17
\ No newline at end of file diff --git a/src/build.c b/src/build.c index 9407b4381..dbb227a28 100644 --- a/src/build.c +++ b/src/build.c @@ -24,7 +24,7 @@ ** This file contains C code routines that are called by the parser ** when syntax rules are reduced. ** -** $Id: build.c,v 1.4 2000/05/30 00:51:27 drh Exp $ +** $Id: build.c,v 1.5 2000/05/30 03:12:21 drh Exp $ */ #include "sqliteInt.h" @@ -207,15 +207,15 @@ void sqliteStartTable(Parse *pParse, Token *pStart, Token *pName){ zName = sqliteTableNameFromToken(pName); pTable = sqliteFindTable(pParse->db, zName); if( pTable!=0 ){ - sqliteSetNString(&pParse->zErrMsg, "table \"", 0, pName->z, pName->n, - "\" already exists", 0, 0); + sqliteSetNString(&pParse->zErrMsg, "table ", 0, pName->z, pName->n, + " already exists", 0, 0); sqliteFree(zName); pParse->nErr++; return; } if( sqliteFindIndex(pParse->db, zName) ){ - sqliteSetString(&pParse->zErrMsg, "there is already an index named \"", - zName, "\"", 0); + sqliteSetString(&pParse->zErrMsg, "there is already an index named ", + zName, 0); sqliteFree(zName); pParse->nErr++; return; @@ -338,8 +338,8 @@ void sqliteDropTable(Parse *pParse, Token *pName){ pTable = sqliteTableFromToken(pParse, pName); if( pTable==0 ) return; if( pTable->readOnly ){ - sqliteSetString(&pParse->zErrMsg, "table \"", pTable->zName, - "\" may not be dropped", 0); + sqliteSetString(&pParse->zErrMsg, "table ", pTable->zName, + " may not be dropped", 0); pParse->nErr++; return; } @@ -447,14 +447,14 @@ void sqliteCreateIndex( sqliteSetString(&zName, pTab->zName, "__primary_key", 0); } if( sqliteFindIndex(pParse->db, zName) ){ - sqliteSetString(&pParse->zErrMsg, "index \"", zName, - "\" already exists", 0); + sqliteSetString(&pParse->zErrMsg, "index ", zName, + " already exists", 0); pParse->nErr++; goto exit_create_index; } if( sqliteFindTable(pParse->db, zName) ){ - sqliteSetString(&pParse->zErrMsg, "there is already a table named \"", - zName, "\"", 0); + sqliteSetString(&pParse->zErrMsg, "there is already a table named ", + zName, 0); pParse->nErr++; goto exit_create_index; } @@ -596,8 +596,8 @@ void sqliteDropIndex(Parse *pParse, Token *pName){ pIndex = sqliteFindIndex(pParse->db, zName); sqliteFree(zName); if( pIndex==0 ){ - sqliteSetNString(&pParse->zErrMsg, "no such index: \"", 0, - pName->z, pName->n, "\"", 1, 0); + sqliteSetNString(&pParse->zErrMsg, "no such index: ", 0, + pName->z, pName->n, 0); pParse->nErr++; return; } @@ -753,14 +753,14 @@ void sqliteInsert( pTab = sqliteFindTable(pParse->db, zTab); sqliteFree(zTab); if( pTab==0 ){ - sqliteSetNString(&pParse->zErrMsg, "no such table: \"", 0, - pTableName->z, pTableName->n, "\"", 1, 0); + sqliteSetNString(&pParse->zErrMsg, "no such table: ", 0, + pTableName->z, pTableName->n, 0); pParse->nErr++; goto insert_cleanup; } if( pTab->readOnly ){ - sqliteSetString(&pParse->zErrMsg, "table \"", pTab->zName, - "\" may not be modified", 0); + sqliteSetString(&pParse->zErrMsg, "table ", pTab->zName, + " may not be modified", 0); pParse->nErr++; goto insert_cleanup; } @@ -893,13 +893,13 @@ int sqliteExprResolveIds(Parse *pParse, IdList *pTabList, Expr *pExpr){ } } if( cnt==0 ){ - sqliteSetNString(&pParse->zErrMsg, "unknown field name: \"", -1, - pExpr->token.z, pExpr->token.n, "\"", -1, 0); + sqliteSetNString(&pParse->zErrMsg, "no such field: ", -1, + pExpr->token.z, pExpr->token.n, 0); pParse->nErr++; return 1; }else if( cnt>1 ){ - sqliteSetNString(&pParse->zErrMsg, "ambiguous field name: \"", -1, - pExpr->token.z, pExpr->token.n, "\"", -1, 0); + sqliteSetNString(&pParse->zErrMsg, "ambiguous field name: ", -1, + pExpr->token.z, pExpr->token.n, 0); pParse->nErr++; return 1; } @@ -941,13 +941,13 @@ int sqliteExprResolveIds(Parse *pParse, IdList *pTabList, Expr *pExpr){ } } if( cnt==0 ){ - sqliteSetNString(&pParse->zErrMsg, "unknown field name: \"", -1, - pLeft->token.z, pLeft->token.n, ".", 1, z, n, "\"", 1, 0); + sqliteSetNString(&pParse->zErrMsg, "no such field: ", -1, + pLeft->token.z, pLeft->token.n, ".", 1, z, n, 0); pParse->nErr++; return 1; }else if( cnt>1 ){ - sqliteSetNString(&pParse->zErrMsg, "ambiguous field name: \"", -1, - pExpr->token.z, pExpr->token.n, ".", 1, z, n, "\"", 1, 0); + sqliteSetNString(&pParse->zErrMsg, "ambiguous field name: ", -1, + pExpr->token.z, pExpr->token.n, ".", 1, z, n, 0); pParse->nErr++; return 1; } @@ -1004,8 +1004,8 @@ void sqliteSelect( for(i=0; i<pTabList->nId; i++){ pTabList->a[i].pTab = sqliteFindTable(pParse->db, pTabList->a[i].zName); if( pTabList->a[i].pTab==0 ){ - sqliteSetString(&pParse->zErrMsg, "unknown table \"", - pTabList->a[i].zName, "\"", 0); + sqliteSetString(&pParse->zErrMsg, "no such table: ", + pTabList->a[i].zName, 0); pParse->nErr++; goto select_cleanup; } @@ -1179,8 +1179,8 @@ void sqliteDeleteFrom( goto delete_from_cleanup; } if( pTabList->a[i].pTab->readOnly ){ - sqliteSetString(&pParse->zErrMsg, "table \"", pTabList->a[i].zName, - "\" may not be modified", 0); + sqliteSetString(&pParse->zErrMsg, "table ", pTabList->a[i].zName, + " may not be modified", 0); pParse->nErr++; goto delete_from_cleanup; } @@ -1277,14 +1277,14 @@ void sqliteUpdate( for(i=0; i<pTabList->nId; i++){ pTabList->a[i].pTab = sqliteFindTable(pParse->db, pTabList->a[i].zName); if( pTabList->a[i].pTab==0 ){ - sqliteSetString(&pParse->zErrMsg, "unknown table \"", - pTabList->a[i].zName, "\"", 0); + sqliteSetString(&pParse->zErrMsg, "no such table: ", + pTabList->a[i].zName, 0); pParse->nErr++; goto update_cleanup; } if( pTabList->a[i].pTab->readOnly ){ - sqliteSetString(&pParse->zErrMsg, "table \"", pTabList->a[i].zName, - "\" may not be modified", 0); + sqliteSetString(&pParse->zErrMsg, "table ", pTabList->a[i].zName, + " may not be modified", 0); pParse->nErr++; goto update_cleanup; } @@ -1313,8 +1313,8 @@ void sqliteUpdate( } } if( j>=pTab->nCol ){ - sqliteSetString(&pParse->zErrMsg, "no such field: \"", - pChanges->a[i].zName, "\"", 0); + sqliteSetString(&pParse->zErrMsg, "no such field: ", + pChanges->a[i].zName, 0); pParse->nErr++; goto update_cleanup; } diff --git a/test/delete.test b/test/delete.test index 4be52ee70..c745afa15 100644 --- a/test/delete.test +++ b/test/delete.test @@ -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.1 2000/05/30 00:51:27 drh Exp $ +# $Id: delete.test,v 1.2 2000/05/30 03:12:22 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -40,7 +40,7 @@ do_test delete-1.1 { do_test delete-2.1 { set v [catch {execsql {DELETE FROM sqlite_master}} msg] lappend v $msg -} {1 {table "sqlite_master" may not be modified}} +} {1 {table sqlite_master may not be modified}} diff --git a/test/index.test b/test/index.test index f53cc9d3f..e760fe019 100644 --- a/test/index.test +++ b/test/index.test @@ -23,7 +23,7 @@ # This file implements regression tests for SQLite library. The # focus of this file is testing the CREATE INDEX statement. # -# $Id: index.test,v 1.1 2000/05/29 23:58:12 drh Exp $ +# $Id: index.test,v 1.2 2000/05/30 03:12:22 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -167,14 +167,14 @@ do_test index-6.1 { execsql {CREATE INDEX index1 ON test1(f1)} set v [catch {execsql {CREATE INDEX index1 ON test2(g1)}} msg] lappend v $msg -} {1 {index "index1" already exists}} +} {1 {index index1 already exists}} do_test index-6.1b { execsql {SELECT name FROM sqlite_master ORDER BY name} } {index1 test1 test2} do_test index-6.2 { set v [catch {execsql {CREATE INDEX test1 ON test2(g1)}} msg] lappend v $msg -} {1 {there is already a table named "test1"}} +} {1 {there is already a table named test1}} do_test index-6.2b { execsql {SELECT name FROM sqlite_master ORDER BY name} } {index1 test1 test2} @@ -210,7 +210,7 @@ do_test index-7.4 { do_test index-8.1 { set v [catch {execsql {DROP INDEX index1}} msg] lappend v $msg -} {1 {no such index: "index1"}} +} {1 {no such index: index1}} diff --git a/test/insert.test b/test/insert.test index e5bdb669d..2bb4c6d00 100644 --- a/test/insert.test +++ b/test/insert.test @@ -23,7 +23,7 @@ # This file implements regression tests for SQLite library. The # focus of this file is testing the INSERT statement. # -# $Id: insert.test,v 1.1 2000/05/30 00:51:27 drh Exp $ +# $Id: insert.test,v 1.2 2000/05/30 03:12:22 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -33,14 +33,14 @@ source $testdir/tester.tcl do_test insert-1.1 { set v [catch {execsql {INSERT INTO test1 VALUES(1,2,3)}} msg] lappend v $msg -} {1 {no such table: "test1"}} +} {1 {no such table: test1}} # Try to insert into sqlite_master # do_test insert-1.2 { set v [catch {execsql {INSERT INTO sqlite_master VALUES(1,2,3,4)}} msg] lappend v $msg -} {1 {table "sqlite_master" may not be modified}} +} {1 {table sqlite_master may not be modified}} # Try to insert the wrong number of entries. # diff --git a/test/table.test b/test/table.test index 24c6bb45a..9c54a9596 100644 --- a/test/table.test +++ b/test/table.test @@ -23,7 +23,7 @@ # This file implements regression tests for SQLite library. The # focus of this file is testing the CREATE TABLE statement. # -# $Id: table.test,v 1.1 2000/05/29 23:58:12 drh Exp $ +# $Id: table.test,v 1.2 2000/05/30 03:12:22 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -96,17 +96,17 @@ do_test table-2.1 { execsql {CREATE TABLE test2(one text)} set v [catch {execsql {CREATE TABLE test2(two text)}} msg] lappend v $msg -} {1 {table "test2" already exists}} +} {1 {table test2 already exists}} do_test table-2.1b { set v [catch {execsql {CREATE TABLE sqlite_master(two text)}} msg] lappend v $msg -} {1 {table "sqlite_master" already exists}} +} {1 {table sqlite_master already exists}} do_test table-2.1c { db close sqlite db testdb set v [catch {execsql {CREATE TABLE sqlite_master(two text)}} msg] lappend v $msg -} {1 {table "sqlite_master" already exists}} +} {1 {table sqlite_master already exists}} do_test table-2.1d { execsql {DROP TABLE test2; SELECT name FROM sqlite_master} } {} @@ -117,13 +117,13 @@ do_test table-2.2 { execsql {CREATE TABLE test2(one text); CREATE INDEX test3 ON test2(one)} set v [catch {execsql {CREATE TABLE test3(two text)}} msg] lappend v $msg -} {1 {there is already an index named "test3"}} +} {1 {there is already an index named test3}} do_test table-2.2b { db close sqlite db testdb set v [catch {execsql {CREATE TABLE test3(two text)}} msg] lappend v $msg -} {1 {there is already an index named "test3"}} +} {1 {there is already an index named test3}} do_test table-2.2c { execsql {DROP INDEX test3} set v [catch {execsql {CREATE TABLE test3(two text)}} msg] @@ -169,21 +169,21 @@ do_test table-3.1 { do_test table-3.2 { set v [catch {execsql {CREATE TABLE BIG(xyz foo)}} msg] lappend v $msg -} {1 {table "BIG" already exists}} +} {1 {table BIG already exists}} do_test table-3.3 { set v [catch {execsql {CREATE TABLE biG(xyz foo)}} msg] lappend v $msg -} {1 {table "biG" already exists}} +} {1 {table biG already exists}} do_test table-3.4 { set v [catch {execsql {CREATE TABLE bIg(xyz foo)}} msg] lappend v $msg -} {1 {table "bIg" already exists}} +} {1 {table bIg already exists}} do_test table-3.5 { db close sqlite db testdb set v [catch {execsql {CREATE TABLE Big(xyz foo)}} msg] lappend v $msg -} {1 {table "Big" already exists}} +} {1 {table Big already exists}} do_test table-3.6 { execsql {DROP TABLE big} execsql {SELECT name FROM sqlite_master} @@ -248,7 +248,7 @@ do_test table-5.1 { do_test table-5.2 { set v [catch {execsql {DROP TABLE sqlite_master}} msg] lappend v $msg -} {1 {table "sqlite_master" may not be dropped}} +} {1 {table sqlite_master may not be dropped}} # Make sure an EXPLAIN does not really create a new table # diff --git a/test/update.test b/test/update.test new file mode 100644 index 000000000..cd0a2047d --- /dev/null +++ b/test/update.test @@ -0,0 +1,119 @@ +# 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 UPDATE statement. +# +# $Id: update.test,v 1.1 2000/05/30 03:12:22 drh Exp $ + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +# Try to update an non-existent table +# +do_test update-1.1 { + set v [catch {execsql {UPDATE test1 SET f2=5 WHERE f1<1}} msg] + lappend v $msg +} {1 {no such table: test1}} + +# Try to update a read-only table +# +do_test update-2.1 { + set v [catch \ + {execsql {UPDATE sqlite_master SET name='xyz' WHERE name='123'}} msg] + lappend v $msg +} {1 {table sqlite_master may not be modified}} + +# Create a table to work with +# +do_test update-3.1 { + execsql {CREATE TABLE test1(f1 int,f2 int)} + for {set i 1} {$i<=10} {incr i} { + set sql "INSERT INTO test1 VALUES($i,[expr {int(pow(2,$i))}])" + execsql $sql + } + execsql {SELECT * FROM test1 ORDER BY f1} +} {1 2 2 4 3 8 4 16 5 32 6 64 7 128 8 256 9 512 10 1024} + +# Unknown field name in an expression +# +do_test update-3.2 { + set v [catch {execsql {UPDATE test1 SET f1=f3*2 WHERE f2==32}} msg] + lappend v $msg +} {1 {no such field: f3}} +do_test update-3.3 { + set v [catch {execsql {UPDATE test1 SET f1=test2.f1*2 WHERE f2==32}} msg] + lappend v $msg +} {1 {no such field: test2.f1}} +do_test update-3.4 { + set v [catch {execsql {UPDATE test1 SET f3=f1*2 WHERE f2==32}} msg] + lappend v $msg +} {1 {no such field: f3}} + +# Actually do some updates +# +do_test update-3.5 { + execsql {UPDATE test1 SET f2=f2*3} + execsql {SELECT * FROM test1 ORDER BY f1} +} {1 6 2 12 3 24 4 48 5 96 6 192 7 384 8 768 9 1536 10 3072} +do_test update-3.6 { + execsql {UPDATE test1 SET f2=f2/3 WHERE f1<=5} + execsql {SELECT * FROM test1 ORDER BY f1} +} {1 2 2 4 3 8 4 16 5 32 6 192 7 384 8 768 9 1536 10 3072} +do_test update-3.7 { + execsql {UPDATE test1 SET f2=f2/3 WHERE f1>5} + execsql {SELECT * FROM test1 ORDER BY f1} +} {1 2 2 4 3 8 4 16 5 32 6 64 7 128 8 256 9 512 10 1024} + +# Swap the values of f1 and f2 for all elements +# +do_test update-3.8 { + execsql {UPDATE test1 SET f2=f1, f1=f2} + 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 1024 10} + +# Create an index and make sure updating works with an index. +# +do_test update-3.9 { + execsql {CREATE INDEX index1 ON test1(f1)} + execsql {CREATE INDEX index2 ON test1(f1)} + execsql {UPDATE test1 SET f1=1025 WHERE f2==10} + 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 10} +do_test update-3.10 { + execsql {SELECT * FROM test1 WHERE f1=1025} +} {1025 10} +do_test update-3.11 { + 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 |