/ Check-in [e2303d1b]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Change the OP_Found opcode so that it expands zero-blobs prior to comparing them. Fix for ticket [fccbde530a6583b]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e2303d1b0c17b6e7494fb7db8264f4c2ac193723
User & Date: drh 2014-02-08 19:12:21
Context
2014-02-08
23:20
Do away with the "multi-register pseudo-table" abstration. Instead, just use an OP_SCopy to load results directory from the result registers of the co-routine. check-in: 1e64dd78 user: drh tags: trunk
19:12
Change the OP_Found opcode so that it expands zero-blobs prior to comparing them. Fix for ticket [fccbde530a6583b] check-in: e2303d1b user: drh tags: trunk
13:24
Fix a harmless compiler warning in VS2013. check-in: 83116ee3 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbe.c.

  3690   3690     assert( pC->pCursor!=0 );
  3691   3691     assert( pC->isTable==0 );
  3692   3692     pFree = 0;  /* Not needed.  Only used to suppress a compiler warning. */
  3693   3693     if( pOp->p4.i>0 ){
  3694   3694       r.pKeyInfo = pC->pKeyInfo;
  3695   3695       r.nField = (u16)pOp->p4.i;
  3696   3696       r.aMem = pIn3;
         3697  +    for(ii=0; ii<r.nField; ii++){
         3698  +      assert( memIsValid(&r.aMem[ii]) );
         3699  +      ExpandBlob(&r.aMem[ii]);
  3697   3700   #ifdef SQLITE_DEBUG
  3698         -    {
  3699         -      int i;
  3700         -      for(i=0; i<r.nField; i++){
  3701         -        assert( memIsValid(&r.aMem[i]) );
  3702         -        if( i ) REGISTER_TRACE(pOp->p3+i, &r.aMem[i]);
  3703         -      }
         3701  +      if( ii ) REGISTER_TRACE(pOp->p3+ii, &r.aMem[ii]);
         3702  +#endif
  3704   3703       }
  3705         -#endif
  3706   3704       r.flags = UNPACKED_PREFIX_MATCH;
  3707   3705       pIdxKey = &r;
  3708   3706     }else{
  3709   3707       pIdxKey = sqlite3VdbeAllocUnpackedRecord(
  3710   3708           pC->pKeyInfo, aTempRec, sizeof(aTempRec), &pFree
  3711   3709       ); 
  3712   3710       if( pIdxKey==0 ) goto no_mem;

Changes to test/distinct.test.

   192    192     }
   193    193   } {{} {} {} 3 6 {}}
   194    194   do_test 3.1 {
   195    195     regexp {OpenEphemeral} [db eval {
   196    196       EXPLAIN SELECT DISTINCT a, b FROM t3 ORDER BY +a, +b;
   197    197     }]
   198    198   } {0}
          199  +
          200  +#-------------------------------------------------------------------------
          201  +# Ticket  [fccbde530a6583bf2748400919f1603d5425995c] (2014-01-08)
          202  +# The logic that computes DISTINCT sometimes thinks that a zeroblob()
          203  +# and a blob of all zeros are different when they should be the same. 
          204  +#
          205  +do_execsql_test 4.1 {
          206  +  DROP TABLE IF EXISTS t1;
          207  +  DROP TABLE IF EXISTS t2;
          208  +  CREATE TABLE t1(a INTEGER);
          209  +  INSERT INTO t1 VALUES(3);
          210  +  INSERT INTO t1 VALUES(2);
          211  +  INSERT INTO t1 VALUES(1);
          212  +  INSERT INTO t1 VALUES(2);
          213  +  INSERT INTO t1 VALUES(3);
          214  +  INSERT INTO t1 VALUES(1);
          215  +  CREATE TABLE t2(x);
          216  +  INSERT INTO t2
          217  +    SELECT DISTINCT
          218  +      CASE a WHEN 1 THEN x'0000000000'
          219  +             WHEN 2 THEN zeroblob(5)
          220  +             ELSE 'xyzzy' END
          221  +      FROM t1;
          222  +  SELECT quote(x) FROM t2 ORDER BY 1;
          223  +} {'xyzzy' X'0000000000'}
   199    224   
   200    225   finish_test