From: dan Date: Mon, 1 May 2017 18:12:56 +0000 (+0000) Subject: Clear the BTCF_ValidNKey flag set if a cursor is moved by X-Git-Tag: version-3.19.0~31 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=874080bbb6cbf78e91aee3515dbd98acd26f233b;p=thirdparty%2Fsqlite.git Clear the BTCF_ValidNKey flag set if a cursor is moved by sqlite3BtreeInsert(). Fix for [f68dc596c4]. FossilOrigin-Name: a6727eef6d757a39ad23e5c8cbe960f5d909e5d37cb4e90bc3bdbb8bf58cd6f8 --- diff --git a/manifest b/manifest index 22a472ed22..3815ce54e0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\ssingle\stestcase()\smacro\sto\sthe\ssubquery\sprocessing\slogic. -D 2017-04-29T19:29:49.700 +C Clear\sthe\sBTCF_ValidNKey\sflag\sset\sif\sa\scursor\sis\smoved\sby\nsqlite3BtreeInsert().\sFix\sfor\s[f68dc596c4]. +D 2017-05-01T18:12:56.867 F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 6a8c838220f7c00820e1fc0ac1bccaaa8e5676067e1dbfa1bafa7a4ffecf8ae6 @@ -345,7 +345,7 @@ F src/auth.c 930b376a9c56998557367e6f7f8aaeac82a2a792 F src/backup.c faf17e60b43233c214aae6a8179d24503a61e83b F src/bitvec.c 17ea48eff8ba979f1f5b04cc484c7bb2be632f33 F src/btmutex.c 0e9ce2d56159b89b9bc8e197e023ee11e39ff8ca -F src/btree.c a0d9a1c782ff3d22df5d217a4fa7125dd69ad5849caa51c4442c10246ca8ae27 +F src/btree.c ef42df0cd8fa80ab174c83deb13a216465c49555eb01d57abdfd814a8546fa77 F src/btree.h 80f518c0788be6cec8d9f8e13bd8e380df299d2b5e4ac340dc887b0642647cfc F src/btreeInt.h a392d353104b4add58b4a59cb185f5d5693dde832c565b77d8d4c343ed98f610 F src/build.c 4026a9c554b233e50c5e9ad46963e676cf54dd2306d952aa1eaa07a1bc9ce14f @@ -604,7 +604,7 @@ F test/colmeta.test 2c765ea61ee37bc43bbe6d6047f89004e6508eb1 F test/colname.test 08948a4809d22817e0e5de89c7c0a8bd90cb551b F test/conflict.test 029faa2d81a0d1cafb5f88614beb663d972c01db F test/conflict2.test bb0b94cf7196c64a3cbd815c66d3ee98c2fecd9c -F test/conflict3.test dec0634c0f31dec9a4b01c63063e939f0cd21b6b +F test/conflict3.test a83db76a6c3503b2fa057c7bfb08c318d8a422202d8bc5b86226e078e5b49ff9 F test/contrib01.test 2a1cbc0f2f48955d7d073f725765da6fbceda6b4 F test/corrupt.test 141c39ea650c1365e85a49e402fa05cb9617fb97 F test/corrupt2.test e4964cee73dda57a90958e0087a6b388b1d9cb58 @@ -1577,7 +1577,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e54c9f8db5b2fa8ea82c6eab7482255431af16901f7992c9667b56a0e50a9f4f -R 6f21ea13ed166571d20351d2145d6640 -U drh -Z 4a7e86f7be3de966a53a14c1a17e31d5 +P 4e1df76e3d85922648e0e1cce73a266c3b1ed4511ace259ec0a01d7693af9e6f +R 2f44609e52881f5575acf3fe925fc9aa +U dan +Z 5b866fdf8c8937d7431fdae30fbd42bc diff --git a/manifest.uuid b/manifest.uuid index 45bf2ccb33..a351564742 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4e1df76e3d85922648e0e1cce73a266c3b1ed4511ace259ec0a01d7693af9e6f \ No newline at end of file +a6727eef6d757a39ad23e5c8cbe960f5d909e5d37cb4e90bc3bdbb8bf58cd6f8 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 35e47173fa..4ba985f931 100644 --- a/src/btree.c +++ b/src/btree.c @@ -8190,6 +8190,7 @@ int sqlite3BtreeInsert( }else if( loc<0 && pPage->nCell>0 ){ assert( pPage->leaf ); idx = ++pCur->ix; + pCur->curFlags &= ~BTCF_ValidNKey; }else{ assert( pPage->leaf ); } diff --git a/test/conflict3.test b/test/conflict3.test index b51a55ee71..751a442685 100644 --- a/test/conflict3.test +++ b/test/conflict3.test @@ -19,13 +19,14 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl +set testprefix conflict3 ifcapable !conflict { finish_test return } -do_execsql_test conflict-1.1 { +do_execsql_test 1.1 { CREATE TABLE t1( a INTEGER PRIMARY KEY ON CONFLICT REPLACE, b UNIQUE ON CONFLICT IGNORE, @@ -37,7 +38,7 @@ do_execsql_test conflict-1.1 { # Insert a row that conflicts on column B. The insert should be ignored. # -do_execsql_test conflict-1.2 { +do_execsql_test 1.2 { INSERT INTO t1(a,b,c) VALUES(3,2,5); SELECT a,b,c FROM t1 ORDER BY a; } {1 2 3 2 3 4} @@ -45,16 +46,16 @@ do_execsql_test conflict-1.2 { # Insert two rows where the second conflicts on C. The first row show go # and and then there should be a constraint error. # -do_test conflict-1.3 { +do_test 1.3 { catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);} } {1 {UNIQUE constraint failed: t1.c}} -do_execsql_test conflict-1.4 { +do_execsql_test 1.4 { SELECT a,b,c FROM t1 ORDER BY a; } {1 2 3 2 3 4 4 5 6} # Replete the tests above, but this time on a table non-INTEGER primary key. # -do_execsql_test conflict-2.1 { +do_execsql_test 2.1 { DROP TABLE t1; CREATE TABLE t1( a INT PRIMARY KEY ON CONFLICT REPLACE, @@ -67,7 +68,7 @@ do_execsql_test conflict-2.1 { # Insert a row that conflicts on column B. The insert should be ignored. # -do_execsql_test conflict-2.2 { +do_execsql_test 2.2 { INSERT INTO t1(a,b,c) VALUES(3,2,5); SELECT a,b,c FROM t1 ORDER BY a; } {1 2 3 2 3 4} @@ -75,16 +76,16 @@ do_execsql_test conflict-2.2 { # Insert two rows where the second conflicts on C. The first row show go # and and then there should be a constraint error. # -do_test conflict-2.3 { +do_test 2.3 { catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);} } {1 {UNIQUE constraint failed: t1.c}} -do_execsql_test conflict-2.4 { +do_execsql_test 2.4 { SELECT a,b,c FROM t1 ORDER BY a; } {1 2 3 2 3 4 4 5 6} # Replete again on a WITHOUT ROWID table. # -do_execsql_test conflict-3.1 { +do_execsql_test 3.1 { DROP TABLE t1; CREATE TABLE t1( a INT PRIMARY KEY ON CONFLICT REPLACE, @@ -97,7 +98,7 @@ do_execsql_test conflict-3.1 { # Insert a row that conflicts on column B. The insert should be ignored. # -do_execsql_test conflict-3.2 { +do_execsql_test 3.2 { INSERT INTO t1(a,b,c) VALUES(3,2,5); SELECT a,b,c FROM t1 ORDER BY a; } {1 2 3 2 3 4} @@ -105,16 +106,16 @@ do_execsql_test conflict-3.2 { # Insert two rows where the second conflicts on C. The first row show go # and and then there should be a constraint error. # -do_test conflict-3.3 { +do_test 3.3 { catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);} } {1 {UNIQUE constraint failed: t1.c}} -do_execsql_test conflict-3.4 { +do_execsql_test 3.4 { SELECT a,b,c FROM t1 ORDER BY a; } {1 2 3 2 3 4 4 5 6} # Arrange the table rows in a different order and repeat. # -do_execsql_test conflict-4.1 { +do_execsql_test 4.1 { DROP TABLE t1; CREATE TABLE t1( b UNIQUE ON CONFLICT IGNORE, @@ -127,7 +128,7 @@ do_execsql_test conflict-4.1 { # Insert a row that conflicts on column B. The insert should be ignored. # -do_execsql_test conflict-4.2 { +do_execsql_test 4.2 { INSERT INTO t1(a,b,c) VALUES(3,2,5); SELECT a,b,c FROM t1 ORDER BY a; } {1 2 3 2 3 4} @@ -135,16 +136,16 @@ do_execsql_test conflict-4.2 { # Insert two rows where the second conflicts on C. The first row show go # and and then there should be a constraint error. # -do_test conflict-4.3 { +do_test 4.3 { catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);} } {1 {UNIQUE constraint failed: t1.c}} -do_execsql_test conflict-4.4 { +do_execsql_test 4.4 { SELECT a,b,c FROM t1 ORDER BY a; } {1 2 3 2 3 4 4 5 6} # Arrange the table rows in a different order and repeat. # -do_execsql_test conflict-5.1 { +do_execsql_test 5.1 { DROP TABLE t1; CREATE TABLE t1( b UNIQUE ON CONFLICT IGNORE, @@ -157,7 +158,7 @@ do_execsql_test conflict-5.1 { # Insert a row that conflicts on column B. The insert should be ignored. # -do_execsql_test conflict-5.2 { +do_execsql_test 5.2 { INSERT INTO t1(a,b,c) VALUES(3,2,5); SELECT a,b,c FROM t1 ORDER BY a; } {1 2 3 2 3 4} @@ -165,16 +166,16 @@ do_execsql_test conflict-5.2 { # Insert two rows where the second conflicts on C. The first row show go # and and then there should be a constraint error. # -do_test conflict-5.3 { +do_test 5.3 { catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);} } {1 {UNIQUE constraint failed: t1.c}} -do_execsql_test conflict-5.4 { +do_execsql_test 5.4 { SELECT a,b,c FROM t1 ORDER BY a; } {1 2 3 2 3 4 4 5 6} # Arrange the table rows in a different order and repeat. # -do_execsql_test conflict-6.1 { +do_execsql_test 6.1 { DROP TABLE t1; CREATE TABLE t1( c UNIQUE ON CONFLICT FAIL, @@ -187,7 +188,7 @@ do_execsql_test conflict-6.1 { # Insert a row that conflicts on column B. The insert should be ignored. # -do_execsql_test conflict-6.2 { +do_execsql_test 6.2 { INSERT INTO t1(a,b,c) VALUES(3,2,5); SELECT a,b,c FROM t1 ORDER BY a; } {1 2 3 2 3 4} @@ -195,16 +196,16 @@ do_execsql_test conflict-6.2 { # Insert two rows where the second conflicts on C. The first row show go # and and then there should be a constraint error. # -do_test conflict-6.3 { +do_test 6.3 { catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);} } {1 {UNIQUE constraint failed: t1.c}} -do_execsql_test conflict-6.4 { +do_execsql_test 6.4 { SELECT a,b,c FROM t1 ORDER BY a; } {1 2 3 2 3 4 4 5 6} # Change which column is the PRIMARY KEY # -do_execsql_test conflict-7.1 { +do_execsql_test 7.1 { DROP TABLE t1; CREATE TABLE t1( a UNIQUE ON CONFLICT REPLACE, @@ -217,7 +218,7 @@ do_execsql_test conflict-7.1 { # Insert a row that conflicts on column B. The insert should be ignored. # -do_execsql_test conflict-7.2 { +do_execsql_test 7.2 { INSERT INTO t1(a,b,c) VALUES(3,2,5); SELECT a,b,c FROM t1 ORDER BY a; } {1 2 3 2 3 4} @@ -225,16 +226,16 @@ do_execsql_test conflict-7.2 { # Insert two rows where the second conflicts on C. The first row show go # and and then there should be a constraint error. # -do_test conflict-7.3 { +do_test 7.3 { catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);} } {1 {UNIQUE constraint failed: t1.c}} -do_execsql_test conflict-7.4 { +do_execsql_test 7.4 { SELECT a,b,c FROM t1 ORDER BY a; } {1 2 3 2 3 4 4 5 6} # Change which column is the PRIMARY KEY # -do_execsql_test conflict-8.1 { +do_execsql_test 8.1 { DROP TABLE t1; CREATE TABLE t1( a UNIQUE ON CONFLICT REPLACE, @@ -247,7 +248,7 @@ do_execsql_test conflict-8.1 { # Insert a row that conflicts on column B. The insert should be ignored. # -do_execsql_test conflict-8.2 { +do_execsql_test 8.2 { INSERT INTO t1(a,b,c) VALUES(3,2,5); SELECT a,b,c FROM t1 ORDER BY a; } {1 2 3 2 3 4} @@ -255,16 +256,16 @@ do_execsql_test conflict-8.2 { # Insert two rows where the second conflicts on C. The first row show go # and and then there should be a constraint error. # -do_test conflict-8.3 { +do_test 8.3 { catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);} } {1 {UNIQUE constraint failed: t1.c}} -do_execsql_test conflict-8.4 { +do_execsql_test 8.4 { SELECT a,b,c FROM t1 ORDER BY a; } {1 2 3 2 3 4 4 5 6} # Change which column is the PRIMARY KEY # -do_execsql_test conflict-9.1 { +do_execsql_test 9.1 { DROP TABLE t1; CREATE TABLE t1( a UNIQUE ON CONFLICT REPLACE, @@ -277,7 +278,7 @@ do_execsql_test conflict-9.1 { # Insert a row that conflicts on column B. The insert should be ignored. # -do_execsql_test conflict-9.2 { +do_execsql_test 9.2 { INSERT INTO t1(a,b,c) VALUES(3,2,5); SELECT a,b,c FROM t1 ORDER BY a; } {1 2 3 2 3 4} @@ -285,16 +286,16 @@ do_execsql_test conflict-9.2 { # Insert two rows where the second conflicts on C. The first row show go # and and then there should be a constraint error. # -do_test conflict-9.3 { +do_test 9.3 { catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);} } {1 {UNIQUE constraint failed: t1.c}} -do_execsql_test conflict-9.4 { +do_execsql_test 9.4 { SELECT a,b,c FROM t1 ORDER BY a; } {1 2 3 2 3 4 4 5 6} # Change which column is the PRIMARY KEY # -do_execsql_test conflict-10.1 { +do_execsql_test 10.1 { DROP TABLE t1; CREATE TABLE t1( a UNIQUE ON CONFLICT REPLACE, @@ -307,7 +308,7 @@ do_execsql_test conflict-10.1 { # Insert a row that conflicts on column B. The insert should be ignored. # -do_execsql_test conflict-10.2 { +do_execsql_test 10.2 { INSERT INTO t1(a,b,c) VALUES(3,2,5); SELECT a,b,c FROM t1 ORDER BY a; } {1 2 3 2 3 4} @@ -315,16 +316,16 @@ do_execsql_test conflict-10.2 { # Insert two rows where the second conflicts on C. The first row show go # and and then there should be a constraint error. # -do_test conflict-10.3 { +do_test 10.3 { catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);} } {1 {UNIQUE constraint failed: t1.c}} -do_execsql_test conflict-10.4 { +do_execsql_test 10.4 { SELECT a,b,c FROM t1 ORDER BY a; } {1 2 3 2 3 4 4 5 6} # Change which column is the PRIMARY KEY # -do_execsql_test conflict-11.1 { +do_execsql_test 11.1 { DROP TABLE t1; CREATE TABLE t1( a UNIQUE ON CONFLICT REPLACE, @@ -337,7 +338,7 @@ do_execsql_test conflict-11.1 { # Insert a row that conflicts on column B. The insert should be ignored. # -do_execsql_test conflict-11.2 { +do_execsql_test 11.2 { INSERT INTO t1(a,b,c) VALUES(3,2,5); SELECT a,b,c FROM t1 ORDER BY a; } {1 2 3 2 3 4} @@ -345,12 +346,25 @@ do_execsql_test conflict-11.2 { # Insert two rows where the second conflicts on C. The first row show go # and and then there should be a constraint error. # -do_test conflict-11.3 { +do_test 11.3 { catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);} } {1 {UNIQUE constraint failed: t1.c}} -do_execsql_test conflict-11.4 { +do_execsql_test 11.4 { SELECT a,b,c FROM t1 ORDER BY a; } {1 2 3 2 3 4 4 5 6} +# Check that ticket [f68dc596c4] has been fixed. +# +do_execsql_test 12.1 { + CREATE TABLE t2(a INTEGER PRIMARY KEY, b TEXT); + INSERT INTO t2 VALUES(111, '111'); +} +do_execsql_test 12.2 { + REPLACE INTO t2 VALUES(NULL, '112'), (111, '111B'); +} +do_execsql_test 12.3 { + SELECT * FROM t2; +} {111 111B 112 112} + finish_test