/ Check-in [284bde0e]
Login

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

Overview
Comment:Minor tweak to vdbeRecordCompareInt().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | experimental
Files: files | file ages | folders
SHA1: 284bde0ee20261737446eb8f5b6b36ad9bc3f355
User & Date: dan 2014-02-28 09:48:30
Context
2014-02-28
18:39
Update some test cases that deal with corrupt databases. check-in: 3a09f560 user: dan tags: experimental
09:48
Minor tweak to vdbeRecordCompareInt(). check-in: 284bde0e user: dan tags: experimental
2014-02-27
20:52
Merge in latest trunk changes. check-in: 8f30b095 user: dan tags: experimental
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbeaux.c.

  3554   3554     const u8 *aKey = &((const u8*)pKey1)[szHdr];
  3555   3555     int serial_type = ((const u8*)pKey1)[1];
  3556   3556     int res;
  3557   3557     i64 v = pPKey2->aMem[0].u.i;
  3558   3558     i64 lhs;
  3559   3559   
  3560   3560     switch( serial_type ){
         3561  +
  3561   3562       case 1:
  3562   3563         lhs = (char)(aKey[0]);
  3563   3564         break;
  3564   3565       case 2:
  3565   3566         lhs = 256*(signed char)aKey[0] + aKey[1];
  3566   3567         break;
  3567   3568       case 3:
................................................................................
  3589   3590         lhs = 0;
  3590   3591         break;
  3591   3592   
  3592   3593       case 9:
  3593   3594         lhs = 1;
  3594   3595         break;
  3595   3596   
         3597  +    /* This case could be removed without changing the results of running
         3598  +    ** this code. Including it causes gcc to generate a faster switch 
         3599  +    ** statement (since the range of switch targets now starts at zero and
         3600  +    ** is contiguous)) but does not cause any duplicate code to be generated
         3601  +    ** (as gcc is clever enough to combine the two like cases). Other 
         3602  +    ** compilers might be similar.  */ 
         3603  +    case 0: case 7:
         3604  +      return vdbeRecordCompare(nKey1, pKey1, szHdr, 1, pPKey2);
         3605  +
  3596   3606       default:
  3597   3607         return vdbeRecordCompare(nKey1, pKey1, szHdr, 1, pPKey2);
  3598   3608     }
  3599   3609   
  3600   3610     if( v>lhs ){
  3601   3611       res = pPKey2->r1;
  3602   3612     }else if( v<lhs ){
  3603   3613       res = pPKey2->r2;
  3604   3614     }else if( pPKey2->nField>1 ){
         3615  +    /* The first fields of the two keys are equal. Compare the trailing 
         3616  +    ** fields.  */
  3605   3617       res = vdbeRecordCompare(nKey1, pKey1, szHdr, 0, pPKey2);
  3606   3618     }else{
         3619  +    /* The first fields of the two keys are equal and there are no trailing
         3620  +    ** fields. Return pPKey2->default_rc in this case. */
  3607   3621       res = pPKey2->default_rc;
  3608   3622     }
  3609   3623   
  3610   3624     assert( (res==0 && vdbeRecordComparePrev(nKey1, pKey1, pPKey2)==0)
  3611   3625          || (res<0 && vdbeRecordComparePrev(nKey1, pKey1, pPKey2)<0)
  3612   3626          || (res>0 && vdbeRecordComparePrev(nKey1, pKey1, pPKey2)>0)
  3613   3627          || CORRUPT_DB