Fix a problem with CASTs and the new CSE mechanism. (CVS 4950)

FossilOrigin-Name: e25939fb25ec8bde8500a672ca5be3cbb514ac3a
This commit is contained in:
drh 2008-04-01 12:24:11 +00:00
parent da250ea599
commit b3843a82ea
4 changed files with 24 additions and 10 deletions

View File

@ -1,5 +1,5 @@
C Fix\sthe\sCSE\smechanism\sso\sthat\sit\stakes\sinto\saccount\scolumn\saffinity\nchanges\sthat\smight\sbe\simposed\sby\scomparison\soperators.\s(CVS\s4949)
D 2008-04-01T05:07:15
C Fix\sa\sproblem\swith\sCASTs\sand\sthe\snew\sCSE\smechanism.\s(CVS\s4950)
D 2008-04-01T12:24:11
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
F Makefile.in b861627d91df5ee422c54237aa38296954dc0151
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -95,7 +95,7 @@ F src/complete.c 4cf68fd75d60257524cbe74f87351b9848399131
F src/date.c e41ce4513fb0e359dc678d6bddb4ace135fe365d
F src/delete.c 74d5c9c824848a14d7dee37264ec302b168c4ddb
F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b
F src/expr.c 11e9a05c4eb60789cd6f1b056d1b7039ec3512c8
F src/expr.c 64843f848a36edf1fe4d95bfd3e7a9090580c4a3
F src/fault.c 83057e86815d473e526f7df0b0108dfdd022ff23
F src/func.c c9e8c7ff4c45027edee89bde7adbf86a3a3b2afe
F src/hash.c 53655c312280211444bfe23af6490a460aec2980
@ -248,7 +248,7 @@ F test/crash5.test c7ddcf7ca83abc19901b977732144234ac72a938
F test/crash6.test 873d851c5ba2a46e0f9974c54e1d4a77d9a587d5
F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2
F test/createtab.test 199cf68f44e5d9e87a0b8afc7130fdeb4def3272
F test/cse.test ad21bab7f66328a90dd429ebd3009c3a927ba8ab
F test/cse.test 36b0079f67f187e4dffe8f3047e04cf10f5f75f9
F test/date.test 8db95a0ba2c8f4c8762ce66859a036c51959a6be
F test/default.test 252298e42a680146b1dd64f563b95bdf088d94fb
F test/delete.test 57533e88e886608bf5ae0f394e14c2eb1b1f7754
@ -621,7 +621,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
P 7e8156129d6d240fe046bbc4ea269ebe1657e2a1
R de548c9eaa6939bb8e637e0b7174d31d
P 91cc646e2b0c1d62a1989405cc9384a2c22d98d0
R 0b78187a1b465d3d8c93c57ba92e771e
U drh
Z f0f4a4427173bdf817f07a4e85556845
Z ed15e3f8ef7420ee4fecf6ce237f8aee

View File

@ -1 +1 @@
91cc646e2b0c1d62a1989405cc9384a2c22d98d0
e25939fb25ec8bde8500a672ca5be3cbb514ac3a

View 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.362 2008/04/01 05:07:15 drh Exp $
** $Id: expr.c,v 1.363 2008/04/01 12:24:11 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@ -2204,6 +2204,7 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
assert( to_op==OP_ToInt || aff!=SQLITE_AFF_INTEGER );
assert( to_op==OP_ToReal || aff!=SQLITE_AFF_REAL );
sqlite3VdbeAddOp1(v, to_op, inReg);
sqlite3ExprCacheAffinityChange(pParse, inReg, 1);
break;
}
#endif /* SQLITE_OMIT_CAST */

View File

@ -13,7 +13,7 @@
# factoring constant expressions out of loops and for
# common subexpression eliminations.
#
# $Id: cse.test,v 1.2 2008/04/01 03:27:39 drh Exp $
# $Id: cse.test,v 1.3 2008/04/01 12:24:11 drh Exp $
#
set testdir [file dirname $argv0]
@ -64,6 +64,19 @@ do_test cse-1.8 {
SELECT a, a%a, a==a, a!=a, a<a, a<=a, a IS NULL, a NOT NULL, a FROM t1
}
} {1 0 1 0 0 1 0 1 1 2 0 1 0 0 1 0 1 2}
do_test cse-1.9 {
execsql {
SELECT NOT b, ~b, NOT NOT b, b FROM t1
}
} {0 -12 1 11 0 -22 1 21}
do_test cse-1.10 {
explain {
SELECT CAST(b AS integer), typeof(b), CAST(b AS text), typeof(b) FROM t1
}
execsql {
SELECT CAST(b AS integer), typeof(b), CAST(b AS text), typeof(b) FROM t1
}
} {11 integer 11 integer 21 integer 21 integer}
# Overflow the column cache. Create queries involving more and more
# columns until the cache overflows. Verify correct operation throughout.