1
0

misc1.test 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. # 2001 September 15.
  2. #
  3. # The author disclaims copyright to this source code. In place of
  4. # a legal notice, here is a blessing:
  5. #
  6. # May you do good and not evil.
  7. # May you find forgiveness for yourself and forgive others.
  8. # May you share freely, never taking more than you give.
  9. #
  10. #***********************************************************************
  11. # This file implements regression tests for SQLite library.
  12. #
  13. # This file implements tests for miscellanous features that were
  14. # left out of other test files.
  15. #
  16. # $Id: misc1.test,v 1.42 2007/11/05 14:58:23 drh Exp $
  17. set testdir [file dirname $argv0]
  18. source $testdir/tester.tcl
  19. # Mimic the SQLite 2 collation type NUMERIC.
  20. db collate numeric numeric_collate
  21. proc numeric_collate {lhs rhs} {
  22. if {$lhs == $rhs} {return 0}
  23. return [expr ($lhs>$rhs)?1:-1]
  24. }
  25. # Mimic the SQLite 2 collation type TEXT.
  26. db collate text text_collate
  27. proc numeric_collate {lhs rhs} {
  28. return [string compare $lhs $rhs]
  29. }
  30. # Test the creation and use of tables that have a large number
  31. # of columns.
  32. #
  33. do_test misc1-1.1 {
  34. set cmd "CREATE TABLE manycol(x0 text"
  35. for {set i 1} {$i<=99} {incr i} {
  36. append cmd ",x$i text"
  37. }
  38. append cmd ")";
  39. execsql $cmd
  40. set cmd "INSERT INTO manycol VALUES(0"
  41. for {set i 1} {$i<=99} {incr i} {
  42. append cmd ",$i"
  43. }
  44. append cmd ")";
  45. execsql $cmd
  46. execsql "SELECT x99 FROM manycol"
  47. } 99
  48. do_test misc1-1.2 {
  49. execsql {SELECT x0, x10, x25, x50, x75 FROM manycol}
  50. } {0 10 25 50 75}
  51. do_test misc1-1.3.1 {
  52. for {set j 100} {$j<=1000} {incr j 100} {
  53. set cmd "INSERT INTO manycol VALUES($j"
  54. for {set i 1} {$i<=99} {incr i} {
  55. append cmd ",[expr {$i+$j}]"
  56. }
  57. append cmd ")"
  58. execsql $cmd
  59. }
  60. execsql {SELECT x50 FROM manycol ORDER BY x80+0}
  61. } {50 150 250 350 450 550 650 750 850 950 1050}
  62. do_test misc1-1.3.2 {
  63. execsql {SELECT x50 FROM manycol ORDER BY x80}
  64. } {1050 150 250 350 450 550 650 750 50 850 950}
  65. do_test misc1-1.4 {
  66. execsql {SELECT x75 FROM manycol WHERE x50=350}
  67. } 375
  68. do_test misc1-1.5 {
  69. execsql {SELECT x50 FROM manycol WHERE x99=599}
  70. } 550
  71. do_test misc1-1.6 {
  72. execsql {CREATE INDEX manycol_idx1 ON manycol(x99)}
  73. execsql {SELECT x50 FROM manycol WHERE x99=899}
  74. } 850
  75. do_test misc1-1.7 {
  76. execsql {SELECT count(*) FROM manycol}
  77. } 11
  78. do_test misc1-1.8 {
  79. execsql {DELETE FROM manycol WHERE x98=1234}
  80. execsql {SELECT count(*) FROM manycol}
  81. } 11
  82. do_test misc1-1.9 {
  83. execsql {DELETE FROM manycol WHERE x98=998}
  84. execsql {SELECT count(*) FROM manycol}
  85. } 10
  86. do_test misc1-1.10 {
  87. execsql {DELETE FROM manycol WHERE x99=500}
  88. execsql {SELECT count(*) FROM manycol}
  89. } 10
  90. do_test misc1-1.11 {
  91. execsql {DELETE FROM manycol WHERE x99=599}
  92. execsql {SELECT count(*) FROM manycol}
  93. } 9
  94. # Check GROUP BY expressions that name two or more columns.
  95. #
  96. do_test misc1-2.1 {
  97. execsql {
  98. BEGIN TRANSACTION;
  99. CREATE TABLE agger(one text, two text, three text, four text);
  100. INSERT INTO agger VALUES(1, 'one', 'hello', 'yes');
  101. INSERT INTO agger VALUES(2, 'two', 'howdy', 'no');
  102. INSERT INTO agger VALUES(3, 'thr', 'howareya', 'yes');
  103. INSERT INTO agger VALUES(4, 'two', 'lothere', 'yes');
  104. INSERT INTO agger VALUES(5, 'one', 'atcha', 'yes');
  105. INSERT INTO agger VALUES(6, 'two', 'hello', 'no');
  106. COMMIT
  107. }
  108. execsql {SELECT count(*) FROM agger}
  109. } 6
  110. do_test misc1-2.2 {
  111. execsql {SELECT sum(one), two, four FROM agger
  112. GROUP BY two, four ORDER BY sum(one) desc}
  113. } {8 two no 6 one yes 4 two yes 3 thr yes}
  114. do_test misc1-2.3 {
  115. execsql {SELECT sum((one)), (two), (four) FROM agger
  116. GROUP BY (two), (four) ORDER BY sum(one) desc}
  117. } {8 two no 6 one yes 4 two yes 3 thr yes}
  118. # Here's a test for a bug found by Joel Lucsy. The code below
  119. # was causing an assertion failure.
  120. #
  121. do_test misc1-3.1 {
  122. set r [execsql {
  123. CREATE TABLE t1(a);
  124. INSERT INTO t1 VALUES('hi');
  125. PRAGMA full_column_names=on;
  126. SELECT rowid, * FROM t1;
  127. }]
  128. lindex $r 1
  129. } {hi}
  130. # Here's a test for yet another bug found by Joel Lucsy. The code
  131. # below was causing an assertion failure.
  132. #
  133. do_test misc1-4.1 {
  134. execsql {
  135. BEGIN;
  136. CREATE TABLE t2(a);
  137. INSERT INTO t2 VALUES('This is a long string to use up a lot of disk -');
  138. UPDATE t2 SET a=a||a||a||a;
  139. INSERT INTO t2 SELECT '1 - ' || a FROM t2;
  140. INSERT INTO t2 SELECT '2 - ' || a FROM t2;
  141. INSERT INTO t2 SELECT '3 - ' || a FROM t2;
  142. INSERT INTO t2 SELECT '4 - ' || a FROM t2;
  143. INSERT INTO t2 SELECT '5 - ' || a FROM t2;
  144. INSERT INTO t2 SELECT '6 - ' || a FROM t2;
  145. COMMIT;
  146. SELECT count(*) FROM t2;
  147. }
  148. } {64}
  149. # Make sure we actually see a semicolon or end-of-file in the SQL input
  150. # before executing a command. Thus if "WHERE" is misspelled on an UPDATE,
  151. # the user won't accidently update every record.
  152. #
  153. do_test misc1-5.1 {
  154. catchsql {
  155. CREATE TABLE t3(a,b);
  156. INSERT INTO t3 VALUES(1,2);
  157. INSERT INTO t3 VALUES(3,4);
  158. UPDATE t3 SET a=0 WHEREwww b=2;
  159. }
  160. } {1 {near "WHEREwww": syntax error}}
  161. do_test misc1-5.2 {
  162. execsql {
  163. SELECT * FROM t3 ORDER BY a;
  164. }
  165. } {1 2 3 4}
  166. # Certain keywords (especially non-standard keywords like "REPLACE") can
  167. # also be used as identifiers. The way this works in the parser is that
  168. # the parser first detects a syntax error, the error handling routine
  169. # sees that the special keyword caused the error, then replaces the keyword
  170. # with "ID" and tries again.
  171. #
  172. # Check the operation of this logic.
  173. #
  174. do_test misc1-6.1 {
  175. catchsql {
  176. CREATE TABLE t4(
  177. abort, asc, begin, cluster, conflict, copy, delimiters, desc, end,
  178. explain, fail, ignore, key, offset, pragma, replace, temp,
  179. vacuum, view
  180. );
  181. }
  182. } {0 {}}
  183. do_test misc1-6.2 {
  184. catchsql {
  185. INSERT INTO t4
  186. VALUES(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19);
  187. }
  188. } {0 {}}
  189. do_test misc1-6.3 {
  190. execsql {
  191. SELECT * FROM t4
  192. }
  193. } {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19}
  194. do_test misc1-6.4 {
  195. execsql {
  196. SELECT abort+asc,max(key,pragma,temp) FROM t4
  197. }
  198. } {3 17}
  199. # Test for multi-column primary keys, and for multiple primary keys.
  200. #
  201. do_test misc1-7.1 {
  202. catchsql {
  203. CREATE TABLE error1(
  204. a TYPE PRIMARY KEY,
  205. b TYPE PRIMARY KEY
  206. );
  207. }
  208. } {1 {table "error1" has more than one primary key}}
  209. do_test misc1-7.2 {
  210. catchsql {
  211. CREATE TABLE error1(
  212. a INTEGER PRIMARY KEY,
  213. b TYPE PRIMARY KEY
  214. );
  215. }
  216. } {1 {table "error1" has more than one primary key}}
  217. do_test misc1-7.3 {
  218. execsql {
  219. CREATE TABLE t5(a,b,c,PRIMARY KEY(a,b));
  220. INSERT INTO t5 VALUES(1,2,3);
  221. SELECT * FROM t5 ORDER BY a;
  222. }
  223. } {1 2 3}
  224. do_test misc1-7.4 {
  225. catchsql {
  226. INSERT INTO t5 VALUES(1,2,4);
  227. }
  228. } {1 {columns a, b are not unique}}
  229. do_test misc1-7.5 {
  230. catchsql {
  231. INSERT INTO t5 VALUES(0,2,4);
  232. }
  233. } {0 {}}
  234. do_test misc1-7.6 {
  235. execsql {
  236. SELECT * FROM t5 ORDER BY a;
  237. }
  238. } {0 2 4 1 2 3}
  239. do_test misc1-8.1 {
  240. catchsql {
  241. SELECT *;
  242. }
  243. } {1 {no tables specified}}
  244. do_test misc1-8.2 {
  245. catchsql {
  246. SELECT t1.*;
  247. }
  248. } {1 {no such table: t1}}
  249. execsql {
  250. DROP TABLE t1;
  251. DROP TABLE t2;
  252. DROP TABLE t3;
  253. DROP TABLE t4;
  254. }
  255. # 64-bit integers are represented exactly.
  256. #
  257. do_test misc1-9.1 {
  258. catchsql {
  259. CREATE TABLE t1(a unique not null, b unique not null);
  260. INSERT INTO t1 VALUES('a',1234567890123456789);
  261. INSERT INTO t1 VALUES('b',1234567891123456789);
  262. INSERT INTO t1 VALUES('c',1234567892123456789);
  263. SELECT * FROM t1;
  264. }
  265. } {0 {a 1234567890123456789 b 1234567891123456789 c 1234567892123456789}}
  266. # A WHERE clause is not allowed to contain more than 99 terms. Check to
  267. # make sure this limit is enforced.
  268. #
  269. # 2005-07-16: There is no longer a limit on the number of terms in a
  270. # WHERE clause. But keep these tests just so that we have some tests
  271. # that use a large number of terms in the WHERE clause.
  272. #
  273. do_test misc1-10.0 {
  274. execsql {SELECT count(*) FROM manycol}
  275. } {9}
  276. do_test misc1-10.1 {
  277. set ::where {WHERE x0>=0}
  278. for {set i 1} {$i<=99} {incr i} {
  279. append ::where " AND x$i<>0"
  280. }
  281. catchsql "SELECT count(*) FROM manycol $::where"
  282. } {0 9}
  283. do_test misc1-10.2 {
  284. catchsql "SELECT count(*) FROM manycol $::where AND rowid>0"
  285. } {0 9}
  286. do_test misc1-10.3 {
  287. regsub "x0>=0" $::where "x0=0" ::where
  288. catchsql "DELETE FROM manycol $::where"
  289. } {0 {}}
  290. do_test misc1-10.4 {
  291. execsql {SELECT count(*) FROM manycol}
  292. } {8}
  293. do_test misc1-10.5 {
  294. catchsql "DELETE FROM manycol $::where AND rowid>0"
  295. } {0 {}}
  296. do_test misc1-10.6 {
  297. execsql {SELECT x1 FROM manycol WHERE x0=100}
  298. } {101}
  299. do_test misc1-10.7 {
  300. regsub "x0=0" $::where "x0=100" ::where
  301. catchsql "UPDATE manycol SET x1=x1+1 $::where"
  302. } {0 {}}
  303. do_test misc1-10.8 {
  304. execsql {SELECT x1 FROM manycol WHERE x0=100}
  305. } {102}
  306. do_test misc1-10.9 {
  307. catchsql "UPDATE manycol SET x1=x1+1 $::where AND rowid>0"
  308. } {0 {}}
  309. do_test misc1-10.10 {
  310. execsql {SELECT x1 FROM manycol WHERE x0=100}
  311. } {103}
  312. # Make sure the initialization works even if a database is opened while
  313. # another process has the database locked.
  314. #
  315. # Update for v3: The BEGIN doesn't lock the database so the schema is read
  316. # and the SELECT returns successfully.
  317. do_test misc1-11.1 {
  318. execsql {BEGIN}
  319. execsql {UPDATE t1 SET a=0 WHERE 0}
  320. sqlite3 db2 test.db
  321. set rc [catch {db2 eval {SELECT count(*) FROM t1}} msg]
  322. lappend rc $msg
  323. # v2 result: {1 {database is locked}}
  324. } {0 3}
  325. do_test misc1-11.2 {
  326. execsql {COMMIT}
  327. set rc [catch {db2 eval {SELECT count(*) FROM t1}} msg]
  328. db2 close
  329. lappend rc $msg
  330. } {0 3}
  331. # Make sure string comparisons really do compare strings in format4+.
  332. # Similar tests in the format3.test file show that for format3 and earlier
  333. # all comparisions where numeric if either operand looked like a number.
  334. #
  335. do_test misc1-12.1 {
  336. execsql {SELECT '0'=='0.0'}
  337. } {0}
  338. do_test misc1-12.2 {
  339. execsql {SELECT '0'==0.0}
  340. } {0}
  341. do_test misc1-12.3 {
  342. execsql {SELECT '12345678901234567890'=='12345678901234567891'}
  343. } {0}
  344. do_test misc1-12.4 {
  345. execsql {
  346. CREATE TABLE t6(a INT UNIQUE, b TEXT UNIQUE);
  347. INSERT INTO t6 VALUES('0','0.0');
  348. SELECT * FROM t6;
  349. }
  350. } {0 0.0}
  351. ifcapable conflict {
  352. do_test misc1-12.5 {
  353. execsql {
  354. INSERT OR IGNORE INTO t6 VALUES(0.0,'x');
  355. SELECT * FROM t6;
  356. }
  357. } {0 0.0}
  358. do_test misc1-12.6 {
  359. execsql {
  360. INSERT OR IGNORE INTO t6 VALUES('y',0);
  361. SELECT * FROM t6;
  362. }
  363. } {0 0.0 y 0}
  364. }
  365. do_test misc1-12.7 {
  366. execsql {
  367. CREATE TABLE t7(x INTEGER, y TEXT, z);
  368. INSERT INTO t7 VALUES(0,0,1);
  369. INSERT INTO t7 VALUES(0.0,0,2);
  370. INSERT INTO t7 VALUES(0,0.0,3);
  371. INSERT INTO t7 VALUES(0.0,0.0,4);
  372. SELECT DISTINCT x, y FROM t7 ORDER BY z;
  373. }
  374. } {0 0 0 0.0}
  375. do_test misc1-12.8 {
  376. execsql {
  377. SELECT min(z), max(z), count(z) FROM t7 GROUP BY x ORDER BY 1;
  378. }
  379. } {1 4 4}
  380. do_test misc1-12.9 {
  381. execsql {
  382. SELECT min(z), max(z), count(z) FROM t7 GROUP BY y ORDER BY 1;
  383. }
  384. } {1 2 2 3 4 2}
  385. # This used to be an error. But we changed the code so that arbitrary
  386. # identifiers can be used as a collating sequence. Collation is by text
  387. # if the identifier contains "text", "blob", or "clob" and is numeric
  388. # otherwise.
  389. #
  390. # Update: In v3, it is an error again.
  391. #
  392. #do_test misc1-12.10 {
  393. # catchsql {
  394. # SELECT * FROM t6 ORDER BY a COLLATE unknown;
  395. # }
  396. #} {0 {0 0 y 0}}
  397. do_test misc1-12.11 {
  398. execsql {
  399. CREATE TABLE t8(x TEXT COLLATE numeric, y INTEGER COLLATE text, z);
  400. INSERT INTO t8 VALUES(0,0,1);
  401. INSERT INTO t8 VALUES(0.0,0,2);
  402. INSERT INTO t8 VALUES(0,0.0,3);
  403. INSERT INTO t8 VALUES(0.0,0.0,4);
  404. SELECT DISTINCT x, y FROM t8 ORDER BY z;
  405. }
  406. } {0 0 0.0 0}
  407. do_test misc1-12.12 {
  408. execsql {
  409. SELECT min(z), max(z), count(z) FROM t8 GROUP BY x ORDER BY 1;
  410. }
  411. } {1 3 2 2 4 2}
  412. do_test misc1-12.13 {
  413. execsql {
  414. SELECT min(z), max(z), count(z) FROM t8 GROUP BY y ORDER BY 1;
  415. }
  416. } {1 4 4}
  417. # There was a problem with realloc() in the OP_MemStore operation of
  418. # the VDBE. A buffer was being reallocated but some pointers into
  419. # the old copy of the buffer were not being moved over to the new copy.
  420. # The following code tests for the problem.
  421. #
  422. ifcapable subquery {
  423. do_test misc1-13.1 {
  424. execsql {
  425. CREATE TABLE t9(x,y);
  426. INSERT INTO t9 VALUES('one',1);
  427. INSERT INTO t9 VALUES('two',2);
  428. INSERT INTO t9 VALUES('three',3);
  429. INSERT INTO t9 VALUES('four',4);
  430. INSERT INTO t9 VALUES('five',5);
  431. INSERT INTO t9 VALUES('six',6);
  432. INSERT INTO t9 VALUES('seven',7);
  433. INSERT INTO t9 VALUES('eight',8);
  434. INSERT INTO t9 VALUES('nine',9);
  435. INSERT INTO t9 VALUES('ten',10);
  436. INSERT INTO t9 VALUES('eleven',11);
  437. SELECT y FROM t9
  438. WHERE x=(SELECT x FROM t9 WHERE y=1)
  439. OR x=(SELECT x FROM t9 WHERE y=2)
  440. OR x=(SELECT x FROM t9 WHERE y=3)
  441. OR x=(SELECT x FROM t9 WHERE y=4)
  442. OR x=(SELECT x FROM t9 WHERE y=5)
  443. OR x=(SELECT x FROM t9 WHERE y=6)
  444. OR x=(SELECT x FROM t9 WHERE y=7)
  445. OR x=(SELECT x FROM t9 WHERE y=8)
  446. OR x=(SELECT x FROM t9 WHERE y=9)
  447. OR x=(SELECT x FROM t9 WHERE y=10)
  448. OR x=(SELECT x FROM t9 WHERE y=11)
  449. OR x=(SELECT x FROM t9 WHERE y=12)
  450. OR x=(SELECT x FROM t9 WHERE y=13)
  451. OR x=(SELECT x FROM t9 WHERE y=14)
  452. ;
  453. }
  454. } {1 2 3 4 5 6 7 8 9 10 11}
  455. }
  456. #
  457. # The following tests can only work if the current SQLite VFS has the concept
  458. # of a current directory.
  459. #
  460. ifcapable curdir {
  461. # Make sure a database connection still works after changing the
  462. # working directory.
  463. #
  464. do_test misc1-14.1 {
  465. file mkdir tempdir
  466. cd tempdir
  467. execsql {BEGIN}
  468. file exists ./test.db-journal
  469. } {0}
  470. do_test misc1-14.2a {
  471. execsql {UPDATE t1 SET a=a||'x' WHERE 0}
  472. file exists ../test.db-journal
  473. } {0}
  474. do_test misc1-14.2b {
  475. execsql {UPDATE t1 SET a=a||'y' WHERE 1}
  476. file exists ../test.db-journal
  477. } {1}
  478. do_test misc1-14.3 {
  479. cd ..
  480. forcedelete tempdir
  481. execsql {COMMIT}
  482. file exists ./test.db-journal
  483. } {0}
  484. }
  485. # A failed create table should not leave the table in the internal
  486. # data structures. Ticket #238.
  487. #
  488. do_test misc1-15.1.1 {
  489. catchsql {
  490. CREATE TABLE t10 AS SELECT c1;
  491. }
  492. } {1 {no such column: c1}}
  493. do_test misc1-15.1.2 {
  494. catchsql {
  495. CREATE TABLE t10 AS SELECT t9.c1;
  496. }
  497. } {1 {no such column: t9.c1}}
  498. do_test misc1-15.1.3 {
  499. catchsql {
  500. CREATE TABLE t10 AS SELECT main.t9.c1;
  501. }
  502. } {1 {no such column: main.t9.c1}}
  503. do_test misc1-15.2 {
  504. catchsql {
  505. CREATE TABLE t10 AS SELECT 1;
  506. }
  507. # The bug in ticket #238 causes the statement above to fail with
  508. # the error "table t10 alread exists"
  509. } {0 {}}
  510. # Test for memory leaks when a CREATE TABLE containing a primary key
  511. # fails. Ticket #249.
  512. #
  513. do_test misc1-16.1 {
  514. catchsql {SELECT name FROM sqlite_master LIMIT 1}
  515. catchsql {
  516. CREATE TABLE test(a integer, primary key(a));
  517. }
  518. } {0 {}}
  519. do_test misc1-16.2 {
  520. catchsql {
  521. CREATE TABLE test(a integer, primary key(a));
  522. }
  523. } {1 {table test already exists}}
  524. do_test misc1-16.3 {
  525. catchsql {
  526. CREATE TABLE test2(a text primary key, b text, primary key(a,b));
  527. }
  528. } {1 {table "test2" has more than one primary key}}
  529. do_test misc1-16.4 {
  530. execsql {
  531. INSERT INTO test VALUES(1);
  532. SELECT rowid, a FROM test;
  533. }
  534. } {1 1}
  535. do_test misc1-16.5 {
  536. execsql {
  537. INSERT INTO test VALUES(5);
  538. SELECT rowid, a FROM test;
  539. }
  540. } {1 1 5 5}
  541. do_test misc1-16.6 {
  542. execsql {
  543. INSERT INTO test VALUES(NULL);
  544. SELECT rowid, a FROM test;
  545. }
  546. } {1 1 5 5 6 6}
  547. ifcapable trigger&&tempdb {
  548. # Ticket #333: Temp triggers that modify persistent tables.
  549. #
  550. do_test misc1-17.1 {
  551. execsql {
  552. BEGIN;
  553. CREATE TABLE RealTable(TestID INTEGER PRIMARY KEY, TestString TEXT);
  554. CREATE TEMP TABLE TempTable(TestID INTEGER PRIMARY KEY, TestString TEXT);
  555. CREATE TEMP TRIGGER trigTest_1 AFTER UPDATE ON TempTable BEGIN
  556. INSERT INTO RealTable(TestString)
  557. SELECT new.TestString FROM TempTable LIMIT 1;
  558. END;
  559. INSERT INTO TempTable(TestString) VALUES ('1');
  560. INSERT INTO TempTable(TestString) VALUES ('2');
  561. UPDATE TempTable SET TestString = TestString + 1 WHERE TestID=1 OR TestId=2;
  562. COMMIT;
  563. SELECT TestString FROM RealTable ORDER BY 1;
  564. }
  565. } {2 3}
  566. }
  567. do_test misc1-18.1 {
  568. set n [sqlite3_sleep 100]
  569. expr {$n>=100}
  570. } {1}
  571. finish_test