diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/btree.c | 2 | ||||
-rw-r--r-- | src/select.c | 2 | ||||
-rw-r--r-- | src/test5.c | 1 | ||||
-rw-r--r-- | src/test_func.c | 2 | ||||
-rw-r--r-- | src/vdbe.c | 6 | ||||
-rw-r--r-- | src/vdbeInt.h | 4 | ||||
-rw-r--r-- | src/vdbeapi.c | 20 | ||||
-rw-r--r-- | src/vdbeaux.c | 13 | ||||
-rw-r--r-- | src/vdbemem.c | 20 |
9 files changed, 19 insertions, 51 deletions
diff --git a/src/btree.c b/src/btree.c index ce35afbd5..eebf6f1e8 100644 --- a/src/btree.c +++ b/src/btree.c @@ -4611,7 +4611,7 @@ int sqlite3BtreeMovetoUnpacked( assert( biasRight==0 || biasRight==1 ); idx = upr>>(1-biasRight); /* idx = biasRight ? upr : (lwr+upr)/2; */ pCur->aiIdx[pCur->iPage] = (u16)idx; - if( pPage->intKey ){ + if( xRecordCompare==0 ){ for(;;){ i64 nCellKey; pCell = findCell(pPage, idx) + pPage->childPtrSize; diff --git a/src/select.c b/src/select.c index 9430888c4..850bc6a90 100644 --- a/src/select.c +++ b/src/select.c @@ -1522,7 +1522,7 @@ static int selectColumnsFromExprList( char *zNewName; int k; for(k=nName-1; k>1 && sqlite3Isdigit(zName[k]); k--){} - if( zName[k]==':' ) nName = k; + if( k>=0 && zName[k]==':' ) nName = k; zName[nName] = 0; zNewName = sqlite3MPrintf(db, "%s:%d", zName, ++cnt); sqlite3DbFree(db, zName); diff --git a/src/test5.c b/src/test5.c index bf574e3c3..952e3325e 100644 --- a/src/test5.c +++ b/src/test5.c @@ -76,7 +76,6 @@ static int test_value_overhead( val.flags = MEM_Str|MEM_Term|MEM_Static; val.z = "hello world"; - val.memType = MEM_Str; val.enc = SQLITE_UTF8; for(i=0; i<repeat_count; i++){ diff --git a/src/test_func.c b/src/test_func.c index b250e3310..9cf2f8002 100644 --- a/src/test_func.c +++ b/src/test_func.c @@ -499,7 +499,6 @@ static void test_extract( mem.enc = ENC(db); pHdr += sqlite3GetVarint(pHdr, &iSerialType); pBody += sqlite3VdbeSerialGet(pBody, (u32)iSerialType, &mem); - sqlite3VdbeMemStoreType(&mem); if( iCurrent==iIdx ){ sqlite3_result_value(context, &mem); @@ -549,7 +548,6 @@ static void test_decode( pHdr += sqlite3GetVarint(pHdr, &iSerialType); pBody += sqlite3VdbeSerialGet(pBody, (u32)iSerialType, &mem); - sqlite3VdbeMemStoreType(&mem); switch( sqlite3_value_type(&mem) ){ case SQLITE_TEXT: pVal = Tcl_NewStringObj((const char*)sqlite3_value_text(&mem), -1); diff --git a/src/vdbe.c b/src/vdbe.c index 16ec099b5..f5a3e1afb 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -303,7 +303,6 @@ int sqlite3_value_numeric_type(sqlite3_value *pVal){ if( eType==SQLITE_TEXT ){ Mem *pMem = (Mem*)pVal; applyNumericAffinity(pMem); - sqlite3VdbeMemStoreType(pMem); eType = sqlite3_value_type(pVal); } return eType; @@ -1253,7 +1252,6 @@ case OP_ResultRow: { assert( (pMem[i].flags & MEM_Ephem)==0 || (pMem[i].flags & (MEM_Str|MEM_Blob))==0 ); sqlite3VdbeMemNulTerminate(&pMem[i]); - sqlite3VdbeMemStoreType(&pMem[i]); REGISTER_TRACE(pOp->p1+i, &pMem[i]); } if( db->mallocFailed ) goto no_mem; @@ -1499,7 +1497,6 @@ case OP_Function: { assert( memIsValid(pArg) ); apVal[i] = pArg; Deephemeralize(pArg); - sqlite3VdbeMemStoreType(pArg); REGISTER_TRACE(pOp->p2+i, pArg); } @@ -5555,7 +5552,6 @@ case OP_AggStep: { assert( memIsValid(pRec) ); apVal[i] = pRec; memAboutToChange(p, pRec); - sqlite3VdbeMemStoreType(pRec); } ctx.pFunc = pOp->p4.pFunc; assert( pOp->p3>0 && pOp->p3<=(p->nMem-p->nCursor) ); @@ -5989,7 +5985,6 @@ case OP_VFilter: { /* jump */ apArg = p->apArg; for(i = 0; i<nArg; i++){ apArg[i] = &pArgc[i+1]; - sqlite3VdbeMemStoreType(apArg[i]); } p->inVtabMethod = 1; @@ -6196,7 +6191,6 @@ case OP_VUpdate: { for(i=0; i<nArg; i++){ assert( memIsValid(pX) ); memAboutToChange(p, pX); - sqlite3VdbeMemStoreType(pX); apArg[i] = pX; pX++; } diff --git a/src/vdbeInt.h b/src/vdbeInt.h index bc2650126..911e34bad 100644 --- a/src/vdbeInt.h +++ b/src/vdbeInt.h @@ -168,7 +168,6 @@ struct Mem { } u; int n; /* Number of characters in string value, excluding '\0' */ u16 flags; /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */ - u8 memType; /* Lower 5 bits of flags */ u8 enc; /* SQLITE_UTF8, SQLITE_UTF16BE, SQLITE_UTF16LE */ #ifdef SQLITE_DEBUG Mem *pScopyFrom; /* This Mem is a shallow copy of pScopyFrom */ @@ -195,6 +194,7 @@ struct Mem { #define MEM_Int 0x0004 /* Value is an integer */ #define MEM_Real 0x0008 /* Value is a real number */ #define MEM_Blob 0x0010 /* Value is a BLOB */ +#define MEM_AffMask 0x001f /* Mask of affinity bits */ #define MEM_RowSet 0x0020 /* Value is a RowSet object */ #define MEM_Frame 0x0040 /* Value is a VdbeFrame object */ #define MEM_Undefined 0x0080 /* Value is undefined */ @@ -453,8 +453,6 @@ int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve); int sqlite3VdbeCloseStatement(Vdbe *, int); void sqlite3VdbeFrameDelete(VdbeFrame*); int sqlite3VdbeFrameRestore(VdbeFrame *); -#define sqlite3VdbeMemStoreType(X) (X)->memType = (u8)((X)->flags&0x1f) -/* void sqlite3VdbeMemStoreType(Mem *pMem); */ void sqlite3VdbePreUpdateHook( Vdbe *, VdbeCursor *, int, const char*, Table *, i64, int); int sqlite3VdbeTransferError(Vdbe *p); diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 7f9862156..d32df40ae 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -135,7 +135,6 @@ const void *sqlite3_value_blob(sqlite3_value *pVal){ Mem *p = (Mem*)pVal; if( p->flags & (MEM_Blob|MEM_Str) ){ sqlite3VdbeMemExpandBlob(p); - p->flags &= ~MEM_Str; p->flags |= MEM_Blob; return p->n ? p->z : 0; }else{ @@ -206,7 +205,7 @@ int sqlite3_value_type(sqlite3_value* pVal){ SQLITE_INTEGER, /* 0x1e */ SQLITE_NULL, /* 0x1f */ }; - return aType[pVal->memType&0x1f]; + return aType[pVal->flags&MEM_AffMask]; } /**************************** sqlite3_result_ ******************************* @@ -732,19 +731,23 @@ int sqlite3_data_count(sqlite3_stmt *pStmt){ */ static const Mem *columnNullValue(void){ /* Even though the Mem structure contains an element - ** of type i64, on certain architecture (x86) with certain compiler + ** of type i64, on certain architectures (x86) with certain compiler ** switches (-Os), gcc may align this Mem object on a 4-byte boundary ** instead of an 8-byte one. This all works fine, except that when ** running with SQLITE_DEBUG defined the SQLite code sometimes assert()s ** that a Mem structure is located on an 8-byte boundary. To prevent - ** this assert() from failing, when building with SQLITE_DEBUG defined - ** using gcc, force nullMem to be 8-byte aligned using the magical + ** these assert()s from failing, when building with SQLITE_DEBUG defined + ** using gcc, we force nullMem to be 8-byte aligned using the magical ** __attribute__((aligned(8))) macro. */ static const Mem nullMem #if defined(SQLITE_DEBUG) && defined(__GNUC__) - __attribute__((aligned(8))) + __attribute__((aligned(8))) #endif - = {0, "", (double)0, {0}, 0, MEM_Null, SQLITE_NULL, 0, 0, 0 }; + = {0, "", (double)0, {0}, 0, MEM_Null, 0, +#ifdef SQLITE_DEBUG + 0, 0, /* pScopyFrom, pFiller */ +#endif + 0, 0 }; return &nullMem; } @@ -1420,7 +1423,6 @@ int sqlite3_preupdate_old(sqlite3 *db, int iIdx, sqlite3_value **ppValue){ if( iIdx==p->iPKey ){ sqlite3VdbeMemSetInt64(*ppValue, p->iKey1); } - sqlite3VdbeMemStoreType(*ppValue); } preupdate_old_out: @@ -1499,7 +1501,6 @@ int sqlite3_preupdate_new(sqlite3 *db, int iIdx, sqlite3_value **ppValue){ if( iIdx==p->iPKey ){ sqlite3VdbeMemSetInt64(pMem, p->iKey2); } - sqlite3VdbeMemStoreType(pMem); } }else{ /* For an UPDATE, memory cell (p->iNewReg+1+iIdx) contains the required @@ -1524,7 +1525,6 @@ int sqlite3_preupdate_new(sqlite3 *db, int iIdx, sqlite3_value **ppValue){ rc = sqlite3VdbeMemCopy(pMem, &p->v->aMem[p->iNewReg+1+iIdx]); if( rc!=SQLITE_OK ) goto preupdate_new_out; } - sqlite3VdbeMemStoreType(pMem); } } *ppValue = pMem; diff --git a/src/vdbeaux.c b/src/vdbeaux.c index d93388199..d13dbaadd 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -1364,7 +1364,6 @@ int sqlite3VdbeList( } if( p->explain==1 ){ pMem->flags = MEM_Int; - pMem->memType = MEM_Int; pMem->u.i = i; /* Program counter */ pMem++; @@ -1372,7 +1371,6 @@ int sqlite3VdbeList( pMem->z = (char*)sqlite3OpcodeName(pOp->opcode); /* Opcode */ assert( pMem->z!=0 ); pMem->n = sqlite3Strlen30(pMem->z); - pMem->memType = MEM_Str; pMem->enc = SQLITE_UTF8; pMem++; @@ -1398,17 +1396,14 @@ int sqlite3VdbeList( pMem->flags = MEM_Int; pMem->u.i = pOp->p1; /* P1 */ - pMem->memType = MEM_Int; pMem++; pMem->flags = MEM_Int; pMem->u.i = pOp->p2; /* P2 */ - pMem->memType = MEM_Int; pMem++; pMem->flags = MEM_Int; pMem->u.i = pOp->p3; /* P3 */ - pMem->memType = MEM_Int; pMem++; if( sqlite3VdbeMemGrow(pMem, 32, 0) ){ /* P4 */ @@ -1424,7 +1419,6 @@ int sqlite3VdbeList( pMem->n = sqlite3Strlen30(pMem->z); pMem->enc = SQLITE_UTF8; } - pMem->memType = MEM_Str; pMem++; if( p->explain==1 ){ @@ -1435,7 +1429,6 @@ int sqlite3VdbeList( pMem->flags = MEM_Str|MEM_Term; pMem->n = 2; sqlite3_snprintf(3, pMem->z, "%.2x", pOp->p5); /* P5 */ - pMem->memType = MEM_Str; pMem->enc = SQLITE_UTF8; pMem++; @@ -1446,11 +1439,9 @@ int sqlite3VdbeList( } pMem->flags = MEM_Str|MEM_Term; pMem->n = displayComment(pOp, zP4, pMem->z, 500); - pMem->memType = MEM_Str; pMem->enc = SQLITE_UTF8; #else pMem->flags = MEM_Null; /* Comment */ - pMem->memType = MEM_Null; #endif } @@ -3541,9 +3532,10 @@ int sqlite3VdbeRecordCompare( if( pKeyInfo->aSortOrder[i] ){ rc = -rc; } - assert( CORRUPT_DB + assert( CORRUPT_DB || (rc<0 && vdbeRecordCompareDebug(nKey1, pKey1, pPKey2)<0) || (rc>0 && vdbeRecordCompareDebug(nKey1, pKey1, pPKey2)>0) + || pKeyInfo->db->mallocFailed ); assert( mem1.zMalloc==0 ); /* See comment below */ return rc; @@ -3938,7 +3930,6 @@ sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe *v, int iVar, u8 aff){ if( pRet ){ sqlite3VdbeMemCopy((Mem *)pRet, pMem); sqlite3ValueApplyAffinity(pRet, aff, SQLITE_UTF8); - sqlite3VdbeMemStoreType((Mem *)pRet); } return pRet; } diff --git a/src/vdbemem.c b/src/vdbemem.c index 378de2deb..2c4aa4ad7 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -122,6 +122,7 @@ int sqlite3VdbeMemGrow(Mem *pMem, int n, int bPreserve){ } if( pMem->zMalloc==0 ){ VdbeMemRelease(pMem); + pMem->z = 0; pMem->flags = MEM_Null; return SQLITE_NOMEM; } @@ -320,7 +321,7 @@ void sqlite3VdbeMemReleaseExternal(Mem *p){ /* ** Release any memory held by the Mem. This may leave the Mem in an ** inconsistent state, for example with (Mem.z==0) and -** (Mem.memType==MEM_Str). +** (Mem.flags==MEM_Str). */ void sqlite3VdbeMemRelease(Mem *p){ assert( sqlite3VdbeCheckMemInvariants(p) ); @@ -512,7 +513,6 @@ void sqlite3VdbeMemSetNull(Mem *pMem){ sqlite3RowSetClear(pMem->u.pRowSet); } MemSetTypeFlag(pMem, MEM_Null); - pMem->memType = MEM_Null; } void sqlite3ValueSetNull(sqlite3_value *p){ sqlite3VdbeMemSetNull((Mem*)p); @@ -525,7 +525,6 @@ void sqlite3ValueSetNull(sqlite3_value *p){ void sqlite3VdbeMemSetZeroBlob(Mem *pMem, int n){ sqlite3VdbeMemRelease(pMem); pMem->flags = MEM_Blob|MEM_Zero; - pMem->memType = MEM_Blob; pMem->n = 0; if( n<0 ) n = 0; pMem->u.nZero = n; @@ -548,7 +547,6 @@ void sqlite3VdbeMemSetInt64(Mem *pMem, i64 val){ sqlite3VdbeMemRelease(pMem); pMem->u.i = val; pMem->flags = MEM_Int; - pMem->memType = MEM_Int; } #ifndef SQLITE_OMIT_FLOATING_POINT @@ -563,7 +561,6 @@ void sqlite3VdbeMemSetDouble(Mem *pMem, double val){ sqlite3VdbeMemRelease(pMem); pMem->r = val; pMem->flags = MEM_Real; - pMem->memType = MEM_Real; } } #endif @@ -772,7 +769,6 @@ int sqlite3VdbeMemSetStr( pMem->n = nByte; pMem->flags = flags; pMem->enc = (enc==0 ? SQLITE_UTF8 : enc); - pMem->memType = flags&0x1f; #ifndef SQLITE_OMIT_UTF16 if( pMem->enc!=SQLITE_UTF8 && sqlite3VdbeMemHandleBom(pMem) ){ @@ -838,7 +834,6 @@ int sqlite3VdbeMemFromBtree( pMem->z[amt] = 0; pMem->z[amt+1] = 0; pMem->flags = MEM_Blob|MEM_Term; - pMem->memType = MEM_Blob; pMem->n = (int)amt; }else{ sqlite3VdbeMemRelease(pMem); @@ -901,7 +896,6 @@ sqlite3_value *sqlite3ValueNew(sqlite3 *db){ Mem *p = sqlite3DbMallocZero(db, sizeof(*p)); if( p ){ p->flags = MEM_Null; - p->memType = MEM_Null; p->db = db; } return p; @@ -950,7 +944,6 @@ static sqlite3_value *valueNew(sqlite3 *db, struct ValueNewStat4Ctx *p){ pRec->aMem = (Mem *)((u8*)pRec + ROUND8(sizeof(UnpackedRecord))); for(i=0; i<nCol; i++){ pRec->aMem[i].flags = MEM_Null; - pRec->aMem[i].memType = MEM_Null; pRec->aMem[i].db = db; } }else{ @@ -1023,7 +1016,6 @@ static int valueFromExpr( zVal = sqlite3MPrintf(db, "%s%s", zNeg, pExpr->u.zToken); if( zVal==0 ) goto no_mem; sqlite3ValueSetStr(pVal, -1, zVal, SQLITE_UTF8, SQLITE_DYNAMIC); - if( op==TK_FLOAT ) pVal->memType = MEM_Real; } if( (op==TK_INTEGER || op==TK_FLOAT ) && affinity==SQLITE_AFF_NONE ){ sqlite3ValueApplyAffinity(pVal, SQLITE_AFF_NUMERIC, SQLITE_UTF8); @@ -1041,9 +1033,9 @@ static int valueFromExpr( ){ sqlite3VdbeMemNumerify(pVal); if( pVal->u.i==SMALLEST_INT64 ){ - pVal->flags &= MEM_Int; + pVal->flags &= ~MEM_Int; pVal->flags |= MEM_Real; - pVal->r = (double)LARGEST_INT64; + pVal->r = (double)SMALLEST_INT64; }else{ pVal->u.i = -pVal->u.i; } @@ -1069,9 +1061,6 @@ static int valueFromExpr( } #endif - if( pVal ){ - sqlite3VdbeMemStoreType(pVal); - } *ppVal = pVal; return rc; @@ -1235,7 +1224,6 @@ int sqlite3Stat4ProbeSetValue( sqlite3ValueApplyAffinity(pVal, affinity, ENC(db)); } pVal->db = pParse->db; - sqlite3VdbeMemStoreType((Mem*)pVal); } } }else{ |