Debian Codegraph @

ext/fts5/test/fts5lastrowid.test

raw
1 # 2017 Feb 27
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 #
12 # Tests of the last_insert_rowid functionality with fts5.
13 #
14
15 source [file join [file dirname [info script]] fts5_common.tcl]
16 set testprefix fts5lastrowid
17
18 # If SQLITE_ENABLE_FTS5 is not defined, omit this file.
19 ifcapable !fts5 {
20 finish_test
21 return
22 }
23
24 do_execsql_test 1.0 {
25 CREATE VIRTUAL TABLE t1 USING fts5(str);
26 }
27
28 do_execsql_test 1.1 {
29 INSERT INTO t1 VALUES('one string');
30 INSERT INTO t1 VALUES('two string');
31 INSERT INTO t1 VALUES('three string');
32 SELECT last_insert_rowid();
33 } {3}
34
35 do_execsql_test 1.2 {
36 BEGIN;
37 INSERT INTO t1 VALUES('one string');
38 INSERT INTO t1 VALUES('two string');
39 INSERT INTO t1 VALUES('three string');
40 COMMIT;
41 SELECT last_insert_rowid();
42 } {6}
43
44 do_execsql_test 1.3 {
45 INSERT INTO t1(rowid, str) VALUES(-22, 'some more text');
46 SELECT last_insert_rowid();
47 } {-22}
48
49 do_execsql_test 1.4 {
50 BEGIN;
51 INSERT INTO t1(rowid, str) VALUES(45, 'some more text');
52 INSERT INTO t1(rowid, str) VALUES(46, 'some more text');
53 INSERT INTO t1(rowid, str) VALUES(222, 'some more text');
54 SELECT last_insert_rowid();
55 COMMIT;
56 SELECT last_insert_rowid();
57 } {222 222}
58
59 do_execsql_test 1.5 {
60 CREATE TABLE x1(x);
61 INSERT INTO x1 VALUES('john'), ('paul'), ('george'), ('ringo');
62 INSERT INTO t1 SELECT x FROM x1;
63 SELECT last_insert_rowid();
64 } {226}
65
66 do_execsql_test 1.6 {
67 INSERT INTO t1(rowid, str) SELECT rowid+10, x FROM x1;
68 SELECT last_insert_rowid();
69 } {14}
70
71
72 finish_test