Return an error when an xBestIndex() method indicates that it intends to use the value of an unusable constraint. Related to #2998. (CVS 4867)

FossilOrigin-Name: ffd470279540b1b8e3fdce6eb14001bae489b16d
This commit is contained in:
danielk1977
2008-03-17 09:36:44 +00:00
parent 17fe6c1d32
commit 39359dc020
5 changed files with 148 additions and 14 deletions
+119 -1
View File
@@ -14,7 +14,7 @@
# virtual tables. The test cases in this file are copied from the file
# join.test, and some of the comments still reflect that.
#
# $Id: vtab6.test,v 1.2 2006/06/28 18:18:10 drh Exp $
# $Id: vtab6.test,v 1.3 2008/03/17 09:36:45 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -454,4 +454,122 @@ do_test vtab6-10.1 {
} {}
} ;# ifcapable subquery
do_test vtab6-11.1.0 {
execsql {
CREATE TABLE ab_r(a, b);
CREATE TABLE bc_r(b, c);
CREATE VIRTUAL TABLE ab USING echo(ab_r);
CREATE VIRTUAL TABLE bc USING echo(bc_r);
INSERT INTO ab VALUES(1, 2);
INSERT INTO bc VALUES(2, 3);
}
} {}
do_test vtab6-11.1.1 {
execsql {
SELECT a, b, c FROM ab NATURAL JOIN bc;
}
} {1 2 3}
do_test vtab6-11.1.2 {
execsql {
SELECT a, b, c FROM bc NATURAL JOIN ab;
}
} {1 2 3}
set ::echo_module_cost 1.0
do_test vtab6-11.1.3 {
execsql {
SELECT a, b, c FROM ab NATURAL JOIN bc;
}
} {1 2 3}
do_test vtab6-11.1.4 {
execsql {
SELECT a, b, c FROM bc NATURAL JOIN ab;
}
} {1 2 3}
do_test vtab6-11.2.0 {
execsql {
CREATE INDEX ab_i ON ab_r(b);
}
} {}
unset ::echo_module_cost
do_test vtab6-11.2.1 {
execsql {
SELECT a, b, c FROM ab NATURAL JOIN bc;
}
} {1 2 3}
do_test vtab6-11.2.2 {
execsql {
SELECT a, b, c FROM bc NATURAL JOIN ab;
}
} {1 2 3}
set ::echo_module_cost 1.0
do_test vtab6-11.2.3 {
execsql {
SELECT a, b, c FROM ab NATURAL JOIN bc;
}
} {1 2 3}
do_test vtab6-11.2.4 {
execsql {
SELECT a, b, c FROM bc NATURAL JOIN ab;
}
} {1 2 3}
unset ::echo_module_cost
db close
sqlite3 db test.db
register_echo_module [sqlite3_connection_pointer db]
do_test vtab6-11.3.1 {
execsql {
SELECT a, b, c FROM ab NATURAL JOIN bc;
}
} {1 2 3}
do_test vtab6-11.3.2 {
execsql {
SELECT a, b, c FROM bc NATURAL JOIN ab;
}
} {1 2 3}
set ::echo_module_cost 1.0
do_test vtab6-11.3.3 {
execsql {
SELECT a, b, c FROM ab NATURAL JOIN bc;
}
} {1 2 3}
do_test vtab6-11.3.4 {
execsql {
SELECT a, b, c FROM bc NATURAL JOIN ab;
}
} {1 2 3}
unset ::echo_module_cost
set ::echo_module_ignore_usable 1
db cache flush
do_test vtab6-11.4.1 {
catchsql {
SELECT a, b, c FROM ab NATURAL JOIN bc;
}
} {1 {table ab: xBestIndex returned an invalid plan}}
do_test vtab6-11.4.2 {
catchsql {
SELECT a, b, c FROM bc NATURAL JOIN ab;
}
} {1 {table ab: xBestIndex returned an invalid plan}}
unset ::echo_module_ignore_usable
finish_test