mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Fix the OP_Affinity operator so that when applying REAL affinity, it
only sets MEM_IntReal if the integer value will fit in 6 bytes or less. Fix for ticket [ba2f4585cf495231] FossilOrigin-Name: 2b221bb15fd2b9f6a426e5eb439f7dbabbe3c4cab010c49b87dae3bb1f16c081
This commit is contained in:
20
src/vdbe.c
20
src/vdbe.c
@@ -2817,10 +2817,22 @@ case OP_Affinity: {
|
||||
assert( memIsValid(pIn1) );
|
||||
applyAffinity(pIn1, zAffinity[0], encoding);
|
||||
if( zAffinity[0]==SQLITE_AFF_REAL && (pIn1->flags & MEM_Int)!=0 ){
|
||||
/* When applying REAL affinity, if the result is still MEM_Int,
|
||||
** indicate that REAL is actually desired */
|
||||
pIn1->flags |= MEM_IntReal;
|
||||
pIn1->flags &= ~MEM_Int;
|
||||
/* When applying REAL affinity, if the result is still an MEM_Int
|
||||
** that will fit in 6 bytes, then change the type to MEM_IntReal
|
||||
** so that we keep the high-resolution integer value but know that
|
||||
** the type really wants to be REAL. */
|
||||
testcase( pIn1->u.i==140737488355328LL );
|
||||
testcase( pIn1->u.i==140737488355327LL );
|
||||
testcase( pIn1->u.i==-140737488355328LL );
|
||||
testcase( pIn1->u.i==-140737488355329LL );
|
||||
if( pIn1->u.i<=140737488355327LL && pIn1->u.i>=-140737488355328LL ){
|
||||
pIn1->flags |= MEM_IntReal;
|
||||
pIn1->flags &= ~MEM_Int;
|
||||
}else{
|
||||
pIn1->u.r = (double)pIn1->u.i;
|
||||
pIn1->flags |= MEM_Real;
|
||||
pIn1->flags &= ~MEM_Int;
|
||||
}
|
||||
}
|
||||
REGISTER_TRACE((int)(pIn1-aMem), pIn1);
|
||||
zAffinity++;
|
||||
|
Reference in New Issue
Block a user