mirror of https://github.com/sqlite/sqlite
Convert the "~" and "NOT" operators to be two-address instructions.
Ticket #3541. (CVS 6028) FossilOrigin-Name: ea9b747efb22fd3f679c3ef86ed51986c5ad9436
This commit is contained in:
parent
01ecbeeb57
commit
e99fa2af71
17
manifest
17
manifest
|
@ -1,5 +1,5 @@
|
||||||
C Add\sthe\sexample\sfrom\s#3359\sto\sthe\stest\ssuite.\s(CVS\s6027)
|
C Convert\sthe\s"~"\sand\s"NOT"\soperators\sto\sbe\stwo-address\sinstructions.\nTicket\s#3541.\s(CVS\s6028)
|
||||||
D 2008-12-14T14:45:21
|
D 2008-12-15T15:27:52
|
||||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||||
F Makefile.in f7e4c81c347b04f7b0f1c1b081a168645d7b8af7
|
F Makefile.in f7e4c81c347b04f7b0f1c1b081a168645d7b8af7
|
||||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||||
|
@ -108,7 +108,7 @@ F src/callback.c bee8949d619b1b7b1e4dfac8a19c5116ae1dd12a
|
||||||
F src/complete.c cb14e06dbe79dee031031f0d9e686ff306afe07c
|
F src/complete.c cb14e06dbe79dee031031f0d9e686ff306afe07c
|
||||||
F src/date.c 3dbac3eac2848af416786b6e1e3150f7c740dac6
|
F src/date.c 3dbac3eac2848af416786b6e1e3150f7c740dac6
|
||||||
F src/delete.c e2392b6808496fc0a7f54662af3ba677a3e8e44a
|
F src/delete.c e2392b6808496fc0a7f54662af3ba677a3e8e44a
|
||||||
F src/expr.c f13ad5563470481eaa1e8016bfa9ed1b4c996574
|
F src/expr.c a385202af56d622b11d05e8d386def256155152b
|
||||||
F src/fault.c dc88c821842157460750d2d61a8a8b4197d047ff
|
F src/fault.c dc88c821842157460750d2d61a8a8b4197d047ff
|
||||||
F src/func.c b0e1c61301f33d67b72ab15d85c80ed76e7c98ac
|
F src/func.c b0e1c61301f33d67b72ab15d85c80ed76e7c98ac
|
||||||
F src/global.c 91723e45a2ad03ae5bb97a0a0d2dbb1a0e69527b
|
F src/global.c 91723e45a2ad03ae5bb97a0a0d2dbb1a0e69527b
|
||||||
|
@ -194,7 +194,7 @@ F src/update.c 080889d241e4dcd1c545c8051eb6de86f4939295
|
||||||
F src/utf.c 1da9c832dba0fa8f865b5b902d93f420a1ee4245
|
F src/utf.c 1da9c832dba0fa8f865b5b902d93f420a1ee4245
|
||||||
F src/util.c ea62608f66f33a7e8322de83024ae37c415c0c7f
|
F src/util.c ea62608f66f33a7e8322de83024ae37c415c0c7f
|
||||||
F src/vacuum.c 383d6297bddc011ab04a9eed110db6eaf523e8e9
|
F src/vacuum.c 383d6297bddc011ab04a9eed110db6eaf523e8e9
|
||||||
F src/vdbe.c ee98938f76a3d9e513aca9696391c6e19fa2cafe
|
F src/vdbe.c 3fd1fe6408598121213e19e1808e5de882c7b636
|
||||||
F src/vdbe.h 03516f28bf5aca00a53c4dccd6c313f96adb94f6
|
F src/vdbe.h 03516f28bf5aca00a53c4dccd6c313f96adb94f6
|
||||||
F src/vdbeInt.h e6e80a99ce634983b7cc2498843b4d2e5540900a
|
F src/vdbeInt.h e6e80a99ce634983b7cc2498843b4d2e5540900a
|
||||||
F src/vdbeapi.c 85c33cfbfa56249cbe627831610afafba754477d
|
F src/vdbeapi.c 85c33cfbfa56249cbe627831610afafba754477d
|
||||||
|
@ -592,6 +592,7 @@ F test/tkt3493.test 8472b3464e49a27ff7271308eec46154209e667b
|
||||||
F test/tkt3508.test d9e285ff91731247d4673f9252fe5934639d7f0d
|
F test/tkt3508.test d9e285ff91731247d4673f9252fe5934639d7f0d
|
||||||
F test/tkt3522.test 22ce2ebbcb04a6be56c0977d405c207967318fd6
|
F test/tkt3522.test 22ce2ebbcb04a6be56c0977d405c207967318fd6
|
||||||
F test/tkt3527.test ee4af96183579565987e58873a7490bc04934ffb
|
F test/tkt3527.test ee4af96183579565987e58873a7490bc04934ffb
|
||||||
|
F test/tkt3541.test 5dc257bde9bc833ab9cc6844bf170b998dbb950a
|
||||||
F test/tkt35xx.test 53bca895091e968126a858ee7da186f59f328994
|
F test/tkt35xx.test 53bca895091e968126a858ee7da186f59f328994
|
||||||
F test/tokenize.test ce430a7aed48fc98301611429595883fdfcab5d7
|
F test/tokenize.test ce430a7aed48fc98301611429595883fdfcab5d7
|
||||||
F test/trace.test 951cd0f5f571e7f36bf7bfe04be70f90fb16fb00
|
F test/trace.test 951cd0f5f571e7f36bf7bfe04be70f90fb16fb00
|
||||||
|
@ -672,7 +673,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
|
||||||
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||||
P adba0f3c01ba2407466d0120c411c398218bdaeb
|
P 84f8417c0794d3e5cec88f59ea71a7d557044409
|
||||||
R fad0d590913fe8f9e5e994000a8088be
|
R af3b4538f82d88370566c291a9daf4a7
|
||||||
U danielk1977
|
U drh
|
||||||
Z 4887ada2d24d472ddc8849201ce49da5
|
Z 98bd9dcbaef571a6a1bb6e3794861e9a
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
84f8417c0794d3e5cec88f59ea71a7d557044409
|
ea9b747efb22fd3f679c3ef86ed51986c5ad9436
|
11
src/expr.c
11
src/expr.c
|
@ -12,7 +12,7 @@
|
||||||
** This file contains routines used for analyzing expressions and
|
** This file contains routines used for analyzing expressions and
|
||||||
** for generating VDBE code that evaluates expressions in SQLite.
|
** for generating VDBE code that evaluates expressions in SQLite.
|
||||||
**
|
**
|
||||||
** $Id: expr.c,v 1.407 2008/12/10 21:19:57 drh Exp $
|
** $Id: expr.c,v 1.408 2008/12/15 15:27:52 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
@ -1975,11 +1975,10 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
|
||||||
assert( TK_NOT==OP_Not );
|
assert( TK_NOT==OP_Not );
|
||||||
testcase( op==TK_BITNOT );
|
testcase( op==TK_BITNOT );
|
||||||
testcase( op==TK_NOT );
|
testcase( op==TK_NOT );
|
||||||
inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);
|
r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
|
||||||
testcase( inReg==target );
|
testcase( regFree1==0 );
|
||||||
testcase( usedAsColumnCache(pParse, inReg, inReg) );
|
inReg = target;
|
||||||
inReg = sqlite3ExprWritableRegister(pParse, inReg, target);
|
sqlite3VdbeAddOp2(v, op, r1, inReg);
|
||||||
sqlite3VdbeAddOp1(v, op, inReg);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TK_ISNULL:
|
case TK_ISNULL:
|
||||||
|
|
38
src/vdbe.c
38
src/vdbe.c
|
@ -43,7 +43,7 @@
|
||||||
** in this file for details. If in doubt, do not deviate from existing
|
** in this file for details. If in doubt, do not deviate from existing
|
||||||
** commenting and indentation practices when changing or adding code.
|
** commenting and indentation practices when changing or adding code.
|
||||||
**
|
**
|
||||||
** $Id: vdbe.c,v 1.802 2008/12/12 17:56:16 drh Exp $
|
** $Id: vdbe.c,v 1.803 2008/12/15 15:27:52 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
@ -1810,31 +1810,35 @@ case OP_Or: { /* same as TK_OR, in1, in2, out3 */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Opcode: Not P1 * * * *
|
/* Opcode: Not P1 P2 * * *
|
||||||
**
|
**
|
||||||
** Interpret the value in register P1 as a boolean value. Replace it
|
** Interpret the value in register P1 as a boolean value. Store the
|
||||||
** with its complement. If the value in register P1 is NULL its value
|
** boolean complement in register P2. If the value in register P1 is
|
||||||
** is unchanged.
|
** NULL, then a NULL is stored in P2.
|
||||||
*/
|
*/
|
||||||
case OP_Not: { /* same as TK_NOT, in1 */
|
case OP_Not: { /* same as TK_NOT, in1 */
|
||||||
if( pIn1->flags & MEM_Null ) break; /* Do nothing to NULLs */
|
pOut = &p->aMem[pOp->p2];
|
||||||
sqlite3VdbeMemIntegerify(pIn1);
|
if( pIn1->flags & MEM_Null ){
|
||||||
pIn1->u.i = !pIn1->u.i;
|
sqlite3VdbeMemSetNull(pOut);
|
||||||
assert( pIn1->flags&MEM_Int );
|
}else{
|
||||||
|
sqlite3VdbeMemSetInt64(pOut, !sqlite3VdbeIntValue(pIn1));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Opcode: BitNot P1 * * * *
|
/* Opcode: BitNot P1 P2 * * *
|
||||||
**
|
**
|
||||||
** Interpret the content of register P1 as an integer. Replace it
|
** Interpret the content of register P1 as an integer. Store the
|
||||||
** with its ones-complement. If the value is originally NULL, leave
|
** ones-complement of the P1 value into register P2. If P1 holds
|
||||||
** it unchanged.
|
** a NULL then store a NULL in P2.
|
||||||
*/
|
*/
|
||||||
case OP_BitNot: { /* same as TK_BITNOT, in1 */
|
case OP_BitNot: { /* same as TK_BITNOT, in1 */
|
||||||
if( pIn1->flags & MEM_Null ) break; /* Do nothing to NULLs */
|
pOut = &p->aMem[pOp->p2];
|
||||||
sqlite3VdbeMemIntegerify(pIn1);
|
if( pIn1->flags & MEM_Null ){
|
||||||
pIn1->u.i = ~pIn1->u.i;
|
sqlite3VdbeMemSetNull(pOut);
|
||||||
assert( pIn1->flags&MEM_Int );
|
}else{
|
||||||
|
sqlite3VdbeMemSetInt64(pOut, ~sqlite3VdbeIntValue(pIn1));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
# 2008 December 16
|
||||||
|
#
|
||||||
|
# The author disclaims copyright to this source code. In place of
|
||||||
|
# a legal notice, here is a blessing:
|
||||||
|
#
|
||||||
|
# May you do good and not evil.
|
||||||
|
# May you find forgiveness for yourself and forgive others.
|
||||||
|
# May you share freely, never taking more than you give.
|
||||||
|
#
|
||||||
|
#***********************************************************************
|
||||||
|
# This file implements regression tests for SQLite library.
|
||||||
|
#
|
||||||
|
# This file is a verification that the bugs identified in ticket
|
||||||
|
# #3541 have been fixed.
|
||||||
|
#
|
||||||
|
# $Id: tkt3541.test,v 1.1 2008/12/15 15:27:52 drh Exp $
|
||||||
|
|
||||||
|
set testdir [file dirname $argv0]
|
||||||
|
source $testdir/tester.tcl
|
||||||
|
|
||||||
|
do_test tkt3541-1.1 {
|
||||||
|
db eval {
|
||||||
|
CREATE TABLE t1(x);
|
||||||
|
INSERT INTO t1 VALUES(123);
|
||||||
|
SELECT CASE ~max(x) WHEN min(x) THEN 1 ELSE max(x) END FROM t1;
|
||||||
|
}
|
||||||
|
} {123}
|
||||||
|
do_test tkt3541-1.2 {
|
||||||
|
db eval {
|
||||||
|
SELECT CASE NOT max(x) WHEN min(x) THEN 1 ELSE max(x) END FROM t1;
|
||||||
|
}
|
||||||
|
} {123}
|
||||||
|
|
||||||
|
|
||||||
|
finish_test
|
Loading…
Reference in New Issue