From d1fa7bca3908f81bb12d677245b2d1a925978404 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 10 Jan 2009 13:24:50 +0000 Subject: [PATCH] Remove some unused code from expr.c in order to increase test coverage. (CVS 6156) FossilOrigin-Name: 2cbea64fb00a1b5b8aa0e9c958b2a09256ae59bc --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/expr.c | 48 ++++++++++++++---------------------------------- src/sqliteInt.h | 5 +++-- src/test1.c | 9 ++------- 5 files changed, 29 insertions(+), 53 deletions(-) diff --git a/manifest b/manifest index 77780d464b..cf737785c1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sbug\sin\sthe\sprevious\scommit\s-\suse\sSQL\scomments\sinstead\sof\sTcl\scomments\sin\sSQL\sblocks.\s(CVS\s6155) -D 2009-01-10T11:13:40 +C Remove\ssome\sunused\scode\sfrom\sexpr.c\sin\sorder\sto\sincrease\stest\scoverage.\s(CVS\s6156) +D 2009-01-10T13:24:51 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 05461a9b5803d5ad10c79f989801e9fd2cc3e592 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -111,7 +111,7 @@ F src/callback.c bee8949d619b1b7b1e4dfac8a19c5116ae1dd12a F src/complete.c cb14e06dbe79dee031031f0d9e686ff306afe07c F src/date.c e010095d85c895761627bb1d0d61d021aea930a9 F src/delete.c 6249005bdd8f85db6ec5f31ddb5c07de023693cc -F src/expr.c a385202af56d622b11d05e8d386def256155152b +F src/expr.c 8d19c0597bc2b7bdd88cd1975b49429e001f4838 F src/fault.c dc88c821842157460750d2d61a8a8b4197d047ff F src/func.c b0e1c61301f33d67b72ab15d85c80ed76e7c98ac F src/global.c 91723e45a2ad03ae5bb97a0a0d2dbb1a0e69527b @@ -158,12 +158,12 @@ F src/select.c ae72b604e47092521c4d9ae54e1b1cbeb872a747 F src/shell.c 65d19f8996a160f288087e31810f24025439c62a F src/sqlite.h.in 6cd2489e40fe97ba58c60044a4ced377e08b6d09 F src/sqlite3ext.h 1db7d63ab5de4b3e6b83dd03d1a4e64fef6d2a17 -F src/sqliteInt.h ab0419bbf296371f23404046924e6edd07c4af42 +F src/sqliteInt.h 4b2a8eb466c30daa90d25f9d3bb2e85b60ad47af F src/sqliteLimit.h 651a2757ba55aeba1da167786b6a8c3404433940 F src/status.c 237b193efae0cf6ac3f0817a208de6c6c6ef6d76 F src/table.c 23db1e5f27c03160987c122a078b4bb51ef0b2f8 F src/tclsqlite.c 4415e1033bd3e92b05a6a9cde911ee4de3b82df9 -F src/test1.c 243bbbdb91618ecce2a51e0ee1c7d8f3f8740193 +F src/test1.c 84221fbafc2f02e3a9285def0b3ed401f5cde258 F src/test2.c 724095fc69cb54b018aaa4463a56836c0b53a17a F src/test3.c 88a246b56b824275300e6c899634fbac1dc94b14 F src/test4.c f79ab52d27ff49b784b631a42e2ccd52cfd5c84c @@ -696,7 +696,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e -P 000aedb0471b5f5a69e7b61f5e1d4b2644994f32 -R b9af50aa7f5d731abd3dea65ed538d84 -U danielk1977 -Z eeac7b0df6e5be72914ec444096e70f6 +P 3d7a8de248ad5fba0e9c88f439cd2d988dcbab8c +R c24af2bb926bb5803a456faffe9201b2 +U drh +Z b201089d3d309f3e54d63a28fa490474 diff --git a/manifest.uuid b/manifest.uuid index 124ef98700..c7bf4f4583 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3d7a8de248ad5fba0e9c88f439cd2d988dcbab8c \ No newline at end of file +2cbea64fb00a1b5b8aa0e9c958b2a09256ae59bc \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 1b59a4cf86..6e114719d2 100644 --- a/src/expr.c +++ b/src/expr.c @@ -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.408 2008/12/15 15:27:52 drh Exp $ +** $Id: expr.c,v 1.409 2009/01/10 13:24:51 drh Exp $ */ #include "sqliteInt.h" #include @@ -920,7 +920,6 @@ static int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){ /* Fall through */ case TK_ID: case TK_COLUMN: - case TK_DOT: case TK_AGG_FUNCTION: case TK_AGG_COLUMN: #ifndef SQLITE_OMIT_SUBQUERY @@ -931,7 +930,6 @@ static int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){ #endif testcase( pExpr->op==TK_ID ); testcase( pExpr->op==TK_COLUMN ); - testcase( pExpr->op==TK_DOT ); testcase( pExpr->op==TK_AGG_FUNCTION ); testcase( pExpr->op==TK_AGG_COLUMN ); pWalker->u.i = 0; @@ -1038,12 +1036,6 @@ int sqlite3IsRowid(const char *z){ return 0; } -#ifdef SQLITE_TEST - int sqlite3_enable_in_opt = 1; -#else - #define sqlite3_enable_in_opt 1 -#endif - /* ** Return true if the IN operator optimization is enabled and ** the SELECT statement p exists and is of the @@ -1059,7 +1051,6 @@ static int isCandidateForInOpt(Select *p){ SrcList *pSrc; ExprList *pEList; Table *pTab; - if( !sqlite3_enable_in_opt ) return 0; /* IN optimization must be enabled */ if( p==0 ) return 0; /* right-hand side of IN is SELECT */ if( p->pPrior ) return 0; /* Not a compound SELECT */ if( p->selFlags & (SF_Distinct|SF_Aggregate) ){ @@ -1070,8 +1061,8 @@ static int isCandidateForInOpt(Select *p){ if( p->pOffset ) return 0; if( p->pWhere ) return 0; /* Has no WHERE clause */ pSrc = p->pSrc; - if( pSrc==0 ) return 0; /* A single table in the FROM clause */ - if( pSrc->nSrc!=1 ) return 0; + assert( pSrc!=0 ); + if( pSrc->nSrc!=1 ) return 0; /* Single term in FROM clause */ if( pSrc->a[0].pSelect ) return 0; /* FROM clause is not a subquery */ pTab = pSrc->a[0].pTab; if( pTab==0 ) return 0; @@ -1658,33 +1649,22 @@ static int usedAsColumnCache(Parse *pParse, int iFrom, int iTo){ } /* -** Theres is a value in register iCurrent. We ultimately want -** the value to be in register iTarget. It might be that -** iCurrent and iTarget are the same register. +** There is a value in register iReg. ** ** We are going to modify the value, so we need to make sure it -** is not a cached register. If iCurrent is a cached register, -** then try to move the value over to iTarget. If iTarget is a -** cached register, then clear the corresponding cache line. -** -** Return the register that the value ends up in. +** is not a cached register. If iReg is a cached register, +** then clear the corresponding cache line. */ -int sqlite3ExprWritableRegister(Parse *pParse, int iCurrent, int iTarget){ +void sqlite3ExprWritableRegister(Parse *pParse, int iReg){ int i; - assert( pParse->pVdbe!=0 ); - if( !usedAsColumnCache(pParse, iCurrent, iCurrent) ){ - return iCurrent; - } - if( iCurrent!=iTarget ){ - sqlite3VdbeAddOp2(pParse->pVdbe, OP_SCopy, iCurrent, iTarget); - } - for(i=0; inColCache; i++){ - if( pParse->aColCache[i].iReg==iTarget ){ - pParse->aColCache[i] = pParse->aColCache[--pParse->nColCache]; - pParse->iColCache = pParse->nColCache; + if( usedAsColumnCache(pParse, iReg, iReg) ){ + for(i=0; inColCache; i++){ + if( pParse->aColCache[i].iReg==iReg ){ + pParse->aColCache[i] = pParse->aColCache[--pParse->nColCache]; + pParse->iColCache = pParse->nColCache; + } } } - return iTarget; } /* @@ -3077,7 +3057,7 @@ int sqlite3GetTempReg(Parse *pParse){ } void sqlite3ReleaseTempReg(Parse *pParse, int iReg){ if( iReg && pParse->nTempRegaTempReg) ){ - sqlite3ExprWritableRegister(pParse, iReg, iReg); + sqlite3ExprWritableRegister(pParse, iReg); pParse->aTempReg[pParse->nTempReg++] = iReg; } } diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 0a93a9881a..a1f9250696 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -11,7 +11,7 @@ ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.821 2009/01/09 14:11:05 drh Exp $ +** @(#) $Id: sqliteInt.h,v 1.822 2009/01/10 13:24:51 drh Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ @@ -863,6 +863,7 @@ struct FuncDef { #define SQLITE_FUNC_CASE 0x02 /* Case-sensitive LIKE-type function */ #define SQLITE_FUNC_EPHEM 0x04 /* Ephemeral. Delete with VDBE */ #define SQLITE_FUNC_NEEDCOLL 0x08 /* sqlite3GetFuncCollSeq() might be called */ +#define SQLITE_FUNC_PRIVATE 0x10 /* Allowed for internal use only */ /* ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are @@ -2288,7 +2289,7 @@ void sqlite3ExprCodeMove(Parse*, int, int, int); void sqlite3ExprCodeCopy(Parse*, int, int, int); void sqlite3ExprClearColumnCache(Parse*, int); void sqlite3ExprCacheAffinityChange(Parse*, int, int); -int sqlite3ExprWritableRegister(Parse*,int,int); +void sqlite3ExprWritableRegister(Parse*,int); void sqlite3ExprHardCopy(Parse*,int,int); int sqlite3ExprCode(Parse*, Expr*, int); int sqlite3ExprCodeTemp(Parse*, Expr*, int*); diff --git a/src/test1.c b/src/test1.c index 7ce482a758..ba82bfed9c 100644 --- a/src/test1.c +++ b/src/test1.c @@ -13,7 +13,7 @@ ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** -** $Id: test1.c,v 1.341 2009/01/09 21:41:17 drh Exp $ +** $Id: test1.c,v 1.342 2009/01/10 13:24:51 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" @@ -4979,7 +4979,6 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ extern int sqlite3VdbeAddopTrace; #endif #ifdef SQLITE_TEST - extern int sqlite3_enable_in_opt; extern char sqlite3_query_plan[]; static char *query_plan = sqlite3_query_plan; #ifdef SQLITE_ENABLE_FTS3 @@ -5064,13 +5063,9 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ (char*)&sqlite3_sync_count, TCL_LINK_INT); Tcl_LinkVar(interp, "sqlite_fullsync_count", (char*)&sqlite3_fullsync_count, TCL_LINK_INT); -#ifdef SQLITE_TEST - Tcl_LinkVar(interp, "sqlite_enable_in_opt", - (char*)&sqlite3_enable_in_opt, TCL_LINK_INT); -#ifdef SQLITE_ENABLE_FTS3 +#if defined(SQLITE_ENABLE_FTS3) && defined(SQLITE_TEST) Tcl_LinkVar(interp, "sqlite_fts3_enable_parentheses", (char*)&sqlite3_fts3_enable_parentheses, TCL_LINK_INT); -#endif #endif return TCL_OK; }