/ Check-in [f92dc418]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:LSM1: Fix the integer key encoding so that negative keys are in numeric order.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | lsm-vtab
Files: files | file ages | folders
SHA1: f92dc4187f6046fcb3ab63449efd7f3738594adc
User & Date: drh 2016-02-24 13:35:22
Context
2017-06-01
16:13
Add test code for LSM to the ext/lsm1/lsm-test directory. check-in: bb7436e8 user: dan tags: lsm-vtab
2016-02-24
13:35
LSM1: Fix the integer key encoding so that negative keys are in numeric order. check-in: f92dc418 user: drh tags: lsm-vtab
2016-02-23
01:41
Merge trunk enhancements. check-in: fac4f4ec user: drh tags: lsm-vtab
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ext/lsm1/lsm_vtab.c.

375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
...
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
      break;
    }
    case SQLITE_INTEGER: {
      sqlite3_int64 iVal = sqlite3_value_int64(pValue);
      sqlite3_uint64 uVal;
      if( iVal<0 ){
        if( iVal==0xffffffffffffffffLL ) return SQLITE_ERROR;
        uVal = -iVal;
        eType = LSM1_TYPE_NEGATIVE;
      }else{
        uVal = iVal;
        eType = LSM1_TYPE_POSITIVE;
      }
      pSpace[0] = eType;
      *ppKey = pSpace;
................................................................................
      ){
        if( pVal[0]==LSM1_TYPE_BLOB ){
          sqlite3_result_blob(ctx, (const void*)&pVal[1],nVal-1,
                              SQLITE_TRANSIENT);
        }else if( pVal[0]==LSM1_TYPE_TEXT ){
          sqlite3_result_text(ctx, (const char*)&pVal[1],nVal-1,
                              SQLITE_TRANSIENT);
        }else if( nVal>=2 && nVal<=9 &&
           (pVal[0]==LSM1_TYPE_POSITIVE || pVal[0]==LSM1_TYPE_NEGATIVE)
        ){
          sqlite3_uint64 uVal = 0;
          lsm1GetVarint64(pVal+1, nVal-1, &uVal);
          if( pVal[0]==LSM1_TYPE_NEGATIVE ){
            sqlite3_result_int64(ctx, -(sqlite3_int64)uVal);
          }else{
            sqlite3_result_int64(ctx, (sqlite3_int64)uVal); 
          }
        }         
      }
      break;
    }
    case LSM1_COLUMN_BLOBVALUE: {
      const void *pVal;
      int nVal;







|







 







|


|
|
<
<
<
|
<







375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
...
420
421
422
423
424
425
426
427
428
429
430
431



432

433
434
435
436
437
438
439
      break;
    }
    case SQLITE_INTEGER: {
      sqlite3_int64 iVal = sqlite3_value_int64(pValue);
      sqlite3_uint64 uVal;
      if( iVal<0 ){
        if( iVal==0xffffffffffffffffLL ) return SQLITE_ERROR;
        uVal = *(sqlite3_uint64*)&iVal;
        eType = LSM1_TYPE_NEGATIVE;
      }else{
        uVal = iVal;
        eType = LSM1_TYPE_POSITIVE;
      }
      pSpace[0] = eType;
      *ppKey = pSpace;
................................................................................
      ){
        if( pVal[0]==LSM1_TYPE_BLOB ){
          sqlite3_result_blob(ctx, (const void*)&pVal[1],nVal-1,
                              SQLITE_TRANSIENT);
        }else if( pVal[0]==LSM1_TYPE_TEXT ){
          sqlite3_result_text(ctx, (const char*)&pVal[1],nVal-1,
                              SQLITE_TRANSIENT);
        }else if( nVal>=2 && nVal<=10 &&
           (pVal[0]==LSM1_TYPE_POSITIVE || pVal[0]==LSM1_TYPE_NEGATIVE)
        ){
          sqlite3_int64 iVal;
          lsm1GetVarint64(pVal+1, nVal-1, (sqlite3_uint64*)&iVal);



          sqlite3_result_int64(ctx, iVal);

        }         
      }
      break;
    }
    case LSM1_COLUMN_BLOBVALUE: {
      const void *pVal;
      int nVal;