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

Merge the fix for determining truth of floating point values from trunk.

FossilOrigin-Name: 003dc140536d0dd4384252ae1b82827b5d8b2b399520f99549b9266a482009fb
This commit is contained in:
drh
2018-02-26 15:31:39 +00:00
6 changed files with 56 additions and 41 deletions

View File

@@ -2172,18 +2172,8 @@ case OP_Or: { /* same as TK_OR, in1, in2, out3 */
int v1; /* Left operand: 0==FALSE, 1==TRUE, 2==UNKNOWN or NULL */
int v2; /* Right operand: 0==FALSE, 1==TRUE, 2==UNKNOWN or NULL */
pIn1 = &aMem[pOp->p1];
if( pIn1->flags & MEM_Null ){
v1 = 2;
}else{
v1 = sqlite3VdbeIntValue(pIn1)!=0;
}
pIn2 = &aMem[pOp->p2];
if( pIn2->flags & MEM_Null ){
v2 = 2;
}else{
v2 = sqlite3VdbeIntValue(pIn2)!=0;
}
v1 = sqlite3VdbeBooleanValue(&aMem[pOp->p1], 2);
v2 = sqlite3VdbeBooleanValue(&aMem[pOp->p2], 2);
if( pOp->opcode==OP_And ){
static const unsigned char and_logic[] = { 0, 0, 0, 0, 1, 2, 0, 2, 2 };
v1 = and_logic[v1*3+v2];
@@ -2212,7 +2202,7 @@ case OP_Not: { /* same as TK_NOT, in1, out2 */
pIn1 = &aMem[pOp->p1];
pOut = &aMem[pOp->p2];
if( (pIn1->flags & MEM_Null)==0 ){
sqlite3VdbeMemSetInt64(pOut, !sqlite3VdbeIntValue(pIn1));
sqlite3VdbeMemSetInt64(pOut, !sqlite3VdbeBooleanValue(pIn1,0));
}else{
sqlite3VdbeMemSetNull(pOut);
}
@@ -2281,30 +2271,25 @@ case OP_Once: { /* jump */
** is considered true if it is numeric and non-zero. If the value
** in P1 is NULL then take the jump if and only if P3 is non-zero.
*/
case OP_If: { /* jump, in1 */
int c;
c = sqlite3VdbeBooleanValue(&aMem[pOp->p1], pOp->p3);
VdbeBranchTaken(c!=0, 2);
if( c ) goto jump_to_p2;
break;
}
/* Opcode: IfNot P1 P2 P3 * *
**
** Jump to P2 if the value in register P1 is False. The value
** is considered false if it has a numeric value of zero. If the value
** in P1 is NULL then take the jump if and only if P3 is non-zero.
*/
case OP_If: /* jump, in1 */
case OP_IfNot: { /* jump, in1 */
int c;
pIn1 = &aMem[pOp->p1];
if( pIn1->flags & MEM_Null ){
c = pOp->p3;
}else{
if( pIn1->flags & MEM_Int ){
c = pIn1->u.i!=0;
}else{
c = sqlite3VdbeRealValue(pIn1)!=0.0;
}
if( pOp->opcode==OP_IfNot ) c = !c;
}
c = !sqlite3VdbeBooleanValue(&aMem[pOp->p1], !pOp->p3);
VdbeBranchTaken(c!=0, 2);
if( c ){
goto jump_to_p2;
}
if( c ) goto jump_to_p2;
break;
}