1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

Make sure the INSERT xfer optimization does not trigger if the CHECK

constraints on the two tables are not identical.  Ticket #2252. (CVS 3660)

FossilOrigin-Name: 6fc18275230563437f2985eac3795e4dfe8eb9de
This commit is contained in:
drh
2007-02-24 13:23:51 +00:00
parent 945498f3f2
commit 8103b7d2b7
5 changed files with 94 additions and 17 deletions

75
test/insert4.test Normal file
View File

@ -0,0 +1,75 @@
# 2007 January 24
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library. The
# focus of this file is testing corner cases of the INSERT statement.
#
# $Id: insert4.test,v 1.1 2007/02/24 13:23:53 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# Ticket #2252. Make sure the an INSERT from identical tables
# does not violate constraints.
#
do_test insert4-1.1 {
execsql {
CREATE TABLE t1(a int, b int, check(b>a));
CREATE TABLE t2(x int, y int);
INSERT INTO t2 VALUES(9,1);
}
catchsql {
INSERT INTO t1 SELECT * FROM t2;
}
} {1 {constraint failed}}
do_test insert4-1.2 {
execsql {
SELECT * FROM t1;
}
} {}
# Other coverage tests for the INSERT transfer optimization.
#
do_test insert4-2.1 {
execsql {
INSERT INTO t1 SELECT 4, 8;
SELECT * FROM t1;
}
} {4 8}
do_test insert4-2.2.1 {
execsql {
CREATE TABLE t3(a int, b int);
INSERT INTO t2 SELECT y, x FROM t2;
INSERT INTO t3 SELECT * FROM t2 LIMIT 1;
SELECT * FROM t3;
}
} {9 1}
do_test insert4-2.2.2 {
catchsql {
DELETE FROM t1;
INSERT INTO t1 SELECT * FROM t2 LIMIT 1;
SELECT * FROM t1;
}
} {1 {constraint failed}}
do_test insert4-2.3.1 {
execsql {
DELETE FROM t3;
INSERT INTO t3 SELECT DISTINCT * FROM t2;
SELECT * FROM t3;
}
} {9 1 1 9}
do_test insert4-2.3.2 {
catchsql {
DELETE FROM t1;
INSERT INTO t1 SELECT DISTINCT * FROM t2;
}
} {1 {constraint failed}}
finish_test