1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-09 14:21:03 +03:00

Modify the optimizer so that it does not assume that functions are

constant. (CVS 920)

FossilOrigin-Name: 767f1af236d115e8388e1dcc28a4df1be48d6c85
This commit is contained in:
drh
2003-04-19 17:27:24 +00:00
parent 37ea94b8c9
commit 7bdc0c1def
5 changed files with 42 additions and 14 deletions

View File

@@ -1,5 +1,5 @@
C Bug\sin\sWHERE\sclause\sprocessing\sfixed.\s\sTicket\s#298.\s(CVS\s919) C Modify\sthe\soptimizer\sso\sthat\sit\sdoes\snot\sassume\sthat\sfunctions\sare\nconstant.\s(CVS\s920)
D 2003-04-19T16:34:05 D 2003-04-19T17:27:25
F Makefile.in df3a4db41a7450468b5fe934d9dd8f723b631249 F Makefile.in df3a4db41a7450468b5fe934d9dd8f723b631249
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -28,7 +28,7 @@ F src/build.c 6694013c86c4c480754f515ddab561302c6e732a
F src/copy.c 8699e571994934c78f70761a1458d7b9e9e75073 F src/copy.c 8699e571994934c78f70761a1458d7b9e9e75073
F src/delete.c af65b26d9d13abbf63fdc4e97b88d26c700b04bb F src/delete.c af65b26d9d13abbf63fdc4e97b88d26c700b04bb
F src/encode.c faf03741efe921755ec371cf4a6984536de00042 F src/encode.c faf03741efe921755ec371cf4a6984536de00042
F src/expr.c 942f535c8906ef81df00bac62223868feb78424b F src/expr.c 3c0ff6b7b34d483ea03fb86c66f28b929542c782
F src/func.c 882c3ed5a02be18cd904715c7ec62947a34a3605 F src/func.c 882c3ed5a02be18cd904715c7ec62947a34a3605
F src/hash.c 4fc39feb7b7711f6495ee9f2159559bedb043e1f F src/hash.c 4fc39feb7b7711f6495ee9f2159559bedb043e1f
F src/hash.h cd0433998bc1a3759d244e1637fe5a3c13b53bf8 F src/hash.h cd0433998bc1a3759d244e1637fe5a3c13b53bf8
@@ -80,7 +80,7 @@ F test/fkey1.test d65c824459916249bee501532d6154ddab0b5db7
F test/format3.test 64ab6c4db132b28a645996d413530f7b2a462cc2 F test/format3.test 64ab6c4db132b28a645996d413530f7b2a462cc2
F test/func.test 000515779001ac6899eec4b54e65c6e2501279d4 F test/func.test 000515779001ac6899eec4b54e65c6e2501279d4
F test/hook.test 7a4c97b886801d265c981dc4ec123c77af642a9d F test/hook.test 7a4c97b886801d265c981dc4ec123c77af642a9d
F test/in.test 3171a2b3170a8223665c1a4f26be5f3eda36cc4b F test/in.test 22de8a3eb27265aab723adc513bea0e76bef70c6
F test/index.test 90ef4c426865f15937858bd433cc82b9c11af913 F test/index.test 90ef4c426865f15937858bd433cc82b9c11af913
F test/insert.test 5697ba098e4d8a6f0151f281b7e39dec9c439e05 F test/insert.test 5697ba098e4d8a6f0151f281b7e39dec9c439e05
F test/insert2.test c288375a64dad3295044714f0dfed4a193cf067f F test/insert2.test c288375a64dad3295044714f0dfed4a193cf067f
@@ -126,7 +126,7 @@ F test/update.test 198360dfa14e65354dbcc66d5b98d8070780e42b
F test/vacuum.test 059871b312eb910bbe49dafde1d01490cc2c6bbe F test/vacuum.test 059871b312eb910bbe49dafde1d01490cc2c6bbe
F test/version.test 605fd0d7e7d571370c32b12dbf395b58953de246 F test/version.test 605fd0d7e7d571370c32b12dbf395b58953de246
F test/view.test c64fa39ea57f3c2066c854290f032ad13b23b83d F test/view.test c64fa39ea57f3c2066c854290f032ad13b23b83d
F test/where.test 94adbfe53e5c9660b9756f23b29e3b2c3d2792a9 F test/where.test d719129a052280fe245a2ddcbd09bcc0b8c17ce4
F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b
F tool/lemon.c 14fedcde9cf70aa6040b89de164cf8f56f92a4b9 F tool/lemon.c 14fedcde9cf70aa6040b89de164cf8f56f92a4b9
F tool/lempar.c 73a991cc3017fb34804250fa901488b5147b3717 F tool/lempar.c 73a991cc3017fb34804250fa901488b5147b3717
@@ -162,7 +162,7 @@ F www/speed.tcl cb4c10a722614aea76d2c51f32ee43400d5951be
F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098 F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098
F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331 F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
P 1e3d0d094776c2a429fa2a3eebc036a0b6374862 P 9b619c98b586a207a87942640d3a94220ff8ab02
R 869f63511d353e87dc2dd3a60513ae60 R 7412289c17f86b36c7e9e5ef2d7e5a25
U drh U drh
Z 804a9e6e52c395fdc713233765cd05d5 Z f9b7a3e33fd7e690b2414333a1a1aca5

View File

@@ -1 +1 @@
9b619c98b586a207a87942640d3a94220ff8ab02 767f1af236d115e8388e1dcc28a4df1be48d6c85

View File

@@ -12,7 +12,7 @@
** This file contains routines used for analyzing expressions and ** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite. ** 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 "sqliteInt.h"
#include <ctype.h> #include <ctype.h>
@@ -299,7 +299,9 @@ int sqliteExprIsConstant(Expr *p){
case TK_ID: case TK_ID:
case TK_COLUMN: case TK_COLUMN:
case TK_DOT: case TK_DOT:
case TK_FUNCTION:
return 0; return 0;
case TK_NULL:
case TK_STRING: case TK_STRING:
case TK_INTEGER: case TK_INTEGER:
case TK_FLOAT: case TK_FLOAT:

View File

@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The # This file implements regression tests for SQLite library. The
# focus of this file is testing the IN and BETWEEN operator. # 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] set testdir [file dirname $argv0]
source $testdir/tester.tcl 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} execsql {SELECT a FROM t1 WHERE b IN (8*2,64/2) ORDER BY b}
} {4 5} } {4 5}
do_test in-2.9 { 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 lappend v $msg
} {1 {no such function: xyz}} } {1 {right-hand side of IN operator must be constant}}
do_test in-2.10 { do_test in-2.10 {
set v [catch {execsql {SELECT a FROM t1 WHERE min(0,b IN (a,30))}} msg] set v [catch {execsql {SELECT a FROM t1 WHERE min(0,b IN (a,30))}} msg]
lappend v $msg lappend v $msg

View File

@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The # This file implements regression tests for SQLite library. The
# focus of this file is testing the use of indices in WHERE clases. # 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] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@@ -711,5 +711,31 @@ do_test where-10.1 {
SELECT 1 WHERE abs(random())<0 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 finish_test