From: drh Date: Tue, 2 Apr 2002 01:58:57 +0000 (+0000) Subject: Fix for bug #6: Correctly handle functions in the WHERE clause of a join. (CVS 513) X-Git-Tag: version-3.6.10~5562 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dd579122da3ebb1c573f9edee63d74864384703f;p=thirdparty%2Fsqlite.git Fix for bug #6: Correctly handle functions in the WHERE clause of a join. (CVS 513) FossilOrigin-Name: bdd8ce584e16fe288a7e8386f897cb36a60e8431 --- diff --git a/manifest b/manifest index 729f0c12e0..925f039be3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sfor\sbug\s#7:\sCorrectly\sdisplay\sthe\sP3\soperand\sin\sa\sVDBE\strace\swhen\sthe\noperand\sis\sreally\sa\spointer\sto\sa\sstructure.\s(CVS\s512) -D 2002-04-02T01:44:51 +C Fix\sfor\sbug\s#6:\sCorrectly\shandle\sfunctions\sin\sthe\sWHERE\sclause\sof\sa\sjoin.\s(CVS\s513) +D 2002-04-02T01:58:58 F Makefile.in 50f1b3351df109b5774771350d8c1b8d3640130d F Makefile.template 89e373b2dad0321df00400fa968dc14b61a03296 F README a4c0ba11354ef6ba0776b400d057c59da47a4cc0 @@ -54,7 +54,7 @@ F src/update.c 7dd714a6a7fa47f849ebb36b6d915974d6c6accb F src/util.c b34cd91387bbfdc79319ea451a7d120cef478120 F src/vdbe.c 3cebe9f77cac311a3c537587258946d04a09c58f F src/vdbe.h f9be1f6e9a336c3ff4d14ea7489ee976e07460cc -F src/where.c 34d91fd5d822c2663caeb023f72d60df316ebf29 +F src/where.c e6292ab9d41aa55005bcca75e6d5e69139fad61b F test/all.test 6aa106eee4d7127afa5cee97c51a783a79694ead F test/bigrow.test 8ab252dba108f12ad64e337b0f2ff31a807ac578 F test/btree.test bf326f546a666617367a7033fa2c07451bd4f8e1 @@ -85,7 +85,7 @@ F test/quick.test 6f023c7a73fc413e6d65b7a1879c79764038dc05 F test/quote.test 286db944717afa9a9bf829dd85e59185c65d5435 F test/rowid.test 4c55943300cddf73dd0f88d40a268cab14c83274 F test/select1.test 572d53f7b28c35a1efdce207f7579523358ba637 -F test/select2.test ed2c1882857106b85478f54f67000e14966be4c4 +F test/select2.test 7b59fb17647eda8c7e21d790d4045e30699982af F test/select3.test 9469c332250a75a0ef1771fb5da62dc04ec77f18 F test/select4.test 29a2ffb187f3d8b6ca42a0a6b619e9cabe12e228 F test/select5.test c2a6c4a003316ee42cbbd689eebef8fdce0db2ac @@ -116,7 +116,7 @@ F www/arch.fig d5f9752a4dbf242e9cfffffd3f5762b6c63b3bcf F www/arch.png 82ef36db1143828a7abc88b1e308a5f55d4336f4 F www/arch.tcl 72a0c80e9054cc7025a50928d28d9c75c02c2b8b F www/c_interface.tcl 567cda531aac9d68a61ef02e26c6b202bd856db2 -F www/changes.tcl bb47ad160743e11dba5a4b73477150b6859ab1a3 +F www/changes.tcl 7ba1054ca1c3119f305f7bbaa6a69bbff2f52410 F www/conflict.tcl 81dd21f9a679e60aae049e9dd8ab53d59570cda2 F www/crosscompile.tcl 3622ebbe518927a3854a12de51344673eb2dd060 F www/download.tcl 29aa6679ca29621d10613f60ebbbda18f4b91c49 @@ -131,7 +131,7 @@ F www/speed.tcl da8afcc1d3ccc5696cfb388a68982bc3d9f7f00f F www/sqlite.tcl 8b5884354cb615049aed83039f8dfe1552a44279 F www/tclsqlite.tcl 829b393d1ab187fd7a5e978631b3429318885c49 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218 -P 0cb5cfa814bceecea1a346535cac24ec8e2941d7 -R e07a70b33336e9b181f22c86f5352ca5 +P 734dde765b38d61feaa5520e6481c77022367892 +R fc0491616bb288b6a30cabaf5c86972c U drh -Z 9c1b0b9c16e5f7f216788d912c729dd6 +Z 1732047b7e97478437e3cc52f209689b diff --git a/manifest.uuid b/manifest.uuid index 6fad890cb1..54e65056f1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -734dde765b38d61feaa5520e6481c77022367892 \ No newline at end of file +bdd8ce584e16fe288a7e8386f897cb36a60e8431 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 32077dc157..f1736c9c7b 100644 --- a/src/where.c +++ b/src/where.c @@ -13,7 +13,7 @@ ** the WHERE clause of SQL statements. Also found here are subroutines ** to generate VDBE code to evaluate expressions. ** -** $Id: where.c,v 1.38 2002/03/02 17:04:09 drh Exp $ +** $Id: where.c,v 1.39 2002/04/02 01:58:58 drh Exp $ */ #include "sqliteInt.h" @@ -90,6 +90,12 @@ static int exprTableUsage(int base, Expr *p){ if( p->pLeft ){ mask |= exprTableUsage(base, p->pLeft); } + if( p->pList ){ + int i; + for(i=0; ipList->nExpr; i++){ + mask |= exprTableUsage(base, p->pList->a[i].pExpr); + } + } return mask; } diff --git a/test/select2.test b/test/select2.test index c78dae8e6e..593b7aadc5 100644 --- a/test/select2.test +++ b/test/select2.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this file is testing the SELECT statement. # -# $Id: select2.test,v 1.16 2001/11/23 00:24:13 drh Exp $ +# $Id: select2.test,v 1.17 2002/04/02 01:58:58 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -113,4 +113,19 @@ do_test select2-3.3 { set sqlite_search_count } {29999} +# Make sure we can optimize functions in the WHERE clause that +# use fields from two or more different table. (Bug #6) +# +do_test select2-4.1 { + execsql { + CREATE TABLE aa(a); + CREATE TABLE bb(b); + INSERT INTO aa VALUES(1); + INSERT INTO aa VALUES(3); + INSERT INTO bb VALUES(2); + INSERT INTO bb VALUES(4); + SELECT * FROM aa, bb WHERE max(a,b)>2; + } +} {1 4 3 2 3 4} + finish_test diff --git a/www/changes.tcl b/www/changes.tcl index d6dfb306a6..fbdd1f2ef5 100644 --- a/www/changes.tcl +++ b/www/changes.tcl @@ -25,7 +25,12 @@ proc chng {date desc} { puts "

    $desc

" } -chng {2002 Mar 31 (2.4.5)} { +chng {2002 Apr 01 (2.4.5)} { +
  • Bug fix: Correctly handle functions that appear in the WHERE clause + of a SELECT.
  • +
  • When the PRAGMA vdbe_trace=ON is set, correctly print the P3 operand + value when it is a pointer to a structure rather than a pointer to + a string.
  • When inserting an explicit NULL into an INTEGER PRIMARY KEY, convert the NULL value into a unique key automatically.
  • }