17c478bd9Sstevel@tonic-gateset testdir [file dirname $argv0]
27c478bd9Sstevel@tonic-gatesource $testdir/tester.tcl
37c478bd9Sstevel@tonic-gate
47c478bd9Sstevel@tonic-gatedb close
57c478bd9Sstevel@tonic-gateset DB [sqlite db test.db]
67c478bd9Sstevel@tonic-gate
77c478bd9Sstevel@tonic-gateexecsql {
87c478bd9Sstevel@tonic-gate  CREATE TABLE t1(a);
97c478bd9Sstevel@tonic-gate  INSERT INTO t1 VALUES(1);
107c478bd9Sstevel@tonic-gate  INSERT INTO t1 VALUES(2);
117c478bd9Sstevel@tonic-gate  INSERT INTO t1 VALUES(3);
127c478bd9Sstevel@tonic-gate  INSERT INTO t1 VALUES(4);
137c478bd9Sstevel@tonic-gate}
147c478bd9Sstevel@tonic-gate
157c478bd9Sstevel@tonic-gatedo_test capi3-13.1 {
167c478bd9Sstevel@tonic-gate  execsql {
177c478bd9Sstevel@tonic-gate    CREATE TABLE t3(a unique on conflict rollback);
187c478bd9Sstevel@tonic-gate    INSERT INTO t3 SELECT a FROM t1;
197c478bd9Sstevel@tonic-gate    BEGIN;
207c478bd9Sstevel@tonic-gate    INSERT INTO t1 SELECT * FROM t1;
217c478bd9Sstevel@tonic-gate  }
227c478bd9Sstevel@tonic-gate} {}
237c478bd9Sstevel@tonic-gatedo_test capi3-13.2 {
247c478bd9Sstevel@tonic-gate  set STMT [sqlite_compile $DB "SELECT a FROM t1" TAIL]
257c478bd9Sstevel@tonic-gate  sqlite_step $STMT
267c478bd9Sstevel@tonic-gate  sqlite_step $STMT
277c478bd9Sstevel@tonic-gate  sqlite_step $STMT
287c478bd9Sstevel@tonic-gate  sqlite_step $STMT
297c478bd9Sstevel@tonic-gate  sqlite_step $STMT
307c478bd9Sstevel@tonic-gate} {SQLITE_ROW}
317c478bd9Sstevel@tonic-gatedo_test capi3-13.3 {
327c478bd9Sstevel@tonic-gate# This causes a ROLLBACK, which deletes the table out from underneath the
337c478bd9Sstevel@tonic-gate# SELECT statement. Causes a crash.
347c478bd9Sstevel@tonic-gate  catchsql {
357c478bd9Sstevel@tonic-gate    INSERT INTO t3 SELECT a FROM t1;
367c478bd9Sstevel@tonic-gate  }
377c478bd9Sstevel@tonic-gate} {1 {column a is not unique}}
387c478bd9Sstevel@tonic-gatedo_test capi3-13.4 {
397c478bd9Sstevel@tonic-gate  sqlite_step $STMT
407c478bd9Sstevel@tonic-gate  sqlite_step $STMT
417c478bd9Sstevel@tonic-gate  sqlite_step $STMT
427c478bd9Sstevel@tonic-gate  sqlite_step $STMT
437c478bd9Sstevel@tonic-gate} {SQLITE_DONE}
447c478bd9Sstevel@tonic-gatedo_test capi3-13.5 {
457c478bd9Sstevel@tonic-gate  sqlite_finalize $STMT
467c478bd9Sstevel@tonic-gate} {SQLITE_OK}
477c478bd9Sstevel@tonic-gate
487c478bd9Sstevel@tonic-gatefinish_test
49