]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Disable the "SELECT max(rowid) ..." optimization for virtual tables. Ticket #2250...
authordanielk1977 <danielk1977@noemail.net>
Fri, 2 Mar 2007 07:27:00 +0000 (07:27 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Fri, 2 Mar 2007 07:27:00 +0000 (07:27 +0000)
FossilOrigin-Name: ddb4d0af5770c7030fe6e92119972c9508724b9a

manifest
manifest.uuid
src/select.c
test/vtab8.test [new file with mode: 0644]

index 2e1eead0664b701488ea270d7611873531855177..db6ac756a3e6e3fc3db7fa610d265c23e37e6aac 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Minor\sfixes\sso\sthat\stestfixture\sbuilds\swithout\sIO\stracing\senabled.\s(CVS\s3668)
-D 2007-03-02T06:24:19
+C Disable\sthe\s"SELECT\smax(rowid)\s..."\soptimization\sfor\svirtual\stables.\sTicket\s#2250.\s(CVS\s3669)
+D 2007-03-02T07:27:00
 F Makefile.in 1fe3d0b46e40fd684e1e61f8e8056cefed16de9f
 F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -92,7 +92,7 @@ F src/pragma.c 5091300911670ddaa552bfa12c45cbca1bb7e7d6
 F src/prepare.c 484389c6811415b8f23d259ac9c029613e1c72c3
 F src/printf.c aade23a789d7cc88b397ec0d33a0a01a33a7a9c1
 F src/random.c 6119474a6f6917f708c1dee25b9a8e519a620e88
-F src/select.c 6a090150d6866a94f719eda57e58207105f4a26d
+F src/select.c 4d68a0d7f98fb59bcedd0be69750e0445b05899c
 F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
 F src/shell.c 3ae4654560e91220a95738a73d135d91d937cda1
 F src/sqlite.h.in 6b7383baf76070214f6381f603328ca9b22a7fae
@@ -355,6 +355,7 @@ F test/vtab4.test a9d7104d41a787754a734740d7aa61c807a69f87
 F test/vtab5.test 9fb8f335651afe8f870011e2f68e5b00c5ad03cd
 F test/vtab6.test ec0036f29f8a803da9935206f2d9d1b6a8026392
 F test/vtab7.test 5f9ef9fb84733e928d5d0267c821072561b198d5
+F test/vtab8.test 31b61c3caeb18c9166483b53c9fc911dd0bf08ff
 F test/vtab9.test 87afba55339b0c255e9697fbfb5bfb6120505d9d
 F test/vtab_err.test 224cc80ad700797c48b9cd2c1e0bd7a8517d8609
 F test/where.test 1d020f50c77f37b2dbab9766ca959e6e3278ecdb
@@ -434,7 +435,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P ed915f579a8e5b75681a9a6012b5041500cad36c
-R 52a2b249c17574a33bd5070b3c0cd9e3
+P 8d3829cdb35f41bc7a2e6f945e9aa83987513104
+R a8c74ef4df5791aca2f931fcffb9fa89
 U danielk1977
-Z d2a702d7474659fbf8106d226e7f424b
+Z 81b4e3cb66e26f39332d05ca445f394b
index 5d8aedcb0972328ad0b593b5013ce9c8762776d9..0fec9d6b4e6c9ad25c108010de7e1fb547cc78f2 100644 (file)
@@ -1 +1 @@
-8d3829cdb35f41bc7a2e6f945e9aa83987513104
\ No newline at end of file
+ddb4d0af5770c7030fe6e92119972c9508724b9a
\ No newline at end of file
index c8f65568735728d2d77871baf0769ddd854a0af9..d7fb3f1790dd13c9658647b5f2feff05d19e2348 100644 (file)
@@ -12,7 +12,7 @@
 ** This file contains C code routines that are called by the parser
 ** to handle SELECT statements in SQLite.
 **
-** $Id: select.c,v 1.329 2007/02/24 13:23:53 drh Exp $
+** $Id: select.c,v 1.330 2007/03/02 07:27:00 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 
@@ -2367,6 +2367,8 @@ static int simpleMinMaxQuery(Parse *pParse, Select *p, int eDest, int iParm){
   iCol = pExpr->iColumn;
   pTab = pSrc->a[0].pTab;
 
+  /* This optimization cannot be used with virtual tables. */
+  if( IsVirtual(pTab) ) return 0;
 
   /* If we get to here, it means the query is of the correct form.
   ** Check to make sure we have an index and make pIdx point to the
diff --git a/test/vtab8.test b/test/vtab8.test
new file mode 100644 (file)
index 0000000..b147adb
--- /dev/null
@@ -0,0 +1,79 @@
+# 2006 August 29
+#
+# 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 inserting into virtual tables from a SELECT
+# statement.
+#
+# $Id: vtab8.test,v 1.1 2007/03/02 07:27:01 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable !vtab {
+  finish_test
+  return
+}
+
+register_echo_module [sqlite3_connection_pointer db]
+
+# See ticket #2244
+#
+do_test vtab1.2244-1 {
+  execsql {
+    CREATE TABLE t2244(a, b);
+    CREATE VIRTUAL TABLE t2244e USING echo(t2244);
+    INSERT INTO t2244 VALUES('AA', 'BB');
+    INSERT INTO t2244 VALUES('CC', 'DD');
+    SELECT rowid, * FROM t2244e;
+  }
+} {1 AA BB 2 CC DD}
+do_test vtab1.2244-2 {
+  execsql {
+    SELECT * FROM t2244e WHERE rowid = 10;
+  }
+} {}
+do_test vtab1.2244-3 {
+  execsql {
+    UPDATE t2244e SET a = 'hello world' WHERE 0;
+    SELECT rowid, * FROM t2244e;
+  }
+} {1 AA BB 2 CC DD}
+
+do_test vtab1-2250-2 {
+  execsql {
+    CREATE TABLE t2250(a, b);
+    INSERT INTO t2250 VALUES(10, 20);
+    CREATE VIRTUAL TABLE t2250e USING echo(t2250);
+    select max(rowid) from t2250;
+    select max(rowid) from t2250e;
+  }
+} {1 1}
+
+# See ticket #2260 (note: this test doesn't trigger the bug yet - it's a
+# work in progress).
+#
+do_test vtab1.2260-1 {
+  execsql {
+    CREATE TABLE t2260a_real(a, b);
+    CREATE TABLE t2260b_real(a, b);
+
+    CREATE INDEX i2260 ON t2260a_real(a);
+    CREATE INDEX i2260x ON t2260b_real(a);
+
+    CREATE VIRTUAL TABLE t2260a USING echo(t2260a_real);
+    CREATE VIRTUAL TABLE t2260b USING echo(t2260b_real);
+
+    SELECT * FROM t2260a, t2260b WHERE t2260a.a = t2260b.a AND t2260a.a > 101;
+  }
+} {}
+
+unset -nocomplain echo_module_begin_fail
+finish_test