/ Check-in [f92dc418]
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 | 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 Side-by-Side Diffs Show Whitespace Changes Patch

Changes to ext/lsm1/lsm_vtab.c.

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