/ 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 Unified Diffs Ignore Whitespace Patch

Changes to src/vdbeaux.c.

3554
3555
3556
3557
3558
3559
3560

3561
3562
3563
3564
3565
3566
3567
....
3589
3590
3591
3592
3593
3594
3595









3596
3597
3598
3599
3600
3601
3602
3603
3604


3605
3606


3607
3608
3609
3610
3611
3612
3613
  const u8 *aKey = &((const u8*)pKey1)[szHdr];
  int serial_type = ((const u8*)pKey1)[1];
  int res;
  i64 v = pPKey2->aMem[0].u.i;
  i64 lhs;

  switch( serial_type ){

    case 1:
      lhs = (char)(aKey[0]);
      break;
    case 2:
      lhs = 256*(signed char)aKey[0] + aKey[1];
      break;
    case 3:
................................................................................
      lhs = 0;
      break;

    case 9:
      lhs = 1;
      break;










    default:
      return vdbeRecordCompare(nKey1, pKey1, szHdr, 1, pPKey2);
  }

  if( v>lhs ){
    res = pPKey2->r1;
  }else if( v<lhs ){
    res = pPKey2->r2;
  }else if( pPKey2->nField>1 ){


    res = vdbeRecordCompare(nKey1, pKey1, szHdr, 0, pPKey2);
  }else{


    res = pPKey2->default_rc;
  }

  assert( (res==0 && vdbeRecordComparePrev(nKey1, pKey1, pPKey2)==0)
       || (res<0 && vdbeRecordComparePrev(nKey1, pKey1, pPKey2)<0)
       || (res>0 && vdbeRecordComparePrev(nKey1, pKey1, pPKey2)>0)
       || CORRUPT_DB







>







 







>
>
>
>
>
>
>
>
>









>
>


>
>







3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
....
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
  const u8 *aKey = &((const u8*)pKey1)[szHdr];
  int serial_type = ((const u8*)pKey1)[1];
  int res;
  i64 v = pPKey2->aMem[0].u.i;
  i64 lhs;

  switch( serial_type ){

    case 1:
      lhs = (char)(aKey[0]);
      break;
    case 2:
      lhs = 256*(signed char)aKey[0] + aKey[1];
      break;
    case 3:
................................................................................
      lhs = 0;
      break;

    case 9:
      lhs = 1;
      break;

    /* This case could be removed without changing the results of running
    ** this code. Including it causes gcc to generate a faster switch 
    ** statement (since the range of switch targets now starts at zero and
    ** is contiguous)) but does not cause any duplicate code to be generated
    ** (as gcc is clever enough to combine the two like cases). Other 
    ** compilers might be similar.  */ 
    case 0: case 7:
      return vdbeRecordCompare(nKey1, pKey1, szHdr, 1, pPKey2);

    default:
      return vdbeRecordCompare(nKey1, pKey1, szHdr, 1, pPKey2);
  }

  if( v>lhs ){
    res = pPKey2->r1;
  }else if( v<lhs ){
    res = pPKey2->r2;
  }else if( pPKey2->nField>1 ){
    /* The first fields of the two keys are equal. Compare the trailing 
    ** fields.  */
    res = vdbeRecordCompare(nKey1, pKey1, szHdr, 0, pPKey2);
  }else{
    /* The first fields of the two keys are equal and there are no trailing
    ** fields. Return pPKey2->default_rc in this case. */
    res = pPKey2->default_rc;
  }

  assert( (res==0 && vdbeRecordComparePrev(nKey1, pKey1, pPKey2)==0)
       || (res<0 && vdbeRecordComparePrev(nKey1, pKey1, pPKey2)<0)
       || (res>0 && vdbeRecordComparePrev(nKey1, pKey1, pPKey2)>0)
       || CORRUPT_DB