Fix the xfer-optimization such that if the destination table has

constraints on the hidden rowid, the optimization is not attempted.
[forum:/forumpost/6dcc95e3ca|Forum post 6dcc95e3ca].

FossilOrigin-Name: da9ca357fb24f39a4a3292ca447773c6233a3084721abfbd5665a45ee8a4bed4
This commit is contained in:
drh
2026-05-11 16:58:05 +00:00
parent 88be32c9d3
commit e14c16189e
4 changed files with 88 additions and 10 deletions
+41
View File
@@ -625,4 +625,45 @@ do_execsql_test 11.0 {
PRAGMA integrity_check;
} {1 1 1 2 2 2 3 3 3 ok}
#-------------------------------------------------------------------------
# forum post 2026-05-11T13:15:57Z
#
do_execsql_test 12.0 {
CREATE TABLE src(x,y,z, CONSTRAINT c1 CHECK(rowid<=5));
CREATE TABLE dest(x,y,z, CONSTRAINT c2 CHECK(rowid<=5));
INSERT INTO src(x) VALUES(22),(33),(44);
UPDATE src SET y=x+100, z=x*100;
INSERT INTO dest(x) VALUES(55),(66),(77);
UPDATE dest SET y=x+100, z=x*100;
PRAGMA integrity_check;
} ok
set sqlite3_xferopt_count 0
do_catchsql_test 12.1 {
INSERT INTO dest SELECT * FROM src;
} {1 {CHECK constraint failed: c2}}
do_test 12.2 {
set sqlite3_xferopt_count
} 0
do_execsql_test 12.3 {
SELECT rowid, x FROM dest;
PRAGMA integrity_check;
} {1 55 2 66 3 77 ok}
do_execsql_test 12.4 {
ALTER TABLE src DROP CONSTRAINT c1;
ALTER TABLE dest DROP CONSTRAINT c2;
}
set sqlite3_xferopt_count 0
do_catchsql_test 12.5 {
INSERT INTO dest SELECT * FROM src;
} {0 {}}
do_test 12.6 {
set sqlite3_xferopt_count
} 1
do_execsql_test 12.7 {
SELECT rowid, x FROM dest;
PRAGMA integrity_check;
} {1 55 2 66 3 77 4 22 5 33 6 44 ok}
finish_test