]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Modify the optimizer so that it does not assume that functions are
authordrh <drh@noemail.net>
Sat, 19 Apr 2003 17:27:24 +0000 (17:27 +0000)
committerdrh <drh@noemail.net>
Sat, 19 Apr 2003 17:27:24 +0000 (17:27 +0000)
constant. (CVS 920)

FossilOrigin-Name: 767f1af236d115e8388e1dcc28a4df1be48d6c85

manifest
manifest.uuid
src/expr.c
test/in.test
test/where.test

index 002d30010f353608ac43c0fa985aded49ffd2ace..c727bdc3b2819cbec1c8f9b3175a55a42ee78702 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Bug\sin\sWHERE\sclause\sprocessing\sfixed.\s\sTicket\s#298.\s(CVS\s919)
-D 2003-04-19T16:34:05
+C Modify\sthe\soptimizer\sso\sthat\sit\sdoes\snot\sassume\sthat\sfunctions\sare\nconstant.\s(CVS\s920)
+D 2003-04-19T17:27:25
 F Makefile.in df3a4db41a7450468b5fe934d9dd8f723b631249
 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -28,7 +28,7 @@ F src/build.c 6694013c86c4c480754f515ddab561302c6e732a
 F src/copy.c 8699e571994934c78f70761a1458d7b9e9e75073
 F src/delete.c af65b26d9d13abbf63fdc4e97b88d26c700b04bb
 F src/encode.c faf03741efe921755ec371cf4a6984536de00042
-F src/expr.c 942f535c8906ef81df00bac62223868feb78424b
+F src/expr.c 3c0ff6b7b34d483ea03fb86c66f28b929542c782
 F src/func.c 882c3ed5a02be18cd904715c7ec62947a34a3605
 F src/hash.c 4fc39feb7b7711f6495ee9f2159559bedb043e1f
 F src/hash.h cd0433998bc1a3759d244e1637fe5a3c13b53bf8
@@ -80,7 +80,7 @@ F test/fkey1.test d65c824459916249bee501532d6154ddab0b5db7
 F test/format3.test 64ab6c4db132b28a645996d413530f7b2a462cc2
 F test/func.test 000515779001ac6899eec4b54e65c6e2501279d4
 F test/hook.test 7a4c97b886801d265c981dc4ec123c77af642a9d
-F test/in.test 3171a2b3170a8223665c1a4f26be5f3eda36cc4b
+F test/in.test 22de8a3eb27265aab723adc513bea0e76bef70c6
 F test/index.test 90ef4c426865f15937858bd433cc82b9c11af913
 F test/insert.test 5697ba098e4d8a6f0151f281b7e39dec9c439e05
 F test/insert2.test c288375a64dad3295044714f0dfed4a193cf067f
@@ -126,7 +126,7 @@ F test/update.test 198360dfa14e65354dbcc66d5b98d8070780e42b
 F test/vacuum.test 059871b312eb910bbe49dafde1d01490cc2c6bbe
 F test/version.test 605fd0d7e7d571370c32b12dbf395b58953de246
 F test/view.test c64fa39ea57f3c2066c854290f032ad13b23b83d
-F test/where.test 94adbfe53e5c9660b9756f23b29e3b2c3d2792a9
+F test/where.test d719129a052280fe245a2ddcbd09bcc0b8c17ce4
 F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b
 F tool/lemon.c 14fedcde9cf70aa6040b89de164cf8f56f92a4b9
 F tool/lempar.c 73a991cc3017fb34804250fa901488b5147b3717
@@ -162,7 +162,7 @@ F www/speed.tcl cb4c10a722614aea76d2c51f32ee43400d5951be
 F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098
 F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
-P 1e3d0d094776c2a429fa2a3eebc036a0b6374862
-R 869f63511d353e87dc2dd3a60513ae60
+P 9b619c98b586a207a87942640d3a94220ff8ab02
+R 7412289c17f86b36c7e9e5ef2d7e5a25
 U drh
-Z 804a9e6e52c395fdc713233765cd05d5
+Z f9b7a3e33fd7e690b2414333a1a1aca5
index c5e1a9a4b208456f0de55bd37817565c0bd70a7d..b173b6f0fc4560efd026950597236e0d26ac9d96 100644 (file)
@@ -1 +1 @@
-9b619c98b586a207a87942640d3a94220ff8ab02
\ No newline at end of file
+767f1af236d115e8388e1dcc28a4df1be48d6c85
\ No newline at end of file
index 432cfec58b68f86a2f911e70c80c21a340de062a..059b7bbe75725bccc9e16ffc74c1838a9e81692c 100644 (file)
@@ -12,7 +12,7 @@
 ** This file contains routines used for analyzing expressions and
 ** for generating VDBE code that evaluates expressions in SQLite.
 **
-** $Id: expr.c,v 1.92 2003/04/15 19:22:23 drh Exp $
+** $Id: expr.c,v 1.93 2003/04/19 17:27:25 drh Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -299,7 +299,9 @@ int sqliteExprIsConstant(Expr *p){
     case TK_ID:
     case TK_COLUMN:
     case TK_DOT:
+    case TK_FUNCTION:
       return 0;
+    case TK_NULL:
     case TK_STRING:
     case TK_INTEGER:
     case TK_FLOAT:
index 4d53bf3a15e6077bdfb9adb08b6ce5c4a26e39ff..18409166dfa0a66169acd75748b0dba783370b7e 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this file is testing the IN and BETWEEN operator.
 #
-# $Id: in.test,v 1.9 2003/01/31 17:16:37 drh Exp $
+# $Id: in.test,v 1.10 2003/04/19 17:27:25 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -84,9 +84,9 @@ do_test in-2.8 {
   execsql {SELECT a FROM t1 WHERE b IN (8*2,64/2) ORDER BY b}
 } {4 5}
 do_test in-2.9 {
-  set v [catch {execsql {SELECT a FROM t1 WHERE b IN (xyz(5,10),20)}} msg]
+  set v [catch {execsql {SELECT a FROM t1 WHERE b IN (max(5,10),20)}} msg]
   lappend v $msg
-} {1 {no such function: xyz}}
+} {1 {right-hand side of IN operator must be constant}}
 do_test in-2.10 {
   set v [catch {execsql {SELECT a FROM t1 WHERE min(0,b IN (a,30))}} msg]
   lappend v $msg
index a54db3fa2325c971b74e5740fe6c65dcf543e729..427dcc27d0719c7a2f3150e18cb47c2e30b06906 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this file is testing the use of indices in WHERE clases.
 #
-# $Id: where.test,v 1.15 2003/04/19 16:34:06 drh Exp $
+# $Id: where.test,v 1.16 2003/04/19 17:27:25 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -711,5 +711,31 @@ do_test where-10.1 {
     SELECT 1 WHERE abs(random())<0
   }
 } {}
+do_test where-10.2 {
+  proc tclvar_func {vname} {return [set ::$vname]}
+  db function tclvar tclvar_func
+  set ::v1 0
+  execsql {
+    SELECT count(*) FROM t1 WHERE tclvar('v1');
+  }
+} {0}
+do_test where-10.3 {
+  set ::v1 1
+  execsql {
+    SELECT count(*) FROM t1 WHERE tclvar('v1');
+  }
+} {100}
+do_test where-10.4 {
+  set ::v1 1
+  proc tclvar_func {vname} {
+    upvar #0 $vname v
+    set v [expr {!$v}]
+    return $v
+  }
+  execsql {
+    SELECT count(*) FROM t1 WHERE tclvar('v1');
+  }
+} {50}
+
 
 finish_test