From fec19aad44a6da8a53bf6801ca5357a82c56bcd6 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 19 May 2004 20:41:03 +0000 Subject: [PATCH] Correctly handle 64-bit integers in SQL statements. (CVS 1408) FossilOrigin-Name: 34f03ba6a9d6e2144d0c6cbbbeb37b4c69705f1f --- manifest | 26 ++++++++-------- manifest.uuid | 2 +- src/expr.c | 59 +++++++++++++++++++----------------- src/sqliteInt.h | 9 ++++-- src/util.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++-- src/vdbe.c | 48 ++++++++---------------------- src/vdbeaux.c | 12 ++------ src/where.c | 9 ++---- test/misc1.test | 21 +++++++------ test/quick.test | 3 +- 10 files changed, 156 insertions(+), 112 deletions(-) diff --git a/manifest b/manifest index 8c1cda16d3..8c0c07b56d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sopcode\snames\sand\scomments\sto\sbetter\sdescribe\sthe\soperation\sof\nthe\sincrKey\sflag.\s\sOP_MoveTo\sbecomes\sOP_MoveGe.\s(CVS\s1407) -D 2004-05-19T14:56:56 +C Correctly\shandle\s64-bit\sintegers\sin\sSQL\sstatements.\s(CVS\s1408) +D 2004-05-19T20:41:03 F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd @@ -31,7 +31,7 @@ F src/copy.c 4d2038602fd0549d80c59bda27d96f13ea9b5e29 F src/date.c 0eb0a89960bb45c7f7e768748605a7a97b0c8064 F src/delete.c 2e1dda38345416a1ea1c0a6468589a7472334dac F src/encode.c a876af473d1d636faa3dca51c7571f2e007eea37 -F src/expr.c de3d86e98d9073399a8173610fb9f02d0e197aea +F src/expr.c 34fceec0ae7d9108d6cf98b0685d3d2afa962728 F src/func.c cfbb7096efb58e2857e3b312a8958a12774b625a F src/hash.c 440c2f8cb373ee1b4e13a0988489c7cd95d55b6f F src/hash.h 762d95f1e567664d1eafc1687de755626be962fb @@ -49,7 +49,7 @@ F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3 F src/select.c d01c03462d57b9d1ea25eea297bbd2c1b1c70e47 F src/shell.c 0c4662e13bfbfd3d13b066c5859cc97ad2f95d21 F src/sqlite.h.in 8c62076ea226b1870df977d7438bf99383d02387 -F src/sqliteInt.h 1da4a9c26da43f235c45c1de0c49fadf6c40d0e6 +F src/sqliteInt.h 6c3822050d10eb648dd04e4ca68a2e577e145496 F src/table.c af14284fa36c8d41f6829e3f2819dce07d3e2de2 F src/tclsqlite.c fbf0fac73624ae246551a6c671f1de0235b5faa1 F src/test1.c 12ef76b8aaba4408422f21f269256b630d4dd627 @@ -61,13 +61,13 @@ F src/tokenize.c e7536dd31205d5afb76c1bdc832dea009c7a3847 F src/trigger.c 11afe9abfba13a2ba142944c797c952e162d117f F src/update.c 1f6687f8d1085f896a24c0fa13d802223ed55539 F src/utf.c 48c537bf7990ce32a36b051401874d024ec2a07b -F src/util.c b72f775a6c3fa404d70250382f63d708e17bc332 +F src/util.c 35d20bd8d467861747262d12b87045d937781d93 F src/vacuum.c c134702e023db8778e6be59ac0ea7b02315b5476 -F src/vdbe.c 42ecfcd3bf67b9922702cbad2dd87be0bc1cc986 +F src/vdbe.c 0f1918d2a702c5b99c7713646a60c78fe5085cfc F src/vdbe.h 314e9c07db73a42a6ba91ab7539e27652fc88870 F src/vdbeInt.h faaa64433d2498f7a6eabccebac854e097b83680 -F src/vdbeaux.c 453e9f6d98fffec8c07ecd99ad9e1bc5b5cf09b1 -F src/where.c e7a7eeb46a81f8ccf84a297db99b3121429769cb +F src/vdbeaux.c c241a6ba1cc7dcd4158da6c4329d33de3c4d0e03 +F src/where.c 626b2cbc4290d8be6c04ad7c8395f46d4e21d0d8 F test/all.test 569a92a8ee88f5300c057cc4a8f50fbbc69a3242 F test/attach.test cb9b884344e6cfa5e165965d5b1adea679a24c83 F test/attach2.test 7c388dee63a4c1997695c3d41957f32ce784ac56 @@ -109,7 +109,7 @@ F test/malloc.test 2cfcffb7c858640e01e6520ee1cd54ca57d98e80 F test/memdb.test 6ece25c7c0e6500199d3662607a3edca081abb2a F test/memleak.test 4d5d374c8ea1fc5ac634aed58cac1047848ce65e F test/minmax.test 9dcf52f713b1b9e61d0a88a51eb8bb2e3c52d0ab -F test/misc1.test 0b98d493b0cf55cb5f53e1f3df8107c166eecb5a +F test/misc1.test 2e1c0d592f082491984cccabfae213cb50fc574f F test/misc2.test 10c2ce26407d37411b96273e552d5095393732be F test/misc3.test 3b5e369514a3ba3f919fb7eafa7d027440b5079e F test/misuse.test 1095f26d1aed406c65e1d2eba651c4bb7c38cbff @@ -120,7 +120,7 @@ F test/pager2.test 7ff175a28484fd324df9315dfe35f6fb159910ec F test/pragma.test 06c4e51998dd68115ef7a60abeeff7accf198f83 F test/printf.test 46b3d07d59d871d0831b4a657f6dfcafe0574850 F test/progress.test 701b6115c2613128ececdfe1398a1bd0e1a4cfb3 x -F test/quick.test 86f868f184dca1420304a32de650de40939a04d1 +F test/quick.test d73d55f7535287135805a41eb2f522091f5f5e0e F test/quote.test 08f23385c685d3dc7914ec760d492cacea7f6e3d F test/rowid.test 863e6e75878cccf03d166fe52023f20e09508683 F test/select1.test 3bfcccd2eadcddbb07f1f5da6550aee8484ea4fb @@ -193,7 +193,7 @@ F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604 F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4 -P 7c31e257e2d109bfedf63dc307b422e1abd46d0e -R 5feb1ed8cc5ac536a6c28ba5fb650adc +P 8f249c45cbc77f4320798ff1a830b55e5c74888a +R ceb7c1c3fcb5c3509b4127012953e677 U drh -Z 09dcaf5d692d1cd749b1f77eda04144f +Z a482adf3fb5ad935e0fa295b0148f6f0 diff --git a/manifest.uuid b/manifest.uuid index 7b56c40d86..3ac2586e85 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8f249c45cbc77f4320798ff1a830b55e5c74888a \ No newline at end of file +34f03ba6a9d6e2144d0c6cbbbeb37b4c69705f1f \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index a0fff71d8e..65821bd535 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.122 2004/05/18 10:06:25 danielk1977 Exp $ +** $Id: expr.c,v 1.123 2004/05/19 20:41:03 drh Exp $ */ #include "sqliteInt.h" #include @@ -442,8 +442,7 @@ int sqlite3ExprIsConstant(Expr *p){ int sqlite3ExprIsInteger(Expr *p, int *pValue){ switch( p->op ){ case TK_INTEGER: { - if( sqlite3FitsIn32Bits(p->token.z) ){ - *pValue = atoi(p->token.z); + if( sqlite3GetInt32(p->token.z, pValue) ){ return 1; } break; @@ -453,8 +452,7 @@ int sqlite3ExprIsInteger(Expr *p, int *pValue){ int n = p->token.n; if( n>0 && z[0]=='-' ){ z++; n--; } while( n>0 && *z && isdigit(*z) ){ z++; n--; } - if( n==0 && sqlite3FitsIn32Bits(p->token.z) ){ - *pValue = atoi(p->token.z); + if( n==0 && sqlite3GetInt32(p->token.z, pValue) ){ return 1; } break; @@ -1131,6 +1129,19 @@ int sqlite3ExprType(Expr *p){ return SQLITE_SO_NUM; } +/* +** Generate an instruction that will put the integer describe by +** text z[0..n-1] on the stack. +*/ +static void codeInteger(Vdbe *v, const char *z, int n){ + int i; + if( sqlite3GetInt32(z, &i) || (i=0, sqlite3FitsIn64Bits(z))!=0 ){ + sqlite3VdbeOp3(v, OP_Integer, i, 0, z, n); + }else{ + sqlite3VdbeOp3(v, OP_Real, 0, 0, z, n); + } +} + /* ** Generate code into the current Vdbe to evaluate the given ** expression and leave the result on the top of stack. @@ -1162,6 +1173,8 @@ void sqlite3ExprCode(Parse *pParse, Expr *pExpr){ case TK_LSHIFT: op = OP_ShiftLeft; break; case TK_RSHIFT: op = OP_ShiftRight; break; case TK_REM: op = OP_Remainder; break; + case TK_FLOAT: op = OP_Real; break; + case TK_STRING: op = OP_String; break; default: break; } switch( pExpr->op ){ @@ -1175,18 +1188,13 @@ void sqlite3ExprCode(Parse *pParse, Expr *pExpr){ } break; } - case TK_STRING: - case TK_FLOAT: case TK_INTEGER: { - if( pExpr->op==TK_INTEGER && sqlite3FitsIn32Bits(pExpr->token.z) ){ - sqlite3VdbeAddOp(v, OP_Integer, atoi(pExpr->token.z), 0); - }else if( pExpr->op==TK_FLOAT || pExpr->op==TK_INTEGER ){ - sqlite3VdbeAddOp(v, OP_Real, 0, 0); - }else{ - sqlite3VdbeAddOp(v, OP_String, 0, 0); - } - assert( pExpr->token.z ); - sqlite3VdbeChangeP3(v, -1, pExpr->token.z, pExpr->token.n); + codeInteger(v, pExpr->token.z, pExpr->token.n); + break; + } + case TK_FLOAT: + case TK_STRING: { + sqlite3VdbeOp3(v, op, 0, 0, pExpr->token.z, pExpr->token.n); sqlite3VdbeDequoteP3(v, -1); break; } @@ -1238,17 +1246,17 @@ void sqlite3ExprCode(Parse *pParse, Expr *pExpr){ break; } case TK_UMINUS: { - assert( pExpr->pLeft ); - if( pExpr->pLeft->op==TK_FLOAT || pExpr->pLeft->op==TK_INTEGER ){ - Token *p = &pExpr->pLeft->token; + Expr *pLeft = pExpr->pLeft; + assert( pLeft ); + if( pLeft->op==TK_FLOAT || pLeft->op==TK_INTEGER ){ + Token *p = &pLeft->token; char *z = sqliteMalloc( p->n + 2 ); sprintf(z, "-%.*s", p->n, p->z); - if( pExpr->pLeft->op==TK_INTEGER && sqlite3FitsIn32Bits(z) ){ - sqlite3VdbeAddOp(v, OP_Integer, atoi(z), 0); + if( pLeft->op==TK_FLOAT ){ + sqlite3VdbeOp3(v, OP_Real, 0, 0, z, p->n+1); }else{ - sqlite3VdbeAddOp(v, OP_Real, 0, 0); + codeInteger(v, z, p->n+1); } - sqlite3VdbeChangeP3(v, -1, z, p->n+1); sqliteFree(z); break; } @@ -1289,7 +1297,7 @@ void sqlite3ExprCode(Parse *pParse, Expr *pExpr){ /* FIX ME: The following is a temporary hack. */ if( 0==sqlite3StrNICmp(zId, "classof", nId) ){ assert( nExpr==1 ); - sqlite3VdbeOp3(v, OP_Class, nExpr, 0, 0, 0); + sqlite3VdbeAddOp(v, OP_Class, nExpr, 0); }else{ sqlite3VdbeOp3(v, OP_Function, nExpr, 0, (char*)pDef, P3_POINTER); } @@ -1800,6 +1808,3 @@ FuncDef *sqlite3FindFunction( } return p; } - - - diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 9334083fb7..afea0e4650 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -11,7 +11,7 @@ ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.237 2004/05/18 23:21:36 drh Exp $ +** @(#) $Id: sqliteInt.h,v 1.238 2004/05/19 20:41:03 drh Exp $ */ #include "config.h" #include "sqlite.h" @@ -478,6 +478,7 @@ struct Column { */ struct CollSeq { char *zName; /* Name of the collating sequence */ + u8 reverseOrder; /* Compare in reverse order. Used by OP_Sort only */ void *pUser; /* First argument to xCmp() */ int (*xCmp)(void*,int,const void*,int,const void*); /* Comparison function */ }; @@ -1312,8 +1313,9 @@ int sqlite3FixExprList(DbFixer*, ExprList*); int sqlite3FixTriggerStep(DbFixer*, TriggerStep*); double sqlite3AtoF(const char *z, const char **); char *sqlite3_snprintf(int,char*,const char*,...); -int sqlite3FitsIn32Bits(const char *); - +int sqlite3GetInt32(const char *, int*); +int sqlite3GetInt64(const char *, i64*); +int sqlite3FitsIn64Bits(const char *); unsigned char *sqlite3utf16to8(const void *pData, int N); void *sqlite3utf8to16be(const unsigned char *pIn, int N); void *sqlite3utf8to16le(const unsigned char *pIn, int N); @@ -1330,3 +1332,4 @@ char sqlite3CompareAffinity(Expr *pExpr, char aff2); char const *sqlite3AffinityString(char affinity); int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity); char sqlite3ExprAffinity(Expr *pExpr); +int sqlite3atoi64(const char*, i64*); diff --git a/src/util.c b/src/util.c index d37a56eb20..c677f61186 100644 --- a/src/util.c +++ b/src/util.c @@ -14,7 +14,7 @@ ** This file contains functions for allocating memory, comparing ** strings, and stuff like that. ** -** $Id: util.c,v 1.85 2004/05/19 10:34:57 danielk1977 Exp $ +** $Id: util.c,v 1.86 2004/05/19 20:41:03 drh Exp $ */ #include "sqliteInt.h" #include @@ -610,6 +610,38 @@ double sqlite3AtoF(const char *z, const char **pzEnd){ return sign<0 ? -v1 : v1; } +/* +** Return TRUE if zNum is a 64-bit signed integer and write +** the value of the integer into *pNum. If zNum is not an integer +** or is an integer that is too large to be expressed with 64 bits, +** then return false. If n>0 and the integer is string is not +** exactly n bytes long, return false. +** +** When this routine was originally written it dealt with only +** 32-bit numbers. At that time, it was much faster than the +** atoi() library routine in RedHat 7.2. +*/ +int sqlite3atoi64(const char *zNum, i64 *pNum){ + i64 v = 0; + int neg; + int i, c; + if( *zNum=='-' ){ + neg = 1; + zNum++; + }else if( *zNum=='+' ){ + neg = 0; + zNum++; + }else{ + neg = 0; + } + for(i=0; (c=zNum[i])>='0' && c<='9'; i++){ + v = v*10 + c - '0'; + } + *pNum = neg ? -v : v; + return c==0 && i>0 && + (i<19 || (i==19 && memcmp(zNum,"9223372036854775807",19)<=0)); +} + /* ** The string zNum represents an integer. There might be some other ** information following the integer too, but that part is ignored. @@ -621,13 +653,55 @@ double sqlite3AtoF(const char *z, const char **pzEnd){ ** 2147483648 will not fit in 32 bits. So it seems safer to return ** false. */ -int sqlite3FitsIn32Bits(const char *zNum){ +static int sqlite3FitsIn32Bits(const char *zNum){ int i, c; if( *zNum=='-' || *zNum=='+' ) zNum++; for(i=0; (c=zNum[i])>='0' && c<='9'; i++){} return i<10 || (i==10 && memcmp(zNum,"2147483647",10)<=0); } +/* +** If zNum represents an integer that will fit in 32-bits, then set +** *pValue to that integer and return true. Otherwise return false. +*/ +int sqlite3GetInt32(const char *zNum, int *pValue){ + if( sqlite3FitsIn32Bits(zNum) ){ + *pValue = atoi(zNum); + return 1; + } + return 0; +} + +/* +** The string zNum represents an integer. There might be some other +** information following the integer too, but that part is ignored. +** If the integer that the prefix of zNum represents will fit in a +** 64-bit signed integer, return TRUE. Otherwise return FALSE. +** +** This routine returns FALSE for the string -9223372036854775808 even that +** that number will, in theory fit in a 64-bit integer. Positive +** 9223373036854775808 will not fit in 64 bits. So it seems safer to return +** false. +*/ +int sqlite3FitsIn64Bits(const char *zNum){ + int i, c; + if( *zNum=='-' || *zNum=='+' ) zNum++; + for(i=0; (c=zNum[i])>='0' && c<='9'; i++){} + return i<19 || (i==19 && memcmp(zNum,"9223372036854775807",19)<=0); +} + +/* +** If zNum represents an integer that will fit in 64-bits, then set +** *pValue to that integer and return true. Otherwise return false. +*/ +int sqlite3GetInt64(const char *zNum, i64 *pValue){ + if( sqlite3FitsIn64Bits(zNum) ){ + sqlite3atoi64(zNum, pValue); + return 1; + } + return 0; +} + /* This comparison routine is what we use for comparison operations ** between numeric values in an SQL expression. "Numeric" is a little ** bit misleading here. What we mean is that the strings have a @@ -1180,4 +1254,3 @@ int sqlite3VarintLen(u64 v){ }while( v!=0 && i<9 ); return i; } - diff --git a/src/vdbe.c b/src/vdbe.c index 688670553e..5bcaea930b 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -43,7 +43,7 @@ ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** -** $Id: vdbe.c,v 1.304 2004/05/19 14:56:57 drh Exp $ +** $Id: vdbe.c,v 1.305 2004/05/19 20:41:03 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -276,36 +276,6 @@ static void popStack(Mem **ppTos, int N){ *ppTos = pTos; } -/* -** Return TRUE if zNum is a 32-bit signed integer and write -** the value of the integer into *pNum. If zNum is not an integer -** or is an integer that is too large to be expressed with just 32 -** bits, then return false. -** -** Under Linux (RedHat 7.2) this routine is much faster than atoi() -** for converting strings into integers. -*/ -static int toInt(const char *zNum, i64 *pNum){ - i64 v = 0; - int neg; - int i, c; - if( *zNum=='-' ){ - neg = 1; - zNum++; - }else if( *zNum=='+' ){ - neg = 0; - zNum++; - }else{ - neg = 0; - } - for(i=0; (c=zNum[i])>='0' && c<='9'; i++){ - v = v*10 + c - '0'; - } - *pNum = neg ? -v : v; - return c==0 && i>0 && - (i<10 || (i==19 && memcmp(zNum,"9223372036854775807",19)<=0)); -} - /* ** Convert the given stack entity into a integer if it isn't one ** already. @@ -319,7 +289,7 @@ static void hardIntegerify(Mem *pStack){ pStack->i = (int)pStack->r; Release(pStack); }else if( pStack->flags & MEM_Str ){ - toInt(pStack->z, &pStack->i); + sqlite3atoi64(pStack->z, &pStack->i); Release(pStack); }else{ pStack->i = 0; @@ -792,6 +762,7 @@ case OP_Halt: { ** ** The integer value P1 is pushed onto the stack. If P3 is not zero ** then it is assumed to be a string representation of the same integer. +** If P1 is zero and P3 is not zero, then the value is derived from P3. */ case OP_Integer: { pTos++; @@ -801,6 +772,9 @@ case OP_Integer: { pTos->z = pOp->p3; pTos->flags |= MEM_Str | MEM_Static; pTos->n = strlen(pOp->p3)+1; + if( pTos->i==0 ){ + sqlite3GetInt64(pTos->z, &pTos->i); + } } break; } @@ -1417,7 +1391,7 @@ case OP_MustBeInt: { pTos->i = i; }else if( pTos->flags & MEM_Str ){ i64 v; - if( !toInt(pTos->z, &v) ){ + if( !sqlite3atoi64(pTos->z, &v) ){ double r; if( !sqlite3IsNumber(pTos->z, 0) ){ goto mismatch; @@ -3334,9 +3308,11 @@ case OP_SetCounts: { */ case OP_KeyAsData: { int i = pOp->p1; + Cursor *pC; assert( i>=0 && inCursor ); - p->apCsr[i]->keyAsData = pOp->p2; - sqlite3BtreeSetCompare(p->apCsr[i]->pCursor, sqlite3VdbeRowCompare, p->apCsr[i]); + pC = p->apCsr[i]; + pC->keyAsData = pOp->p2; + sqlite3BtreeSetCompare(pC->pCursor, sqlite3VdbeRowCompare, pC); break; } @@ -4035,7 +4011,7 @@ case OP_IntegrityCk: { if( aRoot==0 ) goto no_mem; for(j=0, i=sqliteHashFirst(&pSet->hash); i; i=sqliteHashNext(i), j++){ i64 root64; - toInt((char*)sqliteHashKey(i), &root64); + sqlite3atoi64((char*)sqliteHashKey(i), &root64); aRoot[j] = root64; } aRoot[j] = 0; diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 9c4f702355..a8f04a5e94 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -1387,13 +1387,13 @@ int sqlite3MemCompare(Mem *pMem1, Mem *pMem2){ ** if both values are integers. */ if( combined_flags&(MEM_Int|MEM_Real) ){ + i64 diff; if( !(pMem1->flags&(MEM_Int|MEM_Real)) ){ return 1; } if( !(pMem2->flags&(MEM_Int|MEM_Real)) ){ return -1; } - if( combined_flags&MEM_Real ){ if( pMem1->flags&MEM_Int ){ pMem1->r = pMem1->i; @@ -1405,8 +1405,8 @@ int sqlite3MemCompare(Mem *pMem1, Mem *pMem2){ if( pMem1->r > pMem2->r ) return 1; return 0; } - - return (pMem1->i - pMem2->i); + diff = pMem1->i - pMem2->i; + return diff<0 ? -1 : diff==0 ? 0 : +1; } rc = (pMem2->flags&MEM_Null) - (pMem1->flags&MEM_Null); @@ -1667,12 +1667,6 @@ int sqlite3VdbeIdxKeyCompare( len = nCellKey-2; while( pCellKey[len] && --len ); -#if 0 - if( ignorerowid ){ - nKey--; - while( pKey[nKey] && --nKey ); - } -#endif *res = sqlite3VdbeKeyCompare(pC, len, pCellKey, nKey, pKey); if( freeCellKey ){ diff --git a/src/where.c b/src/where.c index cc8ac97dde..af4fa53a90 100644 --- a/src/where.c +++ b/src/where.c @@ -12,7 +12,7 @@ ** This module contains C code that generates VDBE code used to process ** the WHERE clause of SQL statements. ** -** $Id: where.c,v 1.98 2004/05/19 14:56:57 drh Exp $ +** $Id: where.c,v 1.99 2004/05/19 20:41:04 drh Exp $ */ #include "sqliteInt.h" @@ -746,7 +746,6 @@ WhereInfo *sqlite3WhereBegin( ** refer to the index use the "==" or "IN" operators. */ int start; - int testOp; int nColumn = (pLevel->score+4)/8; brk = pLevel->brk = sqlite3VdbeMakeLabel(v); @@ -824,11 +823,7 @@ WhereInfo *sqlite3WhereBegin( /* Scan in the forward order */ sqlite3VdbeAddOp(v, OP_MoveGe, pLevel->iCur, brk); start = sqlite3VdbeAddOp(v, OP_MemLoad, pLevel->iMem, 0); - if( nColumn==pIdx->nColumn || 0 ){ - sqlite3VdbeAddOp(v, OP_IdxGT, pLevel->iCur, brk); - }else{ - sqlite3VdbeOp3(v, OP_IdxGE, pLevel->iCur, brk, "+", P3_STATIC); - } + sqlite3VdbeOp3(v, OP_IdxGE, pLevel->iCur, brk, "+", P3_STATIC); pLevel->op = OP_Next; } sqlite3VdbeAddOp(v, OP_RowKey, pLevel->iCur, 0); diff --git a/test/misc1.test b/test/misc1.test index 4ddea47b79..81c17d8a3c 100644 --- a/test/misc1.test +++ b/test/misc1.test @@ -13,7 +13,7 @@ # This file implements tests for miscellanous features that were # left out of other test files. # -# $Id: misc1.test,v 1.23 2003/08/05 13:13:39 drh Exp $ +# $Id: misc1.test,v 1.24 2004/05/19 20:41:04 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -252,18 +252,17 @@ execsql { DROP TABLE t4; } -# If an integer is too big to be represented as a 32-bit machine integer, -# then treat it as a string. +# 64-bit integers are represented exactly. # do_test misc1-9.1 { catchsql { CREATE TABLE t1(a unique not null, b unique not null); - INSERT INTO t1 VALUES('a',12345678901234567890); - INSERT INTO t1 VALUES('b',12345678911234567890); - INSERT INTO t1 VALUES('c',12345678921234567890); + INSERT INTO t1 VALUES('a',1234567890123456789); + INSERT INTO t1 VALUES('b',1234567891123456789); + INSERT INTO t1 VALUES('c',1234567892123456789); SELECT * FROM t1; } -} {0 {a 12345678901234567890 b 12345678911234567890 c 12345678921234567890}} +} {0 {a 1234567890123456789 b 1234567891123456789 c 1234567892123456789}} # A WHERE clause is not allowed to contain more than 99 terms. Check to # make sure this limit is enforced. @@ -330,7 +329,7 @@ do_test misc1-11.2 { # do_test misc1-12.1 { execsql {SELECT '0'=='0.0'} -} {0} +} {1} do_test misc1-12.2 { execsql {SELECT '0'==0.0} } {1} @@ -395,17 +394,17 @@ do_test misc1-12.11 { INSERT INTO t8 VALUES(0.0,0.0,4); SELECT DISTINCT x, y FROM t8 ORDER BY z; } -} {0 0 0 0.0} +} {0 0 0.0 0} do_test misc1-12.12 { execsql { SELECT min(z), max(z), count(z) FROM t8 GROUP BY x ORDER BY 1; } -} {1 4 4} +} {1 3 2 2 4 2} do_test misc1-12.13 { execsql { SELECT min(z), max(z), count(z) FROM t8 GROUP BY y ORDER BY 1; } -} {1 2 2 3 4 2} +} {1 4 4} # There was a problem with realloc() in the OP_MemStore operation of # the VDBE. A buffer was being reallocated but some pointers into diff --git a/test/quick.test b/test/quick.test index 5295291513..59ead0689a 100644 --- a/test/quick.test +++ b/test/quick.test @@ -10,7 +10,7 @@ #*********************************************************************** # This file runs all tests. # -# $Id: quick.test,v 1.13 2004/05/19 13:13:08 drh Exp $ +# $Id: quick.test,v 1.14 2004/05/19 20:41:04 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -43,7 +43,6 @@ lappend EXCLUDE version.test ;# uses the btree_meta API (not updated) # Some tests fail in these file as a result of the partial manifest types # implementation. -lappend EXCLUDE misc1.test lappend EXCLUDE capi2.test