From cc85b411c7ebc33a9012aa3be430f117e889e77f Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 7 Jun 2000 15:11:27 +0000 Subject: [PATCH] :-) (CVS 70) FossilOrigin-Name: d3baa046c946a2c4d5567ee57d96a6c8aa5740b9 --- manifest | 19 +++++++------- manifest.uuid | 2 +- src/insert.c | 4 +-- src/main.c | 4 +-- test/insert2.test | 14 +++++++++- test/main.test | 65 +++++++++++++++++++++++++++++++++++++++++++++++ test/select1.test | 9 +++++-- 7 files changed, 100 insertions(+), 17 deletions(-) create mode 100644 test/main.test diff --git a/manifest b/manifest index 1c89b56bd5..d968a8cd95 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C :-)\s(CVS\s69) -D 2000-06-07T14:42:27 +C :-)\s(CVS\s70) +D 2000-06-07T15:11:27 F COPYRIGHT 74a8a6531a42e124df07ab5599aad63870fa0bd4 F Makefile.in 17ba1ccf8d2d40c627796bba8f72952365d6d644 F README 51f6a4e7408b34afa5bc1c0485f61b6a4efb6958 @@ -11,8 +11,8 @@ F src/dbbe.c 9b191b16ff01ec5bc0af436558501d07938ba4f0 F src/dbbe.h a8a46f71238e0f09f3ec08fd9d1c8c7f4cdc49bf F src/delete.c 8c733bb82a1b84126116d03dcdccf433c0856f5d F src/expr.c d350fe393e1753aaa733a5d21f0830a23e547400 -F src/insert.c 8bd762bb6aa7bf0e6abda03699c88db7736bf7dd -F src/main.c 48440ddd39783ac379c746804e3424e06cdf7138 +F src/insert.c 93f9e36bf96b57326d8d5709ed44b568b8627aa5 +F src/main.c b4275952180b30e1ca3db266157e2d233c0a24d9 F src/parse.y 4a2e6b14177c97f61fc3e21d4570f5a9c541c1e1 F src/select.c 4834ab68a3308871f17fe8e22d903fcdf1b42420 F src/shell.c 3f4afc39a36e4824e8aa262623fd03568874799e @@ -33,8 +33,9 @@ F test/expr.test 52be5592143a88479e0006dfd7e2023e43294636 F test/in.test 17cd46a9ca0e5d4a804483e6fb496458494858e6 F test/index.test 9f99dca2d904b8de330863a978587f136e2df65a F test/insert.test 66f4c3bd600fec8eb1e733b928cbe6fa885eff0c -F test/insert2.test 2d529bc4acf33dcf554a8c2e4593aab270fa6faf -F test/select1.test 55af6d31c778022ac3eecd051a66e9df3573c46f +F test/insert2.test 732405e30331635af8d159fccabe835eea5cd0c6 +F test/main.test cf1e9035aca55da9ef6d3b73ab36c54b7514b83f +F test/select1.test 64703852af34c85bb31b0a74bd73b340e8267f42 F test/select2.test 3cd3c0f9d67e98b1b54af5853679b4a111224410 F test/select3.test 73ae8c7b80c4e03a9c29d12f2ea1782e28b8e61f F test/sort.test d582086c4bb7df3fbf50aa72e69d7e235e9f8e31 @@ -53,7 +54,7 @@ F www/c_interface.tcl 9ac800854272db5fe439e07b7435b243a5422293 F www/changes.tcl 04e66b4257589ff78a7e1de93e9dda4725fb03d6 F www/index.tcl 52e29a4eeda8d59e91af43c61fef177c5f2ffd53 F www/sqlite.tcl 2f933ce18cffd34a0a020a82435ab937137970fd -P 5d773b5d4e9c23b81f53afd0cef7bd2300fff329 -R 57fdc174a06c58f4d8c32ca7ec794547 +P e4f6b17f66ddbb0bcf13bb9fffc98e5c102151ef +R ce3737a50e7c1b7f05029b62a126b877 U drh -Z 30c18345d5ffdb7b0aa9296432256266 +Z 7bf9f75d63299255b8d69e32b524ad36 diff --git a/manifest.uuid b/manifest.uuid index dd0a6c9fb0..4825fba7b0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e4f6b17f66ddbb0bcf13bb9fffc98e5c102151ef \ No newline at end of file +d3baa046c946a2c4d5567ee57d96a6c8aa5740b9 \ No newline at end of file diff --git a/src/insert.c b/src/insert.c index 40178a9d25..204c6facd3 100644 --- a/src/insert.c +++ b/src/insert.c @@ -24,7 +24,7 @@ ** This file contains C code routines that are called by the parser ** to handle INSERT statements. ** -** $Id: insert.c,v 1.7 2000/06/07 14:42:27 drh Exp $ +** $Id: insert.c,v 1.8 2000/06/07 15:11:27 drh Exp $ */ #include "sqliteInt.h" @@ -184,7 +184,7 @@ void sqliteInsert( sqliteVdbeAddOp(v, OP_String, 0, 0, zDflt, 0); } }else if( srcTab>=0 ){ - sqliteVdbeAddOp(v, OP_Field, srcTab, i, 0, 0); + sqliteVdbeAddOp(v, OP_Field, srcTab, idx, 0, 0); }else{ sqliteExprCode(pParse, pList->a[j].pExpr); } diff --git a/src/main.c b/src/main.c index 8f0c561e03..8a388a01f2 100644 --- a/src/main.c +++ b/src/main.c @@ -26,7 +26,7 @@ ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** -** $Id: main.c,v 1.10 2000/06/07 14:42:27 drh Exp $ +** $Id: main.c,v 1.11 2000/06/07 15:11:27 drh Exp $ */ #include "sqliteInt.h" @@ -185,7 +185,7 @@ sqlite *sqlite_open(const char *zFilename, int mode, char **pzErrMsg){ sqlite_close(db); return 0; }else{ - sqliteFree(*pzErrMsg); + free(*pzErrMsg); *pzErrMsg = 0; } return db; diff --git a/test/insert2.test b/test/insert2.test index de87a75b92..e100f9cf80 100644 --- a/test/insert2.test +++ b/test/insert2.test @@ -24,7 +24,7 @@ # focus of this file is testing the INSERT statement that takes is # result from a SELECT. # -# $Id: insert2.test,v 1.1 2000/06/07 14:42:27 drh Exp $ +# $Id: insert2.test,v 1.2 2000/06/07 15:11:27 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -69,5 +69,17 @@ do_test insert2-1.3 { SELECT * FROM t1 ORDER BY log; } } {1 1 2 2} +do_test insert2-1.4 { + catch {execsql {DROP TABLE t1}} + set r [execsql { + CREATE TABLE t1(log int, cnt int); + CREATE INDEX i1 ON t1(log); + CREATE INDEX i2 ON t1(cnt); + INSERT INTO t1 SELECT log, count() FROM d1 GROUP BY log; + SELECT * FROM t1 ORDER BY log; + }] + lappend r [execsql {SELECT cnt FROM t1 WHERE log=3}] + lappend r [execsql {SELECT log FROM t1 WHERE cnt=4 ORDER BY log}] +} {0 1 1 1 2 2 3 4 4 8 5 4 4 {3 5}} finish_test diff --git a/test/main.test b/test/main.test new file mode 100644 index 0000000000..0052921ca1 --- /dev/null +++ b/test/main.test @@ -0,0 +1,65 @@ +# 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 exercising the code in main.c. +# +# $Id: main.test,v 1.1 2000/06/07 15:11:27 drh Exp $ + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +# Tests of the sqlite_complete() function. +# +do_test main-1.1 { + db complete {This is a test} +} {0} +do_test main-1.2 { + db complete { + } +} {0} +do_test main-1.3 { + db complete { + -- a comment ; + } +} {0} +do_test main-1.4 { + db complete { + -- a comment ; + ; + } +} {1} + +# Try to open a database with a corrupt master file. +# +do_test main-2.0 { + catch {db close} + file delete -force testdb + 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 diff --git a/test/select1.test b/test/select1.test index 235d4b5f18..b415a596b1 100644 --- a/test/select1.test +++ b/test/select1.test @@ -23,7 +23,7 @@ # This file implements regression tests for SQLite library. The # focus of this file is testing the SELECT statement. # -# $Id: select1.test,v 1.4 2000/06/07 14:42:27 drh Exp $ +# $Id: select1.test,v 1.5 2000/06/07 15:11:27 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -281,11 +281,16 @@ do_test select1-6.8 { ORDER BY f2}} msg] lappend v $msg } {1 {ambiguous field name: f1}} -do_test select1-6.8 { +do_test select1-6.8b { set v [catch {execsql2 {SELECT A.f1, B.f1 FROM test1 as A, test1 as B ORDER BY f2}} msg] lappend v $msg } {1 {ambiguous field name: f2}} +do_test select1-6.8c { + set v [catch {execsql2 {SELECT A.f1, f1 FROM test1 as A, test1 as A + ORDER BY f2}} msg] + lappend v $msg +} {1 {ambiguous field name: A.f1}} do_test select1-6.9 { set v [catch {execsql2 {SELECT A.f1, B.f1 FROM test1 as A, test1 as B ORDER BY A.f1, B.f1}} msg]