1
0
mirror of https://github.com/sqlite/sqlite.git synced 2026-01-06 08:01:16 +03:00

Clear the BTCF_ValidNKey flag set if a cursor is moved by

sqlite3BtreeInsert(). Fix for [f68dc596c4].

FossilOrigin-Name: a6727eef6d757a39ad23e5c8cbe960f5d909e5d37cb4e90bc3bdbb8bf58cd6f8
This commit is contained in:
dan
2017-05-01 18:12:56 +00:00
parent 7555581fc1
commit 874080bbb6
4 changed files with 68 additions and 53 deletions

View File

@@ -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