3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
11 # This file implements regression tests for SQLite library.
13 # This file implements tests to verify that ticket #1435 has been
17 # $Id: tkt1435.test,v 1.2 2006/01/17 09:35:02 danielk1977 Exp $
19 set testdir [file dirname $argv0]
20 source $testdir/tester.tcl
27 # Construct the sample database.
32 CREATE TABLE Instances(
33 instanceId INTEGER PRIMARY KEY,
41 INSERT INTO "Instances"
42 VALUES(1, 'libhello:runtime', 1, 1, 1126929880.094, 1, 1);
43 INSERT INTO "Instances"
44 VALUES(2, 'libhello:user', 1, 1, 1126929880.094, 1, 0);
45 INSERT INTO "Instances"
46 VALUES(3, 'libhello:script', 1, 1, 1126929880.094, 1, 0);
47 INSERT INTO "Instances"
48 VALUES(4, 'libhello', 1, 1, 1126929880.094, 1, 0);
50 CREATE TABLE Versions(versionId INTEGER PRIMARY KEY,version STR UNIQUE);
51 INSERT INTO "Versions" VALUES(0, NULL);
52 INSERT INTO "Versions" VALUES(1, '/localhost@rpl:linux/0-1-1');
54 CREATE TABLE Flavors(flavorId integer primary key, flavor str unique);
55 INSERT INTO "Flavors" VALUES(0, NULL);
56 INSERT INTO "Flavors" VALUES(1, '1#x86');
58 CREATE TEMPORARY TABLE tlList (
59 row INTEGER PRIMARY KEY,
66 values(NULL, 'libhello:script', '/localhost@rpl:linux/0-1-1', '1#x86');
68 values(NULL, 'libhello:user', '/localhost@rpl:linux/0-1-1', '1#x86');
70 values(NULL, 'libhello:runtime', '/localhost@rpl:linux/0-1-1', '1#x86');
74 # Run the query with an index
78 select row, pinned from tlList, Instances, Versions, Flavors
80 Instances.troveName = tlList.name
81 and Versions.version = tlList.version
82 and Instances.versionId = Versions.versionId
83 and ( Flavors.flavor = tlList.flavor or Flavors.flavor is NULL
84 and tlList.flavor = '')
85 and Instances.flavorId = Flavors.flavorId
90 # Create a indices, analyze and rerun the query.
91 # Verify that the results are the same
95 CREATE INDEX InstancesNameIdx ON Instances(troveName);
96 CREATE UNIQUE INDEX InstancesIdx
97 ON Instances(troveName, versionId, flavorId);
99 select row, pinned from tlList, Instances, Versions, Flavors
101 Instances.troveName = tlList.name
102 and Versions.version = tlList.version
103 and Instances.versionId = Versions.versionId
104 and ( Flavors.flavor = tlList.flavor or Flavors.flavor is NULL
105 and tlList.flavor = '')
106 and Instances.flavorId = Flavors.flavorId