2 #pragma ident "%Z%%M% %I% %E% SMI"
6 # The author disclaims copyright to this source code. In place of
7 # a legal notice, here is a blessing:
9 # May you do good and not evil.
10 # May you find forgiveness for yourself and forgive others.
11 # May you share freely, never taking more than you give.
13 #***********************************************************************
14 # This file implements regression tests for SQLite library. The
15 # focus of this file is exercising the code in main.c.
17 # $Id: main.test,v 1.14 2003/05/04 17:58:27 drh Exp $
19 set testdir [file dirname $argv0]
20 source $testdir/tester.tcl
22 # Tests of the sqlite_complete() function.
25 db complete {This is a test}
43 db complete {DROP TABLE 'xyz;}
46 db complete {DROP TABLE 'xyz';}
49 db complete {DROP TABLE "xyz;}
52 db complete {DROP TABLE "xyz';}
55 db complete {DROP TABLE "xyz";}
58 db complete {DROP TABLE xyz; hi}
61 db complete {DROP TABLE xyz; }
64 db complete {DROP TABLE xyz; -- hi }
67 db complete {DROP TABLE xyz; -- hi
71 db complete {SELECT a-b FROM t1; }
74 db complete {SELECT a-b FROM t1 }
78 CREATE TABLE abc(x,y);
83 CREATE TRIGGER xyz AFTER DELETE abc BEGIN UPDATE pqr;
88 CREATE TRIGGER xyz AFTER DELETE abc BEGIN UPDATE pqr; END;
93 CREATE TRIGGER xyz AFTER DELETE abc BEGIN
100 CREATE TRIGGER xyz AFTER DELETE backend BEGIN
106 CREATE TRIGGER xyz AFTER DELETE end BEGIN
107 SELECT a, b FROM end;
112 CREATE TRIGGER xyz AFTER DELETE end BEGIN
113 SELECT a, b FROM end;
119 CREATE TRIGGER xyz AFTER DELETE end BEGIN
120 SELECT a, b FROM end;
122 SELECT a, b FROM end;
127 CREATE TRIGGER xyz AFTER DELETE [;end;] BEGIN
133 CREATE TRIGGER xyz AFTER DELETE backend BEGIN
134 UPDATE pqr SET a=[;end;];;;
140 TRIGGER xyz AFTER DELETE backend BEGIN
144 do_test main-1.27.1 {
147 TRIGGERX xyz AFTER DELETE backend BEGIN
151 do_test main-1.27.2 {
153 CREATE/**/TRIGGER xyz AFTER DELETE backend BEGIN
157 do_test main-1.27.3 {
159 /* */ EXPLAIN -- A comment
160 CREATE/**/TRIGGER xyz AFTER DELETE backend BEGIN
164 do_test main-1.27.4 {
167 CREATE TRIGGER xyz AFTER DELETE backend BEGIN
171 do_test main-1.27.5 {
174 CREATE TEMP TRIGGER xyz AFTER DELETE backend BEGIN
180 CREATE TEMP TRIGGER xyz AFTER DELETE backend BEGIN
186 CREATE TRIGGER xyz AFTER DELETE backend BEGIN
188 EXPLAIN select * from xyz;
193 CREATE TABLE /* In comment ; */
198 CREATE TABLE /* In comment ; */ hi;
203 CREATE TABLE /* In comment ; */;
233 db complete {hi /**/ there;}
236 db complete {hi there/***/;}
240 # Try to open a database with a corrupt database file.
244 file delete -force test.db
245 set fd [open test.db w]
248 set v [catch {sqlite db test.db} msg]
249 if {$v} {lappend v $msg} {lappend v {}}
252 # Here are some tests for tokenize.c.
256 foreach f [glob -nocomplain testdb/*] {file delete -force $f}
257 file delete -force testdb
259 set v [catch {execsql {SELECT * from T1 where x!!5}} msg]
261 } {1 {unrecognized token: "!!"}}
264 foreach f [glob -nocomplain testdb/*] {file delete -force $f}
265 file delete -force testdb
267 set v [catch {execsql {SELECT * from T1 where @x}} msg]
269 } {1 {unrecognized token: "@"}}
273 foreach f [glob -nocomplain testdb/*] {file delete -force $f}
274 file delete -force testdb
277 create table T1(X REAL);
278 insert into T1 values(0.5);
279 insert into T1 values(0.5e2);
280 insert into T1 values(0.5e-002);
281 insert into T1 values(5e-002);
282 insert into T1 values(-5.0e-2);
283 insert into T1 values(-5.1e-2);
284 insert into T1 values(0.5e2);
285 insert into T1 values(0.5E+02);
286 insert into T1 values(5E+02);
287 insert into T1 values(5.0E+03);
288 select x*10 from T1 order by x*5;
290 } {-0.51 -0.5 0.05 0.5 5 500 500 500 5000 50000}
292 set v [catch {execsql {create bogus}} msg]
294 } {1 {near "bogus": syntax error}}
296 set v [catch {execsql {create}} msg]
298 } {1 {near "create": syntax error}}