SQLite

Check-in [f92dc4187f]
Login

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
Timelines: family | ancestors | descendants | both | lsm-vtab
Files: files | file ages | folders
SHA1: f92dc4187f6046fcb3ab63449efd7f3738594adc
User & Date: drh 2016-02-24 13:35:22.043
Context
2017-06-01
16:13
Add test code for LSM to the ext/lsm1/lsm-test directory. (check-in: bb7436e84a 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: f92dc4187f user: drh tags: lsm-vtab)
2016-02-23
01:41
Merge trunk enhancements. (check-in: fac4f4ecee user: drh tags: lsm-vtab)
Changes
Side-by-Side Diff Show Whitespace Changes Patch
Changes to ext/lsm1/lsm_vtab.c.
375
376
377
378
379
380
381
382

383
384
385
386
387
388
389
375
376
377
378
379
380
381

382
383
384
385
386
387
388
389







-
+







      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;
        uVal = *(sqlite3_uint64*)&iVal;
        eType = LSM1_TYPE_NEGATIVE;
      }else{
        uVal = iVal;
        eType = LSM1_TYPE_POSITIVE;
      }
      pSpace[0] = eType;
      *ppKey = pSpace;
420
421
422
423
424
425
426
427

428
429
430
431


432
433

434
435
436
437
438
439
440
441
442
443
420
421
422
423
424
425
426

427
428
429


430
431


432



433
434
435
436
437
438
439







-
+


-
-
+
+
-
-
+
-
-
-







      ){
        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 &&
        }else if( nVal>=2 && nVal<=10 &&
           (pVal[0]==LSM1_TYPE_POSITIVE || pVal[0]==LSM1_TYPE_NEGATIVE)
        ){
          sqlite3_uint64 uVal = 0;
          lsm1GetVarint64(pVal+1, nVal-1, &uVal);
          sqlite3_int64 iVal;
          lsm1GetVarint64(pVal+1, nVal-1, (sqlite3_uint64*)&iVal);
          if( pVal[0]==LSM1_TYPE_NEGATIVE ){
            sqlite3_result_int64(ctx, -(sqlite3_int64)uVal);
          sqlite3_result_int64(ctx, iVal);
          }else{
            sqlite3_result_int64(ctx, (sqlite3_int64)uVal); 
          }
        }         
      }
      break;
    }
    case LSM1_COLUMN_BLOBVALUE: {
      const void *pVal;
      int nVal;