Change the OP_Found opcode so that it expands zero-blobs prior to comparing

them.  Fix for ticket [fccbde530a6583b]

FossilOrigin-Name: e2303d1b0c17b6e7494fb7db8264f4c2ac193723
This commit is contained in:
drh 2014-02-08 19:12:21 +00:00
parent c0740cebeb
commit 826af37865
4 changed files with 38 additions and 15 deletions

View File

@ -1,5 +1,5 @@
C Fix\sa\sharmless\scompiler\swarning\sin\sVS2013.
D 2014-02-08T13:24:04.793
C Change\sthe\sOP_Found\sopcode\sso\sthat\sit\sexpands\szero-blobs\sprior\sto\scomparing\nthem.\s\sFix\sfor\sticket\s[fccbde530a6583b]
D 2014-02-08T19:12:21.547
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -280,7 +280,7 @@ F src/update.c a7df6fffce6bfedc578fda6136dd33e34a63f8ee
F src/utf.c 6fc6c88d50448c469c5c196acf21617a24f90269
F src/util.c 15ac2627f548f5481d0d7e6c4eb67be673027695
F src/vacuum.c 3728d74919d4fb1356f9e9a13e27773db60b7179
F src/vdbe.c 0944fe28f711ce12b631f00d18ecf9d82f2f04f8
F src/vdbe.c a5556442eb6ada77eb432c98f22baa51b6abf3a9
F src/vdbe.h e6c4c610fcabad4fa80ebb1efc6822a9367e2b26
F src/vdbeInt.h b5d62957a408c4bea649484008e5f98335b09e97
F src/vdbeapi.c ce4e68ea4842cc6081046f533d088dcf01d247ad
@ -432,7 +432,7 @@ F test/descidx1.test 6d03b44c8538fe0eb4924e19fba10cdd8f3c9240
F test/descidx2.test 9f1a0c83fd57f8667c82310ca21b30a350888b5d
F test/descidx3.test 09ddbe3f5295f482d2f8b687cf6db8bad7acd9a2
F test/diskfull.test 106391384780753ea6896b7b4f005d10e9866b6e
F test/distinct.test 44028aaf161a5e80a2f229622b3a174d3b352810
F test/distinct.test c7b194ef95dbddb32d77acbbab2e023c6eed0cb2
F test/distinctagg.test 1a6ef9c87a58669438fc771450d7a72577417376
F test/e_createtable.test ee95d48664503d40f6cc9ef4a7d03216188e2ada
F test/e_delete.test d5186e2f5478b659f16a2c8b66c09892823e542a
@ -1152,7 +1152,7 @@ F tool/vdbe-compress.tcl 0cf56e9263a152b84da86e75a5c0cdcdb7a47891
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
P 129217ee91782ec77ff82661753ae5bee8ca99d0 35f2793db5eb58484554477a23f8320843ebcd71
R aef457d9a6de27675d731f11fafa24ac
P 83116ee3e0f2b9110c70a4f73a9badc9c2a56f28
R a13d7a863184cc3e51d017457c46ee29
U drh
Z 07817b5f1db7ebfb28393b8fc72b06af
Z 47328ab39b0e370926e85f5f82006e15

View File

@ -1 +1 @@
83116ee3e0f2b9110c70a4f73a9badc9c2a56f28
e2303d1b0c17b6e7494fb7db8264f4c2ac193723

View File

@ -3694,15 +3694,13 @@ case OP_Found: { /* jump, in3 */
r.pKeyInfo = pC->pKeyInfo;
r.nField = (u16)pOp->p4.i;
r.aMem = pIn3;
for(ii=0; ii<r.nField; ii++){
assert( memIsValid(&r.aMem[ii]) );
ExpandBlob(&r.aMem[ii]);
#ifdef SQLITE_DEBUG
{
int i;
for(i=0; i<r.nField; i++){
assert( memIsValid(&r.aMem[i]) );
if( i ) REGISTER_TRACE(pOp->p3+i, &r.aMem[i]);
}
}
if( ii ) REGISTER_TRACE(pOp->p3+ii, &r.aMem[ii]);
#endif
}
r.flags = UNPACKED_PREFIX_MATCH;
pIdxKey = &r;
}else{

View File

@ -197,4 +197,29 @@ do_test 3.1 {
}]
} {0}
#-------------------------------------------------------------------------
# Ticket [fccbde530a6583bf2748400919f1603d5425995c] (2014-01-08)
# The logic that computes DISTINCT sometimes thinks that a zeroblob()
# and a blob of all zeros are different when they should be the same.
#
do_execsql_test 4.1 {
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
CREATE TABLE t1(a INTEGER);
INSERT INTO t1 VALUES(3);
INSERT INTO t1 VALUES(2);
INSERT INTO t1 VALUES(1);
INSERT INTO t1 VALUES(2);
INSERT INTO t1 VALUES(3);
INSERT INTO t1 VALUES(1);
CREATE TABLE t2(x);
INSERT INTO t2
SELECT DISTINCT
CASE a WHEN 1 THEN x'0000000000'
WHEN 2 THEN zeroblob(5)
ELSE 'xyzzy' END
FROM t1;
SELECT quote(x) FROM t2 ORDER BY 1;
} {'xyzzy' X'0000000000'}
finish_test