OLD | NEW |
1 # 2001 September 15 | 1 # 2001 September 15 |
2 # | 2 # |
3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
5 # | 5 # |
6 # May you do good and not evil. | 6 # May you do good and not evil. |
7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
9 # | 9 # |
10 #*********************************************************************** | 10 #*********************************************************************** |
11 # This file implements regression tests for SQLite library. The | 11 # This file implements regression tests for SQLite library. The |
12 # focus of this file is testing the INSERT statement that takes is | 12 # focus of this file is testing the INSERT statement that takes is |
13 # result from a SELECT. | 13 # result from a SELECT. |
14 # | 14 # |
15 # $Id: insert2.test,v 1.19 2008/01/16 18:20:42 danielk1977 Exp $ | 15 # $Id: insert2.test,v 1.19 2008/01/16 18:20:42 danielk1977 Exp $ |
16 | 16 |
17 set testdir [file dirname $argv0] | 17 set testdir [file dirname $argv0] |
18 source $testdir/tester.tcl | 18 source $testdir/tester.tcl |
| 19 set testprefix insert2 |
19 | 20 |
20 # Create some tables with data that we can select against | 21 # Create some tables with data that we can select against |
21 # | 22 # |
22 do_test insert2-1.0 { | 23 do_test insert2-1.0 { |
23 execsql {CREATE TABLE d1(n int, log int);} | 24 execsql {CREATE TABLE d1(n int, log int);} |
24 for {set i 1} {$i<=20} {incr i} { | 25 for {set i 1} {$i<=20} {incr i} { |
25 for {set j 0} {(1<<$j)<$i} {incr j} {} | 26 for {set j 0} {(1<<$j)<$i} {incr j} {} |
26 execsql "INSERT INTO d1 VALUES($i,$j)" | 27 execsql "INSERT INTO d1 VALUES($i,$j)" |
27 } | 28 } |
28 execsql {SELECT * FROM d1 ORDER BY n} | 29 execsql {SELECT * FROM d1 ORDER BY n} |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 } {1 2 1 3} | 269 } {1 2 1 3} |
269 ifcapable subquery { | 270 ifcapable subquery { |
270 do_test insert2-5.2 { | 271 do_test insert2-5.2 { |
271 execsql { | 272 execsql { |
272 INSERT INTO t2 SELECT (SELECT a FROM t2), 4; | 273 INSERT INTO t2 SELECT (SELECT a FROM t2), 4; |
273 SELECT * FROM t2; | 274 SELECT * FROM t2; |
274 } | 275 } |
275 } {1 2 1 3 1 4} | 276 } {1 2 1 3 1 4} |
276 } | 277 } |
277 | 278 |
| 279 do_execsql_test 6.0 { |
| 280 CREATE TABLE t5(a, b, c DEFAULT 'c', d); |
| 281 } |
| 282 do_execsql_test 6.1 { |
| 283 INSERT INTO t5(a) SELECT 456 UNION ALL SELECT 123 ORDER BY 1; |
| 284 SELECT * FROM t5 ORDER BY rowid; |
| 285 } {123 {} c {} 456 {} c {}} |
| 286 |
| 287 ifcapable fts3 { |
| 288 do_execsql_test 6.2 { |
| 289 CREATE VIRTUAL TABLE t0 USING fts4(a); |
| 290 } |
| 291 do_execsql_test 6.3 { |
| 292 INSERT INTO t0 SELECT 0 UNION SELECT 0 AS 'x' ORDER BY x; |
| 293 SELECT * FROM t0; |
| 294 } {0} |
| 295 } |
| 296 |
| 297 |
278 finish_test | 298 finish_test |
OLD | NEW |