-C Fix\sa\sproblem\sin\sthe\ssqlite3ExprCompare()\sfunction\sthat\scaused\stwo\ndissimilar\sexpressions\sto\smatch\sif\sthey\shave\sthe\ssame\s"COLLATE\sname"\sat\nthe\souter\slayer.
-D 2018-04-18T17:52:28.271
+C Add\sextra\stest\scases\sfor\sUPSERT.
+D 2018-04-18T17:56:37.901
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F Makefile.in 5ce9343cba9c189046f1afe6d2bcc1f68079439febc05267b98aec6ecc752439
F test/upsert1.test 3b4e8e5932516115bfffb2269a44c416c5c26d0d57cc7dd16954d0b77fbc4cd9
F test/upsert2.test 82ed5cbd4a13ff74240ece8ec97b6afd07446eac554ad5e93c12b42197844e0b
F test/upsert3.test 46ee74a7d7ee797ca0ab79d44e78572d6778b7520e4ebb8f8c1553765b4eae2c
-F test/upsert4.test 490c82a37048b0258c94498ff3687b20cdbadfefe4d8a4e2d28f09e84f3b98a6
+F test/upsert4.test 42b737568914a7bfb1135c641ae96bc75fbfd7b55785a4eaae279a067a373420
F test/uri.test 3481026f00ade6dfe8adb7acb6e1e47b04369568
F test/uri2.test 9d3ba7a53ee167572d53a298ee4a5d38ec4a8fb7
F test/userauth01.test e740a2697a7b40d7c5003a7d7edaee16acd349a9
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P fba24aec235dd6f124c1ece66cdac485c9d96e0578c4fbacd8f49d7b767a5b4a
-R 30a97c4d09d6fc30a117693d1fff8a6c
-U drh
-Z b4241c44da2068f85d9b7d3cc18d532b
+P fb16348a5bd52752098c9aeacc3281c4e1e8eb5a868d131ea6c3271dc4226b40
+R bf451bcdfd0a3cb7daf666d841400ba4
+U dan
+Z c15e182adb19b110e30902ffd8c90113
set testdir [file dirname $argv0]
source $testdir/tester.tcl
-set testprefix upsert2
+set testprefix upsert4
foreach {tn sql} {
1 { CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c UNIQUE) }
do_execsql_test 1.$tn.6 {
SELECT * FROM t1;
} {1 {} one 2 2 two 3 {} three}
+
+ do_execsql_test 1.$tn.7 {
+ INSERT INTO t1 VALUES(2, NULL, 'zero') ON CONFLICT (a)
+ DO UPDATE SET (b, c) = (SELECT 'x', 'y');
+ SELECT * FROM t1;
+ } {1 {} one 2 x y 3 {} three}
+
+ do_execsql_test 1.$tn.8 {
+ INSERT INTO t1 VALUES(1, NULL, NULL) ON CONFLICT (a)
+ DO UPDATE SET (c, a) = ('four', 4);
+ SELECT * FROM t1 ORDER BY 1;
+ } {2 x y 3 {} three 4 {} four}
}
+#-------------------------------------------------------------------------
+# Test target analysis.
+#
+set rtbl(0) {0 {}}
+set rtbl(1) {/1 .*failed.*/}
+set rtbl(2) {1 {ON CONFLICT clause does not match any PRIMARY KEY or UNIQUE constraint}}
+
+foreach {tn sql} {
+ 1 {
+ CREATE TABLE xyz(a INTEGER PRIMARY KEY, b, c, d);
+ CREATE UNIQUE INDEX xyz1 ON xyz(d, c, b COLLATE nocase);
+ }
+
+ 2 {
+ CREATE TABLE xyz(a INT PRIMARY KEY, b, c, d);
+ CREATE UNIQUE INDEX xyz1 ON xyz(d, c, b COLLATE nocase);
+ }
+
+ 3 {
+ CREATE TABLE xyz(a INT PRIMARY KEY, b, c, d) WITHOUT ROWID;
+ CREATE UNIQUE INDEX xyz1 ON xyz(d, c, b COLLATE nocase);
+ }
+} {
+ reset_db
+ execsql $sql
+ do_execsql_test 2.$tn.1 {
+ INSERT INTO xyz VALUES(10, 1, 1, 'one');
+ }
+
+
+ foreach {tn2 oc res} {
+ 1 "ON CONFLICT (b COLLATE nocase, c, d) DO NOTHING" 0
+ 2 "ON CONFLICT (b, c, d) DO NOTHING" 0
+ 3 "ON CONFLICT (b, c COLLATE nocase, d) DO NOTHING" 2
+ 4 "ON CONFLICT (a) DO NOTHING" 1
+ 5 "ON CONFLICT DO NOTHING" 0
+ 6 "ON CONFLICT (b, c, d) WHERE a!=0 DO NOTHING" 0
+ 7 "ON CONFLICT (d, c, c) WHERE a!=0 DO NOTHING" 2
+ } {
+
+ do_catchsql_test 2.$tn.2.$tn2 "
+ INSERT INTO xyz VALUES(11, 1, 1, 'one') $oc
+ " $rtbl($res)
+ }
+
+ do_execsql_test 2.$tn.3 {
+ SELECT * FROM xyz;
+ } {10 1 1 one}
+}
+
+foreach {tn sql} {
+ 1 {
+ CREATE TABLE abc(a INTEGER PRIMARY KEY, x, y);
+ CREATE UNIQUE INDEX abc1 ON abc(('x' || x) COLLATE nocase);
+ }
+ 2 {
+ CREATE TABLE abc(a INT PRIMARY KEY, x, y);
+ CREATE UNIQUE INDEX abc1 ON abc(('x' || x) COLLATE nocase);
+ }
+ 3 {
+ CREATE TABLE abc(a INT PRIMARY KEY, x, y) WITHOUT ROWID;
+ CREATE UNIQUE INDEX abc1 ON abc(('x' || x) COLLATE nocase);
+ }
+} {
+ reset_db
+ execsql $sql
+ do_execsql_test 2.$tn.1 {
+ INSERT INTO abc VALUES(1, 'one', 'two');
+ }
+
+ foreach {tn2 oc res} {
+ 1 "ON CONFLICT DO NOTHING" 0
+ 2 "ON CONFLICT ('x' || x) DO NOTHING" 0
+ 3 "ON CONFLICT (('x' || x) COLLATE nocase) DO NOTHING" 0
+ 4 "ON CONFLICT (('x' || x) COLLATE binary) DO NOTHING" 2
+ 5 "ON CONFLICT (x || 'x') DO NOTHING" 2
+ 6 "ON CONFLICT ((('x' || x))) DO NOTHING" 0
+ } {
+ do_catchsql_test 2.$tn.2.$tn2 "
+ INSERT INTO abc VALUES(2, 'one', NULL) $oc;
+ " $rtbl($res)
+ }
+
+ do_execsql_test 2.$tn.3 {
+ SELECT * FROM abc
+ } {1 one two}
+}
+
+
finish_test