SQLite

Check-in [5e0a97930b]
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
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 5e0a97930b08fff1c3a29f5c8b2962b856e3302209228c0e71b9f1a1bd2a4be3
User & Date: dan 2017-07-14 11:40:48.489
Context
2017-07-14
13:24
Minor updates to requirements marks and documention. No changes to code. (check-in: 8f6dd5e290 user: drh tags: trunk)
11:40
Add very simple tcl tests for the lsm1 extension. (check-in: 5e0a97930b user: dan tags: trunk)
04:16
Minor tweaks to documentation. No code changes. (check-in: d8cd0434f3 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to ext/lsm1/lsm_vtab.c.
591
592
593
594
595
596
597

598
599
600
601
602
603
604
  sqlite3_vtab *pVTab,
  int argc,
  sqlite3_value **argv,
  sqlite_int64 *pRowid
){
  lsm1_vtab *p = (lsm1_vtab*)pVTab;
  const void *pKey;

  int nKey;
  int eType;
  int rc = LSM_OK;
  sqlite3_value *pValue;
  const unsigned char *pVal;
  unsigned char *pData;
  int nVal;







>







591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
  sqlite3_vtab *pVTab,
  int argc,
  sqlite3_value **argv,
  sqlite_int64 *pRowid
){
  lsm1_vtab *p = (lsm1_vtab*)pVTab;
  const void *pKey;
  void *pFree = 0;
  int nKey;
  int eType;
  int rc = LSM_OK;
  sqlite3_value *pValue;
  const unsigned char *pVal;
  unsigned char *pData;
  int nVal;
625
626
627
628
629
630
631

632
633
634
635
636
637
638
    nKey = sqlite3_value_bytes(argv[2+LSM1_COLUMN_BLOBKEY]);
  }else{
    /* Use a key encoding that sorts in lexicographical order */
    rc = lsm1EncodeKey(argv[2+LSM1_COLUMN_KEY],
                       (unsigned char**)&pKey,&nKey,
                       pSpace,sizeof(pSpace));
    if( rc ) return rc;

  }
  if( sqlite3_value_type(argv[2+LSM1_COLUMN_BLOBVALUE])==SQLITE_BLOB ){
    pVal = sqlite3_value_blob(argv[2+LSM1_COLUMN_BLOBVALUE]);
    nVal = sqlite3_value_bytes(argv[2+LSM1_COLUMN_BLOBVALUE]);
    rc = lsm_insert(p->pDb, pKey, nKey, pVal, nVal);
  }else{
    pValue = argv[2+LSM1_COLUMN_VALUE];







>







626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
    nKey = sqlite3_value_bytes(argv[2+LSM1_COLUMN_BLOBKEY]);
  }else{
    /* Use a key encoding that sorts in lexicographical order */
    rc = lsm1EncodeKey(argv[2+LSM1_COLUMN_KEY],
                       (unsigned char**)&pKey,&nKey,
                       pSpace,sizeof(pSpace));
    if( rc ) return rc;
    if( pKey!=(const void*)pSpace ) pFree = (void*)pKey;
  }
  if( sqlite3_value_type(argv[2+LSM1_COLUMN_BLOBVALUE])==SQLITE_BLOB ){
    pVal = sqlite3_value_blob(argv[2+LSM1_COLUMN_BLOBVALUE]);
    nVal = sqlite3_value_bytes(argv[2+LSM1_COLUMN_BLOBVALUE]);
    rc = lsm_insert(p->pDb, pKey, nKey, pVal, nVal);
  }else{
    pValue = argv[2+LSM1_COLUMN_VALUE];
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
        }
        aVal[i] = (unsigned char)eType;
        rc = lsm_insert(p->pDb, pKey, nKey, &aVal[i], 9-i);
        break;
      }
    }
  }
  if( pKey!=(const void*)pSpace ) sqlite3_free((void*)pKey);
  return rc==LSM_OK ? SQLITE_OK : SQLITE_ERROR;
}      

/* Begin a transaction
*/
static int lsm1Begin(sqlite3_vtab *pVtab){
  lsm1_vtab *p = (lsm1_vtab*)pVtab;







|







681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
        }
        aVal[i] = (unsigned char)eType;
        rc = lsm_insert(p->pDb, pKey, nKey, &aVal[i], 9-i);
        break;
      }
    }
  }
  sqlite3_free(pFree);
  return rc==LSM_OK ? SQLITE_OK : SQLITE_ERROR;
}      

/* Begin a transaction
*/
static int lsm1Begin(sqlite3_vtab *pVtab){
  lsm1_vtab *p = (lsm1_vtab*)pVtab;
Added ext/lsm1/test/lsm1_common.tcl.






































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# 2014 Dec 19
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#

if {![info exists testdir]} {
  set testdir [file join [file dirname [info script]] .. .. .. test]
}
source $testdir/tester.tcl

# Check if the lsm1 extension has been compiled.
set lsm1 lsm1.so
if {[file exists [file join .. $lsm1]]} {
  proc return_if_no_lsm1 {} {}
} else {
  proc return_if_no_lsm1 {} {
    finish_test
    return -code return
  }
  return
}

proc load_lsm1_vtab {db} {
  db enable_load_extension 1
  db eval {SELECT load_extension('../lsm1')}
}


Added ext/lsm1/test/lsm1_simple.test.
















































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# 2017 July 14
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#*************************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script is testing the lsm1 virtual table module.
#

source [file join [file dirname [info script]] lsm1_common.tcl]
set testprefix lsm1_simple
return_if_no_lsm1
load_lsm1_vtab db

forcedelete testlsm.db

do_execsql_test 1.0 {
  CREATE VIRTUAL TABLE x1 USING lsm1(testlsm.db);
  PRAGMA table_info(x1);
} {
  0 key       {} 0 {} 0 
  1 blobkey   {} 0 {} 0 
  2 value     {} 0 {} 0 
  3 blobvalue {} 0 {} 0
}

do_execsql_test 1.1 {
  INSERT INTO x1(blobkey, blobvalue) VALUES(x'abcd', x'1234');
  SELECT quote(blobkey), quote(blobvalue) FROM x1;
} {X'ABCD' X'1234'}

do_catchsql_test 1.2 {
  UPDATE x1 SET blobvalue = x'7890' WHERE blobkey = x'abcd';
} {1 {cannot UPDATE}}

do_catchsql_test 1.3 {
  DELETE FROM x1 WHERE blobkey = x'abcd'
} {1 {cannot DELETE}}

do_test 1.4 {
  lsort [glob testlsm.db*]
} {testlsm.db testlsm.db-log testlsm.db-shm}

db close
do_test 1.5 {
  lsort [glob testlsm.db*]
} {testlsm.db}

finish_test


Changes to test/permutations.test.
85
86
87
88
89
90
91

92
93
94
95
96
97
98
99
#   $allquicktests
#
set alltests [list]
foreach f [glob $testdir/*.test] { lappend alltests [file tail $f] }
foreach f [glob -nocomplain       \
    $testdir/../ext/rtree/*.test  \
    $testdir/../ext/fts5/test/*.test   \

] { 
  lappend alltests $f 
}
foreach f [glob -nocomplain $testdir/../ext/session/*.test] { 
  lappend alltests $f 
}

if {$::tcl_platform(platform)!="unix"} {







>
|







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

if {$::tcl_platform(platform)!="unix"} {