blob: ee9169ce2c4f6ac624f23d6ada3e579f1df6ba28 [file] [log] [blame]
shane3ed4e642008-10-22 16:04:42 +00001# 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#
drhdda70fe2009-06-05 17:09:11 +000017# $Id: tkt3442.test,v 1.2 2009/06/05 17:09:12 drh Exp $
shane3ed4e642008-10-22 16:04:42 +000018
19
20set testdir [file dirname $argv0]
21source $testdir/tester.tcl
22
23
24# Create a schema with some indexes.
25#
26do_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
38# Explain Query Plan
39#
40proc EQP {sql} {
41 uplevel "execsql {EXPLAIN QUERY PLAN $sql}"
42}
43
44
45# These tests perform an EXPLAIN QUERY PLAN on both versions of the
46# SELECT referenced in ticket #3442 (both '5000' and "5000")
47# and verify that the query plan is the same.
48#
49ifcapable explain {
50 do_test tkt3442-1.2 {
51 EQP { SELECT node FROM listhash WHERE id='5000' LIMIT 1; }
drh5822d6f2013-06-10 23:30:09 +000052 } {0 0 0 {SEARCH TABLE listhash USING INDEX ididx (id=?)}}
shane3ed4e642008-10-22 16:04:42 +000053 do_test tkt3442-1.3 {
54 EQP { SELECT node FROM listhash WHERE id="5000" LIMIT 1; }
drh5822d6f2013-06-10 23:30:09 +000055 } {0 0 0 {SEARCH TABLE listhash USING INDEX ididx (id=?)}}
shane3ed4e642008-10-22 16:04:42 +000056}
57
58
59# Some extra tests testing other permutations of 5000.
60#
61ifcapable explain {
62 do_test tkt3442-1.4 {
63 EQP { SELECT node FROM listhash WHERE id=5000 LIMIT 1; }
drh5822d6f2013-06-10 23:30:09 +000064 } {0 0 0 {SEARCH TABLE listhash USING INDEX ididx (id=?)}}
shane3ed4e642008-10-22 16:04:42 +000065}
66do_test tkt3442-1.5 {
67 catchsql {
68 SELECT node FROM listhash WHERE id=[5000] LIMIT 1;
69 }
70} {1 {no such column: 5000}}
71
72finish_test