/ Check-in [5e0a9793]
Login

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

Overview
Comment:Add very simple tcl tests for the lsm1 extension.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:5e0a97930b08fff1c3a29f5c8b2962b856e3302209228c0e71b9f1a1bd2a4be3
User & Date: dan 2017-07-14 11:40:48
Context
2017-07-14
13:24
Minor updates to requirements marks and documention. No changes to code. check-in: 8f6dd5e2 user: drh tags: trunk
11:40
Add very simple tcl tests for the lsm1 extension. check-in: 5e0a9793 user: dan tags: trunk
04:16
Minor tweaks to documentation. No code changes. check-in: d8cd0434 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/lsm1/lsm_vtab.c.

   591    591     sqlite3_vtab *pVTab,
   592    592     int argc,
   593    593     sqlite3_value **argv,
   594    594     sqlite_int64 *pRowid
   595    595   ){
   596    596     lsm1_vtab *p = (lsm1_vtab*)pVTab;
   597    597     const void *pKey;
          598  +  void *pFree = 0;
   598    599     int nKey;
   599    600     int eType;
   600    601     int rc = LSM_OK;
   601    602     sqlite3_value *pValue;
   602    603     const unsigned char *pVal;
   603    604     unsigned char *pData;
   604    605     int nVal;
................................................................................
   625    626       nKey = sqlite3_value_bytes(argv[2+LSM1_COLUMN_BLOBKEY]);
   626    627     }else{
   627    628       /* Use a key encoding that sorts in lexicographical order */
   628    629       rc = lsm1EncodeKey(argv[2+LSM1_COLUMN_KEY],
   629    630                          (unsigned char**)&pKey,&nKey,
   630    631                          pSpace,sizeof(pSpace));
   631    632       if( rc ) return rc;
          633  +    if( pKey!=(const void*)pSpace ) pFree = (void*)pKey;
   632    634     }
   633    635     if( sqlite3_value_type(argv[2+LSM1_COLUMN_BLOBVALUE])==SQLITE_BLOB ){
   634    636       pVal = sqlite3_value_blob(argv[2+LSM1_COLUMN_BLOBVALUE]);
   635    637       nVal = sqlite3_value_bytes(argv[2+LSM1_COLUMN_BLOBVALUE]);
   636    638       rc = lsm_insert(p->pDb, pKey, nKey, pVal, nVal);
   637    639     }else{
   638    640       pValue = argv[2+LSM1_COLUMN_VALUE];
................................................................................
   679    681           }
   680    682           aVal[i] = (unsigned char)eType;
   681    683           rc = lsm_insert(p->pDb, pKey, nKey, &aVal[i], 9-i);
   682    684           break;
   683    685         }
   684    686       }
   685    687     }
   686         -  if( pKey!=(const void*)pSpace ) sqlite3_free((void*)pKey);
          688  +  sqlite3_free(pFree);
   687    689     return rc==LSM_OK ? SQLITE_OK : SQLITE_ERROR;
   688    690   }      
   689    691   
   690    692   /* Begin a transaction
   691    693   */
   692    694   static int lsm1Begin(sqlite3_vtab *pVtab){
   693    695     lsm1_vtab *p = (lsm1_vtab*)pVtab;

Added ext/lsm1/test/lsm1_common.tcl.

            1  +# 2014 Dec 19
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +#
           12  +
           13  +if {![info exists testdir]} {
           14  +  set testdir [file join [file dirname [info script]] .. .. .. test]
           15  +}
           16  +source $testdir/tester.tcl
           17  +
           18  +# Check if the lsm1 extension has been compiled.
           19  +set lsm1 lsm1.so
           20  +if {[file exists [file join .. $lsm1]]} {
           21  +  proc return_if_no_lsm1 {} {}
           22  +} else {
           23  +  proc return_if_no_lsm1 {} {
           24  +    finish_test
           25  +    return -code return
           26  +  }
           27  +  return
           28  +}
           29  +
           30  +proc load_lsm1_vtab {db} {
           31  +  db enable_load_extension 1
           32  +  db eval {SELECT load_extension('../lsm1')}
           33  +}
           34  +
           35  +

Added ext/lsm1/test/lsm1_simple.test.

            1  +# 2017 July 14
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#*************************************************************************
           11  +# This file implements regression tests for SQLite library.  The
           12  +# focus of this script is testing the lsm1 virtual table module.
           13  +#
           14  +
           15  +source [file join [file dirname [info script]] lsm1_common.tcl]
           16  +set testprefix lsm1_simple
           17  +return_if_no_lsm1
           18  +load_lsm1_vtab db
           19  +
           20  +forcedelete testlsm.db
           21  +
           22  +do_execsql_test 1.0 {
           23  +  CREATE VIRTUAL TABLE x1 USING lsm1(testlsm.db);
           24  +  PRAGMA table_info(x1);
           25  +} {
           26  +  0 key       {} 0 {} 0 
           27  +  1 blobkey   {} 0 {} 0 
           28  +  2 value     {} 0 {} 0 
           29  +  3 blobvalue {} 0 {} 0
           30  +}
           31  +
           32  +do_execsql_test 1.1 {
           33  +  INSERT INTO x1(blobkey, blobvalue) VALUES(x'abcd', x'1234');
           34  +  SELECT quote(blobkey), quote(blobvalue) FROM x1;
           35  +} {X'ABCD' X'1234'}
           36  +
           37  +do_catchsql_test 1.2 {
           38  +  UPDATE x1 SET blobvalue = x'7890' WHERE blobkey = x'abcd';
           39  +} {1 {cannot UPDATE}}
           40  +
           41  +do_catchsql_test 1.3 {
           42  +  DELETE FROM x1 WHERE blobkey = x'abcd'
           43  +} {1 {cannot DELETE}}
           44  +
           45  +do_test 1.4 {
           46  +  lsort [glob testlsm.db*]
           47  +} {testlsm.db testlsm.db-log testlsm.db-shm}
           48  +
           49  +db close
           50  +do_test 1.5 {
           51  +  lsort [glob testlsm.db*]
           52  +} {testlsm.db}
           53  +
           54  +finish_test
           55  +
           56  +

Changes to test/permutations.test.

    85     85   #   $allquicktests
    86     86   #
    87     87   set alltests [list]
    88     88   foreach f [glob $testdir/*.test] { lappend alltests [file tail $f] }
    89     89   foreach f [glob -nocomplain       \
    90     90       $testdir/../ext/rtree/*.test  \
    91     91       $testdir/../ext/fts5/test/*.test   \
    92         -] { 
           92  +    $testdir/../ext/lsm1/test/*.test   \
           93  +] {
    93     94     lappend alltests $f 
    94     95   }
    95     96   foreach f [glob -nocomplain $testdir/../ext/session/*.test] { 
    96     97     lappend alltests $f 
    97     98   }
    98     99   
    99    100   if {$::tcl_platform(platform)!="unix"} {