Build scalosgfx.library with actual defs.h
[AROS-Contrib.git] / sqlite3 / test / rollback.test
blobb73400fa23c44ba92d4d6933e06923028f73c300
1 # 2004 June 30
3 # The author disclaims copyright to this source code.  In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
11 # This file implements regression tests for SQLite library.  The
12 # focus of this file is verifying that a rollback in one statement
13 # caused by an ON CONFLICT ROLLBACK clause aborts any other pending
14 # statements.
16 # $Id: rollback.test,v 1.2 2005/01/12 13:04:55 danielk1977 Exp $
18 set testdir [file dirname $argv0]
19 source $testdir/tester.tcl
21 db close
22 set DB [sqlite3 db test.db]
24 do_test rollback-1.1 {
25   execsql {
26     CREATE TABLE t1(a);
27     INSERT INTO t1 VALUES(1);
28     INSERT INTO t1 VALUES(2);
29     INSERT INTO t1 VALUES(3);
30     INSERT INTO t1 VALUES(4);
31     SELECT * FROM t1;
32   }
33 } {1 2 3 4}
35 do_test rollback-1.2 {
36   execsql {
37     CREATE TABLE t3(a unique on conflict rollback);
38     INSERT INTO t3 SELECT a FROM t1;
39     BEGIN;
40     INSERT INTO t1 SELECT * FROM t1;
41   }
42 } {}
43 do_test rollback-1.3 {
44   set STMT [sqlite3_prepare $DB "SELECT a FROM t1" -1 TAIL]
45   sqlite3_step $STMT
46 } {SQLITE_ROW}
48 # This causes a ROLLBACK, which deletes the table out from underneath the
49 # SELECT statement.
51 do_test rollback-1.4 {
52   catchsql {
53     INSERT INTO t3 SELECT a FROM t1;
54   }
55 } {1 {column a is not unique}}
57 # Try to continue with the SELECT statement
59 do_test rollback-1.5 {
60   sqlite3_step $STMT
61 } {SQLITE_ABORT}
63 # Restart the SELECT statement
65 do_test rollback-1.6 {
66   sqlite3_reset $STMT
67 } {SQLITE_OK}
68 do_test rollback-1.7 {
69   sqlite3_step $STMT
70 } {SQLITE_ROW}
71 do_test rollback-1.8 {
72   sqlite3_step $STMT
73 } {SQLITE_ROW}
74 do_test rollback-1.9 {
75   sqlite3_finalize $STMT
76 } {SQLITE_OK}
78 finish_test