gitlab.com/CoiaPrant/sqlite3@v1.19.1/testdata/tcl/vtabD.test (about)

     1  # 2009 April 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 file is creating and dropping virtual tables.
    13  #
    14  # $Id: vtabD.test,v 1.3 2009/06/05 17:09:12 drh Exp $
    15  
    16  set testdir [file dirname $argv0]
    17  source $testdir/tester.tcl
    18  
    19  ifcapable !vtab||!schema_pragmas { finish_test ; return }
    20  
    21  # Register the echo module
    22  register_echo_module [sqlite3_connection_pointer db]
    23  
    24  do_test vtabD-1.1 {
    25    execsql {
    26      CREATE TABLE t1(a, b);
    27      CREATE INDEX i1 ON t1(a);
    28      CREATE INDEX i2 ON t1(b);
    29      CREATE VIRTUAL TABLE tv1 USING echo(t1);
    30    }
    31  } {}
    32  do_test vtabD-1.2 {
    33    execsql BEGIN
    34    for {set i 0} {$i < 100000} {incr i} {
    35      execsql { INSERT INTO t1 VALUES($i, $i*$i) }
    36    }
    37    execsql COMMIT
    38  } {}
    39  do_test vtabD-1.3 {
    40    execsql { SELECT * FROM tv1 WHERE a = 1 OR b = 4 }
    41  } {1 1 2 4}
    42  do_test vtabD-1.4 {
    43    execsql { SELECT * FROM tv1 WHERE a = 1 OR b = 1 }
    44  } {1 1}
    45  do_test vtabD-1.5 {
    46    execsql { SELECT * FROM tv1 WHERE (a > 0 AND a < 5) OR (b > 15 AND b < 65) }
    47  } {1 1 2 4 3 9 4 16 5 25 6 36 7 49 8 64}
    48  
    49  do_test vtabD-1.6 {
    50    execsql { SELECT * FROM tv1 WHERE a < 500 OR b = 810000 }
    51  } [execsql {
    52    SELECT * FROM t1 WHERE a < 500;
    53    SELECT * FROM t1 WHERE b = 810000 AND NOT (a < 500);
    54  }]
    55  
    56  do_test vtabD-1.7 {
    57    execsql { SELECT * FROM tv1 WHERE a < 90000 OR b = 8100000000 }
    58  } [execsql {
    59    SELECT * FROM t1 WHERE a < 90000;
    60    SELECT * FROM t1 WHERE b = 8100000000 AND NOT (a < 90000);
    61  }]
    62  
    63  if {[working_64bit_int]} {
    64  do_test vtabD-1.8 {
    65    execsql { SELECT * FROM tv1 WHERE a = 90001 OR b = 810000 }
    66  } {90001 8100180001 900 810000}
    67  }
    68  
    69  finish_test