modernc.org/cc@v1.0.1/v2/testdata/_sqlite/ext/fts5/test/fts5faultD.test (about)

     1  # 2016 February 2
     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  # This file is focused on OOM errors.
    13  #
    14  
    15  source [file join [file dirname [info script]] fts5_common.tcl]
    16  source $testdir/malloc_common.tcl
    17  set testprefix fts5faultA
    18  
    19  # If SQLITE_ENABLE_FTS3 is defined, omit this file.
    20  ifcapable !fts5 {
    21    finish_test
    22    return
    23  }
    24  
    25  foreach_detail_mode $testprefix {
    26    if {"%DETAIL%"=="none"} continue
    27  
    28    do_execsql_test 1.0 {
    29      CREATE VIRTUAL TABLE o1 USING fts5(a, b, c, detail=%DETAIL%);
    30      INSERT INTO o1(o1, rank) VALUES('pgsz', 32);
    31  
    32      WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<60 )
    33      INSERT INTO o1 SELECT 'A', 'B', 'C' FROM s;
    34  
    35      WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<60 )
    36      INSERT INTO o1 SELECT 'C', 'A', 'B' FROM s;
    37  
    38      WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<60 )
    39      INSERT INTO o1 SELECT 'B', 'C', 'A' FROM s;
    40    }
    41    
    42    do_faultsim_test 1 -faults int* -prep {
    43      sqlite3 db test.db
    44    } -body {
    45      execsql { SELECT count(*) FROM o1('a') }
    46    } -test {
    47      faultsim_test_result {0 180} {1 {vtable constructor failed: o1}}
    48    }
    49  
    50    do_faultsim_test 2 -faults int* -prep {
    51      sqlite3 db test.db
    52    } -body {
    53      execsql { SELECT * FROM o1('a:a AND {b c}:b') ORDER BY rank }
    54      expr 1
    55    } -test {
    56      faultsim_test_result {0 1} {1 {vtable constructor failed: o1}}
    57    }
    58  
    59    do_faultsim_test 3 -faults int* -prep {
    60      sqlite3 db test.db
    61    } -body {
    62      execsql { SELECT * FROM o1('{b c}:b NOT a:a') ORDER BY rank }
    63      expr 1
    64    } -test {
    65      faultsim_test_result {0 1} {1 {vtable constructor failed: o1}}
    66    }
    67  
    68    do_faultsim_test 4 -faults int* -prep {
    69      sqlite3 db test.db
    70    } -body {
    71      execsql { SELECT * FROM o1('b:b OR a:a') }
    72      expr 1
    73    } -test {
    74      faultsim_test_result {0 1} {1 {vtable constructor failed: o1}}
    75    }
    76  
    77    do_faultsim_test 5 -faults int* -prep {
    78      sqlite3 db test.db
    79    } -body {
    80      execsql { SELECT count(*) FROM o1('c:b') }
    81      expr 1
    82    } -test {
    83      faultsim_test_result {0 1} {1 {vtable constructor failed: o1}}
    84    }
    85  }
    86  
    87  finish_test