github.com/jdgcs/sqlite3@v1.12.1-0.20210908114423-bc5f96e4dd51/testdata/tcl/tkt3442.test (about)

     1  # 2008 October 20
     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.
    12  #
    13  # This file implements tests to verify that ticket #3442 has been
    14  # fixed.  
    15  #
    16  #
    17  # $Id: tkt3442.test,v 1.2 2009/06/05 17:09:12 drh Exp $
    18  
    19  
    20  set testdir [file dirname $argv0]
    21  source $testdir/tester.tcl
    22  
    23  
    24  # Create a schema with some indexes.
    25  #
    26  do_test tkt3442-1.1 {
    27    execsql {
    28       CREATE TABLE listhash(
    29         key INTEGER PRIMARY KEY,
    30         id TEXT,
    31         node INTEGER
    32       );
    33       CREATE UNIQUE INDEX ididx ON listhash(id);
    34    }
    35  } {}
    36  
    37  # These tests perform an EXPLAIN QUERY PLAN on both versions of the 
    38  # SELECT referenced in ticket #3442 (both '5000' and "5000") 
    39  # and verify that the query plan is the same.
    40  #
    41  do_eqp_test tkt3442-1.2 {
    42    SELECT node FROM listhash WHERE id='5000' LIMIT 1;
    43  } {SEARCH listhash USING INDEX ididx (id=?)}
    44  do_eqp_test tkt3442-1.3 {
    45    SELECT node FROM listhash WHERE id="5000" LIMIT 1;
    46  } {SEARCH listhash USING INDEX ididx (id=?)}
    47  
    48  
    49  # Some extra tests testing other permutations of 5000.
    50  #
    51  do_eqp_test tkt3442-1.4 {
    52    SELECT node FROM listhash WHERE id=5000 LIMIT 1;
    53  } {SEARCH listhash USING INDEX ididx (id=?)}
    54  
    55  do_test tkt3442-1.5 {
    56    catchsql {
    57      SELECT node FROM listhash WHERE id=[5000] LIMIT 1;
    58    }
    59  } {1 {no such column: 5000}}
    60  
    61  finish_test