1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Fix a bug reported on the mailing list concerning a conflict between "INSERT INTO ... SELECT" statements and the "SELECT max(x) FROM tbl" optimization. (CVS 2227)

FossilOrigin-Name: 5a9da62ae303800ded99942aed30eadeb3863da3
This commit is contained in:
danielk1977
2005-01-17 08:57:09 +00:00
parent 5558a8a697
commit 3719d7f9c4
4 changed files with 45 additions and 15 deletions

View File

@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing the INSERT statement.
#
# $Id: insert.test,v 1.21 2004/11/10 15:27:38 danielk1977 Exp $
# $Id: insert.test,v 1.22 2005/01/17 08:57:09 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -304,6 +304,29 @@ ifcapable {reindex} {
} {}
}
# Test that the special optimization for queries of the form
# "SELECT max(x) FROM tbl" where there is an index on tbl(x) works with
# INSERT statments.
do_test insert-7.1 {
execsql {
DROP TABLE t1;
CREATE TABLE t1(a);
INSERT INTO t1 VALUES(1);
INSERT INTO t1 VALUES(2);
CREATE INDEX i1 ON t1(a);
}
} {}
do_test insert-7.2 {
execsql {
INSERT INTO t1 SELECT max(a) FROM t1;
}
} {}
do_test insert-7.3 {
execsql {
SELECT a FROM t1;
}
} {1 2 2}
integrity_check insert-99.0
finish_test