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 #*********************************************************************** |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 execsql { | 379 execsql { |
380 CREATE TABLE t6(x INTEGER PRIMARY KEY, y); | 380 CREATE TABLE t6(x INTEGER PRIMARY KEY, y); |
381 INSERT INTO t6 VALUES(1,1); | 381 INSERT INTO t6 VALUES(1,1); |
382 INSERT INTO t6 VALUES(2,2); | 382 INSERT INTO t6 VALUES(2,2); |
383 INSERT INTO t6 VALUES(3,3); | 383 INSERT INTO t6 VALUES(3,3); |
384 INSERT INTO t6 SELECT nullif(y*2+10,14), y+100 FROM t6; | 384 INSERT INTO t6 SELECT nullif(y*2+10,14), y+100 FROM t6; |
385 SELECT x, y FROM t6; | 385 SELECT x, y FROM t6; |
386 } | 386 } |
387 } {1 1 2 2 3 3 12 101 13 102 16 103} | 387 } {1 1 2 2 3 3 12 101 13 102 16 103} |
388 | 388 |
| 389 # Multiple VALUES clauses |
| 390 # |
| 391 ifcapable compound { |
| 392 do_test insert-10.1 { |
| 393 execsql { |
| 394 CREATE TABLE t10(a,b,c); |
| 395 INSERT INTO t10 VALUES(1,2,3), (4,5,6), (7,8,9); |
| 396 SELECT * FROM t10; |
| 397 } |
| 398 } {1 2 3 4 5 6 7 8 9} |
| 399 do_test insert-10.2 { |
| 400 catchsql { |
| 401 INSERT INTO t10 VALUES(11,12,13), (14,15), (16,17,28); |
| 402 } |
| 403 } {1 {all VALUES must have the same number of terms}} |
| 404 } |
| 405 |
| 406 # Need for the OP_SoftNull opcode |
| 407 # |
| 408 do_execsql_test insert-11.1 { |
| 409 CREATE TABLE t11a AS SELECT '123456789' AS x; |
| 410 CREATE TABLE t11b (a INTEGER PRIMARY KEY, b, c); |
| 411 INSERT INTO t11b SELECT x, x, x FROM t11a; |
| 412 SELECT quote(a), quote(b), quote(c) FROM t11b; |
| 413 } {123456789 '123456789' '123456789'} |
| 414 |
| 415 |
| 416 # More columns of input than there are columns in the table. |
| 417 # Ticket http://www.sqlite.org/src/info/e9654505cfda9361 |
| 418 # |
| 419 do_execsql_test insert-12.1 { |
| 420 CREATE TABLE t12a(a,b,c,d,e,f,g); |
| 421 INSERT INTO t12a VALUES(101,102,103,104,105,106,107); |
| 422 CREATE TABLE t12b(x); |
| 423 INSERT INTO t12b(x,rowid,x,x,x,x,x) SELECT * FROM t12a; |
| 424 SELECT rowid, x FROM t12b; |
| 425 } {102 101} |
| 426 do_execsql_test insert-12.2 { |
| 427 CREATE TABLE tab1( value INTEGER); |
| 428 INSERT INTO tab1 (value, _rowid_) values( 11, 1); |
| 429 INSERT INTO tab1 (value, _rowid_) SELECT 22,999; |
| 430 SELECT * FROM tab1; |
| 431 } {11 22} |
| 432 do_execsql_test insert-12.3 { |
| 433 CREATE TABLE t12c(a, b DEFAULT 'xyzzy', c); |
| 434 INSERT INTO t12c(a, rowid, c) SELECT 'one', 999, 'two'; |
| 435 SELECT * FROM t12c; |
| 436 } {one xyzzy two} |
| 437 |
| 438 |
389 integrity_check insert-99.0 | 439 integrity_check insert-99.0 |
390 | 440 |
391 finish_test | 441 finish_test |
OLD | NEW |