1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Tighten the conditions under which applyNumericAffinity() be called and add

assert() statements to prove that it is never called otherwise.

FossilOrigin-Name: e996ca32cb643c558b616c0dd872f3351b6aa3ef
This commit is contained in:
drh
2014-09-19 22:01:54 +00:00
parent 4583c37ca0
commit 11a6eee8e1
3 changed files with 10 additions and 11 deletions

View File

@@ -242,8 +242,7 @@ static void applyNumericAffinity(Mem *pRec, int bTryForInt){
double rValue;
i64 iValue;
u8 enc = pRec->enc;
if( (pRec->flags&MEM_Str)==0 ) return;
if( (pRec->flags&(MEM_Int|MEM_Real))!=0 ) return;
assert( (pRec->flags & (MEM_Str|MEM_Int|MEM_Real))==MEM_Str );
if( sqlite3AtoF(pRec->z, &rValue, pRec->n, enc)==0 ) return;
if( 0==sqlite3Atoi64(pRec->z, &iValue, pRec->n, enc) ){
pRec->u.i = iValue;
@@ -283,7 +282,7 @@ static void applyAffinity(
|| affinity==SQLITE_AFF_NUMERIC );
if( (pRec->flags & MEM_Int)==0 ){
if( (pRec->flags & MEM_Real)==0 ){
applyNumericAffinity(pRec,1);
if( pRec->flags & MEM_Str ) applyNumericAffinity(pRec,1);
}else{
sqlite3VdbeIntegerAffinity(pRec);
}
@@ -3558,7 +3557,7 @@ case OP_SeekGT: { /* jump, in3 */
** blob, or NULL. But it needs to be an integer before we can do
** the seek, so convert it. */
pIn3 = &aMem[pOp->p3];
if( (pIn3->flags & (MEM_Int|MEM_Real))==0 ){
if( (pIn3->flags & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){
applyNumericAffinity(pIn3, 0);
}
iKey = sqlite3VdbeIntValue(pIn3);