mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Always interpret non-zero floating-point values as true even if their
integer part is zero. Fix for ticket [36fae083b450e3af857a459e20]. FossilOrigin-Name: a983fa857048c748112c2f805f13aadeae43b43b3d27fa55433a3699b51c9a0e
This commit is contained in:
41
src/vdbe.c
41
src/vdbe.c
@@ -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];
|
||||
@@ -2214,7 +2204,7 @@ case OP_Not: { /* same as TK_NOT, in1, out2 */
|
||||
sqlite3VdbeMemSetNull(pOut);
|
||||
if( (pIn1->flags & MEM_Null)==0 ){
|
||||
pOut->flags = MEM_Int;
|
||||
pOut->u.i = !sqlite3VdbeIntValue(pIn1);
|
||||
pOut->u.i = !sqlite3VdbeBooleanValue(pIn1, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user