OLD | NEW |
1 # The author disclaims copyright to this source code. In place of | 1 # The author disclaims copyright to this source code. In place of |
2 # a legal notice, here is a blessing: | 2 # a legal notice, here is a blessing: |
3 # | 3 # |
4 # May you do good and not evil. | 4 # May you do good and not evil. |
5 # May you find forgiveness for yourself and forgive others. | 5 # May you find forgiveness for yourself and forgive others. |
6 # May you share freely, never taking more than you give. | 6 # May you share freely, never taking more than you give. |
7 # | 7 # |
8 #*********************************************************************** | 8 #*********************************************************************** |
9 # | 9 # |
10 # Tests to make sure that value returned by last_insert_rowid() (LIRID) | 10 # Tests to make sure that value returned by last_insert_rowid() (LIRID) |
(...skipping 18 matching lines...) Expand all Loading... |
29 do_test lastinsert-1.1 { | 29 do_test lastinsert-1.1 { |
30 catchsql { | 30 catchsql { |
31 create table t1 (k integer primary key); | 31 create table t1 (k integer primary key); |
32 insert into t1 values (1); | 32 insert into t1 values (1); |
33 insert into t1 values (NULL); | 33 insert into t1 values (NULL); |
34 insert into t1 values (NULL); | 34 insert into t1 values (NULL); |
35 select last_insert_rowid(); | 35 select last_insert_rowid(); |
36 } | 36 } |
37 } {0 3} | 37 } {0 3} |
38 | 38 |
| 39 # EVIDENCE-OF: R-47220-63683 The sqlite3_last_insert_rowid() function |
| 40 # does not work for WITHOUT ROWID tables. |
| 41 # |
| 42 do_test lastinsert-1.1w { |
| 43 catchsql { |
| 44 create table t1w (k integer primary key) WITHOUT ROWID; |
| 45 insert into t1w values (123456); |
| 46 select last_insert_rowid(); -- returns 3 from above. |
| 47 } |
| 48 } {0 3} |
| 49 |
39 # LIRID unchanged after an update on a table | 50 # LIRID unchanged after an update on a table |
40 do_test lastinsert-1.2 { | 51 do_test lastinsert-1.2 { |
41 catchsql { | 52 catchsql { |
42 update t1 set k=4 where k=2; | 53 update t1 set k=4 where k=2; |
43 select last_insert_rowid(); | 54 select last_insert_rowid(); |
44 } | 55 } |
45 } {0 3} | 56 } {0 3} |
46 | 57 |
47 # LIRID unchanged after a delete from a table | 58 # LIRID unchanged after a delete from a table |
48 do_test lastinsert-1.3 { | 59 do_test lastinsert-1.3 { |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 | 368 |
358 do_test lastinsert-9.1 { | 369 do_test lastinsert-9.1 { |
359 db eval {INSERT INTO t2 VALUES(123456789012345,0)} | 370 db eval {INSERT INTO t2 VALUES(123456789012345,0)} |
360 db last_insert_rowid | 371 db last_insert_rowid |
361 } {123456789012345} | 372 } {123456789012345} |
362 | 373 |
363 | 374 |
364 } ;# ifcapable (view && trigger) | 375 } ;# ifcapable (view && trigger) |
365 | 376 |
366 finish_test | 377 finish_test |
OLD | NEW |