xref: /sqlite-3.40.0/test/upsertfault.test (revision 42d18160)
1*42d18160Sdan# 2018-04-17
2*42d18160Sdan#
3*42d18160Sdan# The author disclaims copyright to this source code.  In place of
4*42d18160Sdan# a legal notice, here is a blessing:
5*42d18160Sdan#
6*42d18160Sdan#    May you do good and not evil.
7*42d18160Sdan#    May you find forgiveness for yourself and forgive others.
8*42d18160Sdan#    May you share freely, never taking more than you give.
9*42d18160Sdan#
10*42d18160Sdan#***********************************************************************
11*42d18160Sdan#
12*42d18160Sdan# Test cases for UPSERT
13*42d18160Sdan
14*42d18160Sdanset testdir [file dirname $argv0]
15*42d18160Sdansource $testdir/tester.tcl
16*42d18160Sdanset testprefix upsertfault
17*42d18160Sdan
18*42d18160Sdando_execsql_test 1.0 {
19*42d18160Sdan  CREATE TABLE t1(a PRIMARY KEY, b, c, d, UNIQUE(b, c));
20*42d18160Sdan  INSERT INTO t1 VALUES(1, 1, 1, 1);
21*42d18160Sdan  INSERT INTO t1 VALUES(2, 2, 2, 2);
22*42d18160Sdan}
23*42d18160Sdanfaultsim_save_and_close
24*42d18160Sdan
25*42d18160Sdando_faultsim_test 1 -faults oom* -prep {
26*42d18160Sdan  faultsim_restore_and_reopen
27*42d18160Sdan  db eval { SELECT * FROM sqlite_master }
28*42d18160Sdan} -body {
29*42d18160Sdan  execsql {
30*42d18160Sdan     INSERT INTO t1 VALUES(3, 2, 2, NULL) ON CONFLICT(b, c) DO
31*42d18160Sdan       UPDATE SET d=d+1;
32*42d18160Sdan  }
33*42d18160Sdan} -test {
34*42d18160Sdan  faultsim_test_result {0 {}}
35*42d18160Sdan}
36*42d18160Sdan
37*42d18160Sdan
38*42d18160Sdanfinish_test
39