/ Check-in [acb65297]
Login

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

Overview
Comment:Floating point values are serialized in big-endian byte order. (CVS 1431)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: acb65297b69c531813287166175fa7864c900fe6
User & Date: drh 2004-05-21 21:12:42
Context
2004-05-22
02:55
Update comments and remove dead code from btree.c (CVS 1432) check-in: 8069caca user: drh tags: trunk
2004-05-21
21:12
Floating point values are serialized in big-endian byte order. (CVS 1431) check-in: acb65297 user: drh tags: trunk
13:39
Remove the OP_SetFound opcode and its cousins. (CVS 1430) check-in: 5524075e user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/vdbeaux.c.

1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
....
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488




1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
....
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
  assert( serial_type!=0 );
 
  /* NULL */
  if( serial_type==6 ){
    return 0;
  }
 
  /* Integer */
  if( serial_type<5 ){
    i64 i = pMem->i;
    len = sqlite3VdbeSerialTypeLen(serial_type);
    while( len-- ){
      buf[len] = (i&0xFF);
      i = i >> 8;
    }
    return sqlite3VdbeSerialTypeLen(serial_type);
  }

  /* Float */
  if( serial_type==5 ){
    /* TODO: byte ordering? */
    assert( sizeof(double)==8 );
    memcpy(buf, &pMem->r, 8);
    return 8;
  }
  
  /* String or blob */
  assert( serial_type>=12 );
  len = sqlite3VdbeSerialTypeLen(serial_type);
  memcpy(buf, pMem->z, len);
  return len;
................................................................................

  /* NULL */
  if( serial_type==6 ){
    pMem->flags = MEM_Null;
    return 0;
  }
 
  /* Integer */
  if( serial_type<5 ){
    i64 i = 0;
    int n;
    len = sqlite3VdbeSerialTypeLen(serial_type);

    if( buf[0]&0x80 ){
      for(n=0; n<(8-len); n++){
        i = (i<<8)+0xFF;
      }
    }
    for(n=0; n<len; n++){
      i = i << 8;
      i = i + buf[n];
    }




    pMem->flags = MEM_Int;
    pMem->i = i;
    return sqlite3VdbeSerialTypeLen(serial_type);
  }

  /* Float */
  if( serial_type==5 ){
    /* TODO: byte ordering? */
    assert( sizeof(double)==8 );
    memcpy(&pMem->r, buf, 8);
    pMem->flags = MEM_Real;
    return 8;
  }
  
  /* String or blob */
  assert( serial_type>=12 );
  len = sqlite3VdbeSerialTypeLen(serial_type);
  if( serial_type&0x01 ){
    pMem->flags = MEM_Str|MEM_Utf8;
    pMem->n = len+1;
  }else{
................................................................................
  *res = sqlite3VdbeKeyCompare(pC->pKeyInfo, len, pCellKey, nKey, pKey);
  
  if( freeCellKey ){
    sqliteFree(pCellKey);
  }
  return SQLITE_OK;
}










|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
<







 







|
|
|




|
<
|
<

<
|

>
>
>
>
|
|
<
|
<
<
<
<
<
<
<
|

|







 







<
<
<
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443


1444
1445
1446
1447
1448
1449
1450
....
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479

1480

1481

1482
1483
1484
1485
1486
1487
1488
1489

1490







1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
....
1870
1871
1872
1873
1874
1875
1876



  assert( serial_type!=0 );
 
  /* NULL */
  if( serial_type==6 ){
    return 0;
  }
 
  /* Integer and Real */
  if( serial_type<=5 ){
    u64 v;
    int i;
    if( serial_type==5 ){
      v = *(u64*)&pMem->r;
    }else{
      v = *(u64*)&pMem->i;
    }
    len = i = sqlite3VdbeSerialTypeLen(serial_type);
    while( i-- ){
      buf[i] = (v&0xFF);
      v >>= 8;
    }
    return len;


  }
  
  /* String or blob */
  assert( serial_type>=12 );
  len = sqlite3VdbeSerialTypeLen(serial_type);
  memcpy(buf, pMem->z, len);
  return len;
................................................................................

  /* NULL */
  if( serial_type==6 ){
    pMem->flags = MEM_Null;
    return 0;
  }
 
  /* Integer and Real */
  if( serial_type<=5 ){
    u64 v = 0;
    int n;
    len = sqlite3VdbeSerialTypeLen(serial_type);

    if( buf[0]&0x80 ){
      v = -1;

    }

    for(n=0; n<len; n++){

      v = (v<<8) | buf[n];
    }
    if( serial_type==5 ){
      pMem->flags = MEM_Real;
      pMem->r = *(double*)&v;
    }else{
      pMem->flags = MEM_Int;
      pMem->i = *(int*)&v;

    }







    return len;
  }

  /* String or blob */
  assert( serial_type>=12 );
  len = sqlite3VdbeSerialTypeLen(serial_type);
  if( serial_type&0x01 ){
    pMem->flags = MEM_Str|MEM_Utf8;
    pMem->n = len+1;
  }else{
................................................................................
  *res = sqlite3VdbeKeyCompare(pC->pKeyInfo, len, pCellKey, nKey, pKey);
  
  if( freeCellKey ){
    sqliteFree(pCellKey);
  }
  return SQLITE_OK;
}