Always convert IEEE NaN into NULL. Ticket #3060. Add test cases to verify

that this is happening. (CVS 5066)

FossilOrigin-Name: 9b07e59e510e2de39c2081653662fbc654ca6fbb
This commit is contained in:
drh
2008-04-29 00:15:20 +00:00
parent 7d133d8889
commit 2eaf93d34f
6 changed files with 116 additions and 16 deletions
+8 -4
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.369 2008/04/25 00:08:38 drh Exp $
** $Id: expr.c,v 1.370 2008/04/29 00:15:21 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -1938,9 +1938,13 @@ static void codeReal(Vdbe *v, const char *z, int n, int negateFlag, int iMem){
char *zV;
assert( !isdigit(z[n]) );
sqlite3AtoF(z, &value);
if( negateFlag ) value = -value;
zV = dup8bytes(v, (char*)&value);
sqlite3VdbeAddOp4(v, OP_Real, 0, iMem, 0, zV, P4_REAL);
if( sqlite3IsNaN(value) ){
sqlite3VdbeAddOp2(v, OP_Null, 0, iMem);
}else{
if( negateFlag ) value = -value;
zV = dup8bytes(v, (char*)&value);
sqlite3VdbeAddOp4(v, OP_Real, 0, iMem, 0, zV, P4_REAL);
}
}
}
+2 -1
View File
@@ -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.736 2008/04/28 16:55:26 drh Exp $
** $Id: vdbe.c,v 1.737 2008/04/29 00:15:21 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -842,6 +842,7 @@ case OP_Int64: { /* out2-prerelease */
*/
case OP_Real: { /* same as TK_FLOAT, out2-prerelease */
pOut->flags = MEM_Real;
assert( !sqlite3IsNaN(*pOp->p4.pReal) );
pOut->r = *pOp->p4.pReal;
break;
}
+2 -2
View File
@@ -14,7 +14,7 @@
** to version 2.8.7, all this code was combined into the vdbe.c source file.
** But that file was getting too big so this subroutines were split out.
**
** $Id: vdbeaux.c,v 1.380 2008/04/27 18:40:12 drh Exp $
** $Id: vdbeaux.c,v 1.381 2008/04/29 00:15:21 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -2133,7 +2133,7 @@ int sqlite3VdbeSerialGet(
assert( sizeof(x)==8 && sizeof(pMem->r)==8 );
swapMixedEndianFloat(x);
memcpy(&pMem->r, &x, sizeof(x));
pMem->flags = MEM_Real;
pMem->flags = sqlite3IsNaN(pMem->r) ? MEM_Null : MEM_Real;
}
return 8;
}