xref: /sqlite-3.40.0/test/transitive1.test (revision 3768f175)
163db0392Sdrh# 2013 April 17
263db0392Sdrh#
363db0392Sdrh# The author disclaims copyright to this source code.  In place of
463db0392Sdrh# a legal notice, here is a blessing:
563db0392Sdrh#
663db0392Sdrh#    May you do good and not evil.
763db0392Sdrh#    May you find forgiveness for yourself and forgive others.
863db0392Sdrh#    May you share freely, never taking more than you give.
963db0392Sdrh#
1063db0392Sdrh#*************************************************************************
1163db0392Sdrh# This file implements regression tests for SQLite library.  The
1263db0392Sdrh# focus of this script is testing of transitive WHERE clause constraints
1363db0392Sdrh#
1463db0392Sdrh
1563db0392Sdrhset testdir [file dirname $argv0]
1663db0392Sdrhsource $testdir/tester.tcl
1763db0392Sdrh
1863db0392Sdrhdo_execsql_test transitive1-100 {
1963db0392Sdrh  CREATE TABLE t1(a TEXT, b TEXT, c TEXT COLLATE NOCASE);
2063db0392Sdrh  INSERT INTO t1 VALUES('abc','abc','Abc');
2163db0392Sdrh  INSERT INTO t1 VALUES('def','def','def');
2263db0392Sdrh  INSERT INTO t1 VALUES('ghi','ghi','GHI');
2363db0392Sdrh  CREATE INDEX t1a1 ON t1(a);
2463db0392Sdrh  CREATE INDEX t1a2 ON t1(a COLLATE nocase);
2563db0392Sdrh
2663db0392Sdrh  SELECT * FROM t1 WHERE a=b AND c=b AND c='DEF';
2763db0392Sdrh} {def def def}
2863db0392Sdrhdo_execsql_test transitive1-110 {
2963db0392Sdrh  SELECT * FROM t1 WHERE a=b AND c=b AND c>='DEF' ORDER BY +a;
3063db0392Sdrh} {def def def ghi ghi GHI}
3163db0392Sdrhdo_execsql_test transitive1-120 {
3263db0392Sdrh  SELECT * FROM t1 WHERE a=b AND c=b AND c<='DEF' ORDER BY +a;
3363db0392Sdrh} {abc abc Abc def def def}
3463db0392Sdrh
3563db0392Sdrhdo_execsql_test transitive1-200 {
3663db0392Sdrh  CREATE TABLE t2(a INTEGER, b INTEGER, c TEXT);
3763db0392Sdrh  INSERT INTO t2 VALUES(100,100,100);
3863db0392Sdrh  INSERT INTO t2 VALUES(20,20,20);
3963db0392Sdrh  INSERT INTO t2 VALUES(3,3,3);
4063db0392Sdrh
4163db0392Sdrh  SELECT * FROM t2 WHERE a=b AND c=b AND c=20;
4263db0392Sdrh} {20 20 20}
4363db0392Sdrhdo_execsql_test transitive1-210 {
4463db0392Sdrh  SELECT * FROM t2 WHERE a=b AND c=b AND c>=20 ORDER BY +a;
4563db0392Sdrh} {3 3 3 20 20 20}
4663db0392Sdrhdo_execsql_test transitive1-220 {
4763db0392Sdrh  SELECT * FROM t2 WHERE a=b AND c=b AND c<=20 ORDER BY +a;
4863db0392Sdrh} {20 20 20 100 100 100}
4963db0392Sdrh
50b5246e51Sdrh# Test cases for ticket [[d805526eae253103] 2013-07-08
51b5246e51Sdrh# "Incorrect join result or assertion fault due to transitive constraints"
52b5246e51Sdrh#
53b5246e51Sdrhdo_execsql_test transitive1-300 {
54b5246e51Sdrh  CREATE TABLE t301(w INTEGER PRIMARY KEY, x);
55b5246e51Sdrh  CREATE TABLE t302(y INTEGER UNIQUE, z);
56b5246e51Sdrh  INSERT INTO t301 VALUES(1,2),(3,4),(5,6);
57b5246e51Sdrh  INSERT INTO t302 VALUES(1,3),(3,6),(5,7);
58b5246e51Sdrh  SELECT *
59b5246e51Sdrh    FROM t301 CROSS JOIN t302
60b5246e51Sdrh   WHERE w=y AND y IS NOT NULL
61b5246e51Sdrh   ORDER BY +w;
62b5246e51Sdrh} {1 2 1 3 3 4 3 6 5 6 5 7}
63b5246e51Sdrhdo_execsql_test transitive1-301 {
64b5246e51Sdrh  SELECT *
65b5246e51Sdrh    FROM t301 CROSS JOIN t302
66b5246e51Sdrh   WHERE w=y AND y IS NOT NULL
67b5246e51Sdrh   ORDER BY w;
68b5246e51Sdrh} {1 2 1 3 3 4 3 6 5 6 5 7}
695d8806e0Sdrhdo_execsql_test transitive1-302 {
705d8806e0Sdrh  SELECT *
715d8806e0Sdrh    FROM t301 CROSS JOIN t302
725d8806e0Sdrh   WHERE w IS y AND y IS NOT NULL
735d8806e0Sdrh   ORDER BY w;
745d8806e0Sdrh} {1 2 1 3 3 4 3 6 5 6 5 7}
75b5246e51Sdrhdo_execsql_test transitive1-310 {
76b5246e51Sdrh  SELECT *
77b5246e51Sdrh    FROM t301 CROSS JOIN t302 ON w=y
78b5246e51Sdrh   WHERE y>1
79b5246e51Sdrh   ORDER BY +w
80b5246e51Sdrh} {3 4 3 6 5 6 5 7}
81b5246e51Sdrhdo_execsql_test transitive1-311 {
82b5246e51Sdrh  SELECT *
83b5246e51Sdrh    FROM t301 CROSS JOIN t302 ON w=y
84b5246e51Sdrh   WHERE y>1
85b5246e51Sdrh   ORDER BY w
86b5246e51Sdrh} {3 4 3 6 5 6 5 7}
87b5246e51Sdrhdo_execsql_test transitive1-312 {
88b5246e51Sdrh  SELECT *
89b5246e51Sdrh    FROM t301 CROSS JOIN t302 ON w=y
90b5246e51Sdrh   WHERE y>1
91b5246e51Sdrh   ORDER BY w DESC
92b5246e51Sdrh} {5 6 5 7 3 4 3 6}
93b5246e51Sdrhdo_execsql_test transitive1-320 {
94b5246e51Sdrh  SELECT *
95b5246e51Sdrh    FROM t301 CROSS JOIN t302 ON w=y
96b5246e51Sdrh   WHERE y BETWEEN 2 AND 4;
97b5246e51Sdrh} {3 4 3 6}
98b5246e51Sdrhdo_execsql_test transitive1-331 {
99b5246e51Sdrh  SELECT *
100b5246e51Sdrh    FROM t301 CROSS JOIN t302 ON w=y
101b5246e51Sdrh   WHERE y BETWEEN 1 AND 4
102b5246e51Sdrh   ORDER BY w;
103b5246e51Sdrh} {1 2 1 3 3 4 3 6}
104b5246e51Sdrhdo_execsql_test transitive1-332 {
105b5246e51Sdrh  SELECT *
106b5246e51Sdrh    FROM t301 CROSS JOIN t302 ON w=y
107b5246e51Sdrh   WHERE y BETWEEN 1 AND 4
108b5246e51Sdrh   ORDER BY w DESC;
109b5246e51Sdrh} {3 4 3 6 1 2 1 3}
110b5246e51Sdrh
11170a0222fSdrh# Ticket [c620261b5b5dc] circa 2013-10-28.
11270a0222fSdrh# Make sure constraints are not used with LEFT JOINs.
11370a0222fSdrh#
11470a0222fSdrh# The next case is from the ticket report.  It outputs no rows in 3.8.1
11570a0222fSdrh# prior to the bug-fix.
11670a0222fSdrh#
11770a0222fSdrhdo_execsql_test transitive1-400 {
11870a0222fSdrh  CREATE TABLE t401(a);
11970a0222fSdrh  CREATE TABLE t402(b);
12070a0222fSdrh  CREATE TABLE t403(c INTEGER PRIMARY KEY);
12170a0222fSdrh  INSERT INTO t401 VALUES(1);
12270a0222fSdrh  INSERT INTO t403 VALUES(1);
12370a0222fSdrh  SELECT '1-row' FROM t401 LEFT JOIN t402 ON b=a JOIN t403 ON c=a;
12470a0222fSdrh} {1-row}
1255d8806e0Sdrhdo_execsql_test transitive1-401 {
1265d8806e0Sdrh  SELECT '1-row' FROM t401 LEFT JOIN t402 ON b IS a JOIN t403 ON c=a;
1275d8806e0Sdrh} {1-row}
1285d8806e0Sdrhdo_execsql_test transitive1-402 {
1295d8806e0Sdrh  SELECT '1-row' FROM t401 LEFT JOIN t402 ON b=a JOIN t403 ON c IS a;
1305d8806e0Sdrh} {1-row}
1315d8806e0Sdrhdo_execsql_test transitive1-403 {
1325d8806e0Sdrh  SELECT '1-row' FROM t401 LEFT JOIN t402 ON b IS a JOIN t403 ON c IS a;
1335d8806e0Sdrh} {1-row}
1345d8806e0Sdrh
13570a0222fSdrh
13670a0222fSdrh# The following is a script distilled from the XBMC project where the
13770a0222fSdrh# bug was originally encountered.  The correct answer is a single row
13870a0222fSdrh# of output.  Before the bug was fixed, zero rows were generated.
13970a0222fSdrh#
14070a0222fSdrhdo_execsql_test transitive1-410 {
14170a0222fSdrh  CREATE TABLE bookmark ( idBookmark integer primary key, idFile integer, timeInSeconds double, totalTimeInSeconds double, thumbNailImage text, player text, playerState text, type integer);
14270a0222fSdrh  CREATE TABLE path ( idPath integer primary key, strPath text, strContent text, strScraper text, strHash text, scanRecursive integer, useFolderNames bool, strSettings text, noUpdate bool, exclude bool, dateAdded text);
14370a0222fSdrh  INSERT INTO "path" VALUES(1,'/tmp/tvshows/','tvshows','metadata.tvdb.com','989B1CE5680A14F5F86123F751169B49',0,0,'<settings><setting id="absolutenumber" value="false" /><setting id="dvdorder" value="false" /><setting id="fanart" value="true" /><setting id="language" value="en" /></settings>',0,0,NULL);
14470a0222fSdrh  INSERT INTO "path" VALUES(2,'/tmp/tvshows/The.Big.Bang.Theory/','','','85E1DAAB2F5FF6EAE8AEDF1B5C882D1E',NULL,NULL,NULL,NULL,NULL,'2013-10-23 18:58:43');
14570a0222fSdrh  CREATE TABLE files ( idFile integer primary key, idPath integer, strFilename text, playCount integer, lastPlayed text, dateAdded text);
14670a0222fSdrh  INSERT INTO "files" VALUES(1,2,'The.Big.Bang.Theory.S01E01.WEB-DL.AAC2.0.H264.mkv',NULL,NULL,'2013-10-23 18:57:36');
14770a0222fSdrh  CREATE TABLE tvshow ( idShow integer primary key,c00 text,c01 text,c02 text,c03 text,c04 text,c05 text,c06 text,c07 text,c08 text,c09 text,c10 text,c11 text,c12 text,c13 text,c14 text,c15 text,c16 text,c17 text,c18 text,c19 text,c20 text,c21 text,c22 text,c23 text);
14870a0222fSdrh  INSERT INTO "tvshow" VALUES(1,'The Big Bang Theory','Leonard Hofstadter and Sheldon Cooper are brilliant physicists, the kind of "beautiful minds" that understand how the universe works. But none of that genius helps them interact with people, especially women. All this begins to change when a free-spirited beauty named Penny moves in next door. Sheldon, Leonard''s roommate, is quite content spending his nights playing Klingon Boggle with their socially dysfunctional friends, fellow CalTech scientists Howard Wolowitz and Raj Koothrappali. However, Leonard sees in Penny a whole new universe of possibilities... including love.','','','9.200000','2007-09-24','<thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g13.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g23.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g18.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g17.jpg</thumb><thumb aspect="banner">http://
14970a0222fSdrh  thetvdb.com/banners/graphical/80379-g6.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g5.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g2.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g11.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g12.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g19.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g3.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g4.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g15.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g22.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g7.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g10.jpg</thumb><thumb
15070a0222fSdrh  aspect="banner">http://thetvdb.com/banners/graphical/80379-g24.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g8.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g9.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g14.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g16.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/graphical/80379-g21.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/text/80379-4.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/text/80379-2.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/text/80379-3.jpg</thumb><thumb aspect="banner">http://thetvdb.com/banners/text/80379-5.jpg</thumb><thumb aspect="poster" type="season" season="6">http://thetvdb.com/banners/seasons/80379-6-8.jpg</thumb><thumb aspect="poster" type="season" season="0">http://thetvdb.com/banners/seasons/80379-0-4.jpg</thumb><thumb aspect="poster" type="season"
15170a0222fSdrh  season="1">http://thetvdb.com/banners/seasons/80379-1-12.jpg</thumb><thumb aspect="poster" type="season" season="3">http://thetvdb.com/banners/seasons/80379-3-9.jpg</thumb><thumb aspect="poster" type="season" season="2">http://thetvdb.com/banners/seasons/80379-2-11.jpg</thumb><thumb aspect="poster" type="season" season="5">http://thetvdb.com/banners/seasons/80379-5-9.jpg</thumb><thumb aspect="poster" type="season" season="4">http://thetvdb.com/banners/seasons/80379-4-8.jpg</thumb><thumb aspect="poster" type="season" season="7">http://thetvdb.com/banners/seasons/80379-7-3.jpg</thumb><thumb aspect="poster" type="season" season="3">http://thetvdb.com/banners/seasons/80379-3-4.jpg</thumb><thumb aspect="poster" type="season" season="4">http://thetvdb.com/banners/seasons/80379-4-5.jpg</thumb><thumb aspect="poster" type="season" season="2">http://thetvdb.com/banners/seasons/80379-2-9.jpg</thumb><thumb aspect="poster" type="season" season="0">http://thetvdb.com/banners/seasons/80379-0-2.jpg</thumb><thumb aspect="
15270a0222fSdrh  poster" type="season" season="6">http://thetvdb.com/banners/seasons/80379-6-6.jpg</thumb><thumb aspect="poster" type="season" season="4">http://thetvdb.com/banners/seasons/80379-4-4.jpg</thumb><thumb aspect="poster" type="season" season="6">http://thetvdb.com/banners/seasons/80379-6-2.jpg</thumb><thumb aspect="poster" type="season" season="1">http://thetvdb.com/banners/seasons/80379-1-9.jpg</thumb><thumb aspect="poster" type="season" season="6">http://thetvdb.com/banners/seasons/80379-6-4.jpg</thumb><thumb aspect="poster" type="season" season="1">http://thetvdb.com/banners/seasons/80379-1.jpg</thumb><thumb aspect="poster" type="season" season="3">http://thetvdb.com/banners/seasons/80379-3.jpg</thumb><thumb aspect="poster" type="season" season="4">http://thetvdb.com/banners/seasons/80379-4-2.jpg</thumb><thumb aspect="poster" type="season" season="5">http://thetvdb.com/banners/seasons/80379-5-7.jpg</thumb><thumb aspect="poster" type="season" season="2">http://thetvdb.com/banners/seasons/80379-2-10.jpg</
15370a0222fSdrh  thumb><thumb aspect="poster" type="season" season="6">http://thetvdb.com/banners/seasons/80379-6-5.jpg</thumb><thumb aspect="poster" type="season" season="1">http://thetvdb.com/banners/seasons/80379-1-5.jpg</thumb><thumb aspect="poster" type="season" season="5">http://thetvdb.com/banners/seasons/80379-5-4.jpg</thumb><thumb aspect="poster" type="season" season="4">http://thetvdb.com/banners/seasons/80379-4.jpg</thumb><thumb aspect="poster" type="season" season="6">http://thetvdb.com/banners/seasons/80379-6-3.jpg</thumb><thumb aspect="poster" type="season" season="5">http://thetvdb.com/banners/seasons/80379-5.jpg</thumb><thumb aspect="poster" type="season" season="3">http://thetvdb.com/banners/seasons/80379-3-6.jpg</thumb><thumb aspect="poster" type="season" season="2">http://thetvdb.com/banners/seasons/80379-2.jpg</thumb><thumb aspect="poster" type="season" season="7">http://thetvdb.com/banners/seasons/80379-7.jpg</thumb><thumb aspect="poster" type="season" season="1">http://thetvdb.com/banners/seasons/80379-
15470a0222fSdrh  1-7.jpg</thumb><thumb aspect="poster" type="season" season="5">http://thetvdb.com/banners/seasons/80379-5-2.jpg</thumb><thumb aspect="poster" type="season" season="5">http://thetvdb.com/banners/seasons/80379-5-3.jpg</thumb><thumb aspect="poster" type="season" season="7">http://thetvdb.com/banners/seasons/80379-7-2.jpg</thumb><thumb aspect="poster" type="season" season="1">http://thetvdb.com/banners/seasons/80379-1-2.jpg</thumb><thumb aspect="poster" type="season" season="2">http://thetvdb.com/banners/seasons/80379-2-5.jpg</thumb><thumb aspect="poster" type="season" season="4">http://thetvdb.com/banners/seasons/80379-4-3.jpg</thumb><thumb aspect="poster" type="season" season="5">http://thetvdb.com/banners/seasons/80379-5-5.jpg</thumb><thumb aspect="poster" type="season" season="0">http://thetvdb.com/banners/seasons/80379-0.jpg</thumb><thumb aspect="poster" type="season" season="3">http://thetvdb.com/banners/seasons/80379-3-5.jpg</thumb><thumb aspect="poster" type="season" season="1">http://thetvdb.com/banners/
15570a0222fSdrh  seasons/80379-1-6.jpg</thumb><thumb aspect="poster" type="season" season="2">http://thetvdb.com/banners/seasons/80379-2-3.jpg</thumb><thumb aspect="poster" type="season" season="2">http://thetvdb.com/banners/seasons/80379-2-8.jpg</thumb><thumb aspect="poster" type="season" season="6">http://thetvdb.com/banners/seasons/80379-6-7.jpg</thumb><thumb aspect="poster" type="season" season="5">http://thetvdb.com/banners/seasons/80379-5-8.jpg</thumb><thumb aspect="poster" type="season" season="4">http://thetvdb.com/banners/seasons/80379-4-7.jpg</thumb><thumb aspect="poster" type="season" season="2">http://thetvdb.com/banners/seasons/80379-2-6.jpg</thumb><thumb aspect="poster" type="season" season="3">http://thetvdb.com/banners/seasons/80379-3-8.jpg</thumb><thumb aspect="poster" type="season" season="1">http://thetvdb.com/banners/seasons/80379-1-11.jpg</thumb><thumb aspect="poster" type="season" season="1">http://thetvdb.com/banners/seasons/80379-1-10.jpg</thumb><thumb aspect="poster" type="season" season="1">http://
15670a0222fSdrh  thetvdb.com/banners/seasons/80379-1-8.jpg</thumb><thumb aspect="poster" type="season" season="3">http://thetvdb.com/banners/seasons/80379-3-7.jpg</thumb><thumb aspect="poster" type="season" season="2">http://thetvdb.com/banners/seasons/80379-2-4.jpg</thumb><thumb aspect="poster" type="season" season="1">http://thetvdb.com/banners/seasons/80379-1-3.jpg</thumb><thumb aspect="poster" type="season" season="1">http://thetvdb.com/banners/seasons/80379-1-4.jpg</thumb><thumb aspect="poster" type="season" season="3">http://thetvdb.com/banners/seasons/80379-3-3.jpg</thumb><thumb aspect="poster" type="season" season="2">http://thetvdb.com/banners/seasons/80379-2-7.jpg</thumb><thumb aspect="poster" type="season" season="6">http://thetvdb.com/banners/seasons/80379-6.jpg</thumb><thumb aspect="poster" type="season" season="2">http://thetvdb.com/banners/seasons/80379-2-2.jpg</thumb><thumb aspect="poster" type="season" season="5">http://thetvdb.com/banners/seasons/80379-5-6.jpg</thumb><thumb aspect="poster" type="season"
15770a0222fSdrh  season="3">http://thetvdb.com/banners/seasons/80379-3-2.jpg</thumb><thumb aspect="poster" type="season" season="4">http://thetvdb.com/banners/seasons/80379-4-6.jpg</thumb><thumb aspect="banner" type="season" season="5">http://thetvdb.com/banners/seasonswide/80379-5.jpg</thumb><thumb aspect="banner" type="season" season="3">http://thetvdb.com/banners/seasonswide/80379-3-2.jpg</thumb><thumb aspect="banner" type="season" season="1">http://thetvdb.com/banners/seasonswide/80379-1-2.jpg</thumb><thumb aspect="banner" type="season" season="2">http://thetvdb.com/banners/seasonswide/80379-2-2.jpg</thumb><thumb aspect="banner" type="season" season="4">http://thetvdb.com/banners/seasonswide/80379-4-2.jpg</thumb><thumb aspect="banner" type="season" season="0">http://thetvdb.com/banners/seasonswide/80379-0.jpg</thumb><thumb aspect="banner" type="season" season="0">http://thetvdb.com/banners/seasonswide/80379-0-2.jpg</thumb><thumb aspect="banner" type="season" season="1">http://thetvdb.com/banners/seasonswide/80379-1.jpg</
15870a0222fSdrh  thumb><thumb aspect="banner" type="season" season="2">http://thetvdb.com/banners/seasonswide/80379-2.jpg</thumb><thumb aspect="banner" type="season" season="4">http://thetvdb.com/banners/seasonswide/80379-4.jpg</thumb><thumb aspect="banner" type="season" season="3">http://thetvdb.com/banners/seasonswide/80379-3.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-22.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-18.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-13.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-10.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-16.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-1.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-9.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-2.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-19.jpg</
15970a0222fSdrh  thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-8.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-4.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-20.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-23.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-7.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-3.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-12.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-11.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-15.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-21.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-14.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-17.jpg</thumb><thumb aspect="poster">http://thetvdb.com/banners/posters/80379-6.jpg</thumb><thumb
16070a0222fSdrh  aspect="poster">http://thetvdb.com/banners/posters/80379-5.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-22.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-18.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-13.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-10.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-16.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-1.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-9.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-2.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-19.jpg</thumb><thumb aspect="
16170a0222fSdrh  poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-8.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-4.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-20.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-23.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-7.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-3.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-12.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-11.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-15.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-21.jpg</
16270a0222fSdrh  thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-14.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-17.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-6.jpg</thumb><thumb aspect="poster" type="season" season="-1">http://thetvdb.com/banners/posters/80379-5.jpg</thumb>','','Comedy','','<episodeguide><url cache="80379-en.xml">http://thetvdb.com/api/1D62F2F90030C444/series/80379/all/en.zip</url></episodeguide>','<fanart url="http://thetvdb.com/banners/"><thumb dim="1920x1080" colors="|192,185,169|19,20,25|57,70,89|" preview="_cache/fanart/original/80379-2.jpg">fanart/original/80379-2.jpg</thumb><thumb dim="1920x1080" colors="|94,28,16|194,18,38|0,0,8|" preview="_cache/fanart/original/80379-34.jpg">fanart/original/80379-34.jpg</thumb><thumb dim="1280x720" colors="|254,157,210|11,12,7|191,152,111|" preview="_cache/fanart/original/80379-4.jpg">fanart/original/80379-
16370a0222fSdrh  4.jpg</thumb><thumb dim="1920x1080" colors="" preview="_cache/fanart/original/80379-42.jpg">fanart/original/80379-42.jpg</thumb><thumb dim="1920x1080" colors="|236,187,155|136,136,128|254,254,252|" preview="_cache/fanart/original/80379-37.jpg">fanart/original/80379-37.jpg</thumb><thumb dim="1920x1080" colors="|112,102,152|116,109,116|235,152,146|" preview="_cache/fanart/original/80379-14.jpg">fanart/original/80379-14.jpg</thumb><thumb dim="1920x1080" colors="|150,158,161|174,75,121|150,98,58|" preview="_cache/fanart/original/80379-16.jpg">fanart/original/80379-16.jpg</thumb><thumb dim="1280x720" colors="|224,200,176|11,1,28|164,96,0|" preview="_cache/fanart/original/80379-1.jpg">fanart/original/80379-1.jpg</thumb><thumb dim="1920x1080" colors="" preview="_cache/fanart/original/80379-35.jpg">fanart/original/80379-35.jpg</thumb><thumb dim="1920x1080" colors="" preview="_cache/fanart/original/80379-40.jpg">fanart/original/80379-40.jpg</thumb><thumb dim="1920x1080" colors="|255,255,255|30,19,13|155,112,70|"
16470a0222fSdrh  preview="_cache/fanart/original/80379-31.jpg">fanart/original/80379-31.jpg</thumb><thumb dim="1920x1080" colors="|241,195,172|84,54,106|254,221,206|" preview="_cache/fanart/original/80379-29.jpg">fanart/original/80379-29.jpg</thumb><thumb dim="1280x720" colors="|197,167,175|219,29,39|244,208,192|" preview="_cache/fanart/original/80379-11.jpg">fanart/original/80379-11.jpg</thumb><thumb dim="1280x720" colors="|195,129,97|244,192,168|219,148,118|" preview="_cache/fanart/original/80379-24.jpg">fanart/original/80379-24.jpg</thumb><thumb dim="1920x1080" colors="|14,10,11|255,255,255|175,167,164|" preview="_cache/fanart/original/80379-30.jpg">fanart/original/80379-30.jpg</thumb><thumb dim="1920x1080" colors="" preview="_cache/fanart/original/80379-19.jpg">fanart/original/80379-19.jpg</thumb><thumb dim="1920x1080" colors="|246,199,69|98,55,38|161,127,82|" preview="_cache/fanart/original/80379-9.jpg">fanart/original/80379-9.jpg</thumb><thumb dim="1280x720" colors="|129,22,14|48,50,39|223,182,64|" preview="_cache/
16570a0222fSdrh  fanart/original/80379-13.jpg">fanart/original/80379-13.jpg</thumb><thumb dim="1920x1080" colors="" preview="_cache/fanart/original/80379-45.jpg">fanart/original/80379-45.jpg</thumb><thumb dim="1920x1080" colors="" preview="_cache/fanart/original/80379-33.jpg">fanart/original/80379-33.jpg</thumb><thumb dim="1280x720" colors="|103,77,60|224,180,153|129,100,84|" preview="_cache/fanart/original/80379-10.jpg">fanart/original/80379-10.jpg</thumb><thumb dim="1920x1080" colors="" preview="_cache/fanart/original/80379-23.jpg">fanart/original/80379-23.jpg</thumb><thumb dim="1280x720" colors="|219,29,39|0,4,10|88,117,135|" preview="_cache/fanart/original/80379-12.jpg">fanart/original/80379-12.jpg</thumb><thumb dim="1920x1080" colors="|226,209,165|51,18,9|89,54,24|" preview="_cache/fanart/original/80379-5.jpg">fanart/original/80379-5.jpg</thumb><thumb dim="1280x720" colors="" preview="_cache/fanart/original/80379-26.jpg">fanart/original/80379-26.jpg</thumb><thumb dim="1280x720" colors="|249,251,229|126,47,53|251,226,
16670a0222fSdrh  107|" preview="_cache/fanart/original/80379-27.jpg">fanart/original/80379-27.jpg</thumb><thumb dim="1920x1080" colors="|233,218,65|30,27,46|173,53,18|" preview="_cache/fanart/original/80379-32.jpg">fanart/original/80379-32.jpg</thumb><thumb dim="1280x720" colors="|248,248,248|64,54,78|188,193,196|" preview="_cache/fanart/original/80379-3.jpg">fanart/original/80379-3.jpg</thumb><thumb dim="1280x720" colors="" preview="_cache/fanart/original/80379-25.jpg">fanart/original/80379-25.jpg</thumb><thumb dim="1280x720" colors="|159,150,133|59,39,32|168,147,104|" preview="_cache/fanart/original/80379-7.jpg">fanart/original/80379-7.jpg</thumb><thumb dim="1920x1080" colors="|221,191,157|11,7,6|237,146,102|" preview="_cache/fanart/original/80379-21.jpg">fanart/original/80379-21.jpg</thumb><thumb dim="1280x720" colors="" preview="_cache/fanart/original/80379-28.jpg">fanart/original/80379-28.jpg</thumb><thumb dim="1920x1080" colors="" preview="_cache/fanart/original/80379-36.jpg">fanart/original/80379-36.jpg</thumb><thumb
16770a0222fSdrh  dim="1920x1080" colors="|253,237,186|33,25,22|245,144,38|" preview="_cache/fanart/original/80379-38.jpg">fanart/original/80379-38.jpg</thumb><thumb dim="1920x1080" colors="|174,111,68|243,115,50|252,226,45|" preview="_cache/fanart/original/80379-20.jpg">fanart/original/80379-20.jpg</thumb><thumb dim="1920x1080" colors="|63,56,123|87,59,47|63,56,123|" preview="_cache/fanart/original/80379-17.jpg">fanart/original/80379-17.jpg</thumb><thumb dim="1920x1080" colors="" preview="_cache/fanart/original/80379-43.jpg">fanart/original/80379-43.jpg</thumb><thumb dim="1280x720" colors="|69,68,161|142,118,142|222,191,137|" preview="_cache/fanart/original/80379-22.jpg">fanart/original/80379-22.jpg</thumb><thumb dim="1280x720" colors="|1,108,206|242,209,192|250,197,163|" preview="_cache/fanart/original/80379-15.jpg">fanart/original/80379-15.jpg</thumb><thumb dim="1280x720" colors="|239,229,237|0,0,0|167,136,115|" preview="_cache/fanart/original/80379-18.jpg">fanart/original/80379-18.jpg</thumb><thumb dim="1280x720" colors=""
16870a0222fSdrh  preview="_cache/fanart/original/80379-6.jpg">fanart/original/80379-6.jpg</thumb><thumb dim="1280x720" colors="" preview="_cache/fanart/original/80379-8.jpg">fanart/original/80379-8.jpg</thumb><thumb dim="1280x720" colors="" preview="_cache/fanart/original/80379-41.jpg">fanart/original/80379-41.jpg</thumb><thumb dim="1920x1080" colors="" preview="_cache/fanart/original/80379-44.jpg">fanart/original/80379-44.jpg</thumb><thumb dim="1280x720" colors="" preview="_cache/fanart/original/80379-39.jpg">fanart/original/80379-39.jpg</thumb></fanart>','80379','TV-PG','CBS','','/tmp/tvshows/The.Big.Bang.Theory/','1',NULL,NULL,NULL,NULL,NULL,NULL);
16970a0222fSdrh  CREATE TABLE episode ( idEpisode integer primary key, idFile integer,c00 text,c01 text,c02 text,c03 text,c04 text,c05 text,c06 text,c07 text,c08 text,c09 text,c10 text,c11 text,c12 varchar(24),c13 varchar(24),c14 text,c15 text,c16 text,c17 varchar(24),c18 text,c19 text,c20 text,c21 text,c22 text,c23 text, idShow integer);
17070a0222fSdrh  INSERT INTO "episode" VALUES(1,1,'Pilot','Brilliant physicist roommates Leonard and Sheldon meet their new neighbor Penny, who begins showing them that as much as they know about science, they know little about actual living.','','7.700000','Chuck Lorre / Bill Prady','2007-09-24','<thumb>http://thetvdb.com/banners/episodes/80379/332484.jpg</thumb>','',NULL,'1800','James Burrows','','1','1','','-1','-1','-1','/tmp/tvshows/The.Big.Bang.Theory/The.Big.Bang.Theory.S01E01.WEB-DL.AAC2.0.H264.mkv','2','332484',NULL,NULL,NULL,1);
17170a0222fSdrh  CREATE TABLE tvshowlinkpath (idShow integer, idPath integer);
17270a0222fSdrh  INSERT INTO "tvshowlinkpath" VALUES(1,2);
17370a0222fSdrh  CREATE TABLE seasons ( idSeason integer primary key, idShow integer, season integer);
17470a0222fSdrh  INSERT INTO "seasons" VALUES(1,1,-1);
17570a0222fSdrh  INSERT INTO "seasons" VALUES(2,1,0);
17670a0222fSdrh  INSERT INTO "seasons" VALUES(3,1,1);
17770a0222fSdrh  INSERT INTO "seasons" VALUES(4,1,2);
17870a0222fSdrh  INSERT INTO "seasons" VALUES(5,1,3);
17970a0222fSdrh  INSERT INTO "seasons" VALUES(6,1,4);
18070a0222fSdrh  INSERT INTO "seasons" VALUES(7,1,5);
18170a0222fSdrh  INSERT INTO "seasons" VALUES(8,1,6);
18270a0222fSdrh  INSERT INTO "seasons" VALUES(9,1,7);
18370a0222fSdrh  CREATE TABLE art(art_id INTEGER PRIMARY KEY, media_id INTEGER, media_type TEXT, type TEXT, url TEXT);
18470a0222fSdrh  INSERT INTO "art" VALUES(1,1,'actor','thumb','http://thetvdb.com/banners/actors/73597.jpg');
18570a0222fSdrh  INSERT INTO "art" VALUES(2,2,'actor','thumb','http://thetvdb.com/banners/actors/73596.jpg');
18670a0222fSdrh  INSERT INTO "art" VALUES(3,3,'actor','thumb','http://thetvdb.com/banners/actors/73595.jpg');
18770a0222fSdrh  INSERT INTO "art" VALUES(4,4,'actor','thumb','http://thetvdb.com/banners/actors/73599.jpg');
18870a0222fSdrh  INSERT INTO "art" VALUES(5,5,'actor','thumb','http://thetvdb.com/banners/actors/73598.jpg');
18970a0222fSdrh  INSERT INTO "art" VALUES(6,6,'actor','thumb','http://thetvdb.com/banners/actors/283158.jpg');
19070a0222fSdrh  INSERT INTO "art" VALUES(7,7,'actor','thumb','http://thetvdb.com/banners/actors/283157.jpg');
19170a0222fSdrh  INSERT INTO "art" VALUES(8,8,'actor','thumb','http://thetvdb.com/banners/actors/91271.jpg');
19270a0222fSdrh  INSERT INTO "art" VALUES(9,9,'actor','thumb','http://thetvdb.com/banners/actors/294178.jpg');
19370a0222fSdrh  INSERT INTO "art" VALUES(10,10,'actor','thumb','http://thetvdb.com/banners/actors/283159.jpg');
19470a0222fSdrh  INSERT INTO "art" VALUES(11,1,'tvshow','banner','http://thetvdb.com/banners/graphical/80379-g13.jpg');
19570a0222fSdrh  INSERT INTO "art" VALUES(12,1,'tvshow','fanart','http://thetvdb.com/banners/fanart/original/80379-2.jpg');
19670a0222fSdrh  INSERT INTO "art" VALUES(13,1,'tvshow','poster','http://thetvdb.com/banners/posters/80379-22.jpg');
19770a0222fSdrh  INSERT INTO "art" VALUES(14,1,'season','poster','http://thetvdb.com/banners/posters/80379-22.jpg');
19870a0222fSdrh  INSERT INTO "art" VALUES(15,2,'season','banner','http://thetvdb.com/banners/seasonswide/80379-0.jpg');
19970a0222fSdrh  INSERT INTO "art" VALUES(16,2,'season','poster','http://thetvdb.com/banners/seasons/80379-0-4.jpg');
20070a0222fSdrh  INSERT INTO "art" VALUES(17,3,'season','banner','http://thetvdb.com/banners/seasonswide/80379-1-2.jpg');
20170a0222fSdrh  INSERT INTO "art" VALUES(18,3,'season','poster','http://thetvdb.com/banners/seasons/80379-1-12.jpg');
20270a0222fSdrh  INSERT INTO "art" VALUES(19,4,'season','banner','http://thetvdb.com/banners/seasonswide/80379-2-2.jpg');
20370a0222fSdrh  INSERT INTO "art" VALUES(20,4,'season','poster','http://thetvdb.com/banners/seasons/80379-2-11.jpg');
20470a0222fSdrh  INSERT INTO "art" VALUES(21,5,'season','banner','http://thetvdb.com/banners/seasonswide/80379-3-2.jpg');
20570a0222fSdrh  INSERT INTO "art" VALUES(22,5,'season','poster','http://thetvdb.com/banners/seasons/80379-3-9.jpg');
20670a0222fSdrh  INSERT INTO "art" VALUES(23,6,'season','banner','http://thetvdb.com/banners/seasonswide/80379-4-2.jpg');
20770a0222fSdrh  INSERT INTO "art" VALUES(24,6,'season','poster','http://thetvdb.com/banners/seasons/80379-4-8.jpg');
20870a0222fSdrh  INSERT INTO "art" VALUES(25,7,'season','banner','http://thetvdb.com/banners/seasonswide/80379-5.jpg');
20970a0222fSdrh  INSERT INTO "art" VALUES(26,7,'season','poster','http://thetvdb.com/banners/seasons/80379-5-9.jpg');
21070a0222fSdrh  INSERT INTO "art" VALUES(27,8,'season','poster','http://thetvdb.com/banners/seasons/80379-6-8.jpg');
21170a0222fSdrh  INSERT INTO "art" VALUES(28,9,'season','poster','http://thetvdb.com/banners/seasons/80379-7-3.jpg');
21270a0222fSdrh  INSERT INTO "art" VALUES(29,1,'episode','thumb','http://thetvdb.com/banners/episodes/80379/332484.jpg');
21370a0222fSdrh  CREATE INDEX ix_bookmark ON bookmark (idFile, type);
21470a0222fSdrh  CREATE INDEX ix_path ON path ( strPath );
21570a0222fSdrh  CREATE INDEX ix_files ON files ( idPath, strFilename );
21670a0222fSdrh  CREATE UNIQUE INDEX ix_episode_file_1 on episode (idEpisode, idFile);
21770a0222fSdrh  CREATE UNIQUE INDEX id_episode_file_2 on episode (idFile, idEpisode);
21870a0222fSdrh  CREATE INDEX ix_episode_season_episode on episode (c12, c13);
21970a0222fSdrh  CREATE INDEX ix_episode_bookmark on episode (c17);
22070a0222fSdrh  CREATE INDEX ix_episode_show1 on episode(idEpisode,idShow);
22170a0222fSdrh  CREATE INDEX ix_episode_show2 on episode(idShow,idEpisode);
22270a0222fSdrh  CREATE UNIQUE INDEX ix_tvshowlinkpath_1 ON tvshowlinkpath ( idShow, idPath );
22370a0222fSdrh  CREATE UNIQUE INDEX ix_tvshowlinkpath_2 ON tvshowlinkpath ( idPath, idShow );
22470a0222fSdrh  CREATE INDEX ixEpisodeBasePath ON episode ( c19 );
22570a0222fSdrh  CREATE INDEX ixTVShowBasePath on tvshow ( c17 );
22670a0222fSdrh  CREATE INDEX ix_seasons ON seasons (idShow, season);
22770a0222fSdrh  CREATE INDEX ix_art ON art(media_id, media_type, type);
22870a0222fSdrh  CREATE VIEW episodeview
22970a0222fSdrh  AS
23070a0222fSdrh    SELECT episode.*,
23170a0222fSdrh           files.strfilename           AS strFileName,
23270a0222fSdrh           path.strpath                AS strPath,
23370a0222fSdrh           files.playcount             AS playCount,
23470a0222fSdrh           files.lastplayed            AS lastPlayed,
23570a0222fSdrh           files.dateadded             AS dateAdded,
23670a0222fSdrh           tvshow.c00                  AS strTitle,
23770a0222fSdrh           tvshow.c14                  AS strStudio,
23870a0222fSdrh           tvshow.c05                  AS premiered,
23970a0222fSdrh           tvshow.c13                  AS mpaa,
24070a0222fSdrh           tvshow.c16                  AS strShowPath,
24170a0222fSdrh           bookmark.timeinseconds      AS resumeTimeInSeconds,
24270a0222fSdrh           bookmark.totaltimeinseconds AS totalTimeInSeconds,
24370a0222fSdrh           seasons.idseason            AS idSeason
24470a0222fSdrh    FROM   episode
24570a0222fSdrh           JOIN files
24670a0222fSdrh             ON files.idfile = episode.idfile
24770a0222fSdrh           JOIN tvshow
24870a0222fSdrh             ON tvshow.idshow = episode.idshow
24970a0222fSdrh           LEFT JOIN seasons
25070a0222fSdrh                  ON seasons.idshow = episode.idshow
25170a0222fSdrh                     AND seasons.season = episode.c12
25270a0222fSdrh           JOIN path
25370a0222fSdrh             ON files.idpath = path.idpath
25470a0222fSdrh           LEFT JOIN bookmark
25570a0222fSdrh                  ON bookmark.idfile = episode.idfile
25670a0222fSdrh                     AND bookmark.type = 1;
25770a0222fSdrh  CREATE VIEW tvshowview
25870a0222fSdrh  AS
25970a0222fSdrh    SELECT tvshow.*,
26070a0222fSdrh           path.strpath                              AS strPath,
26170a0222fSdrh           path.dateadded                            AS dateAdded,
26270a0222fSdrh           Max(files.lastplayed)                     AS lastPlayed,
26370a0222fSdrh           NULLIF(Count(episode.c12), 0)             AS totalCount,
26470a0222fSdrh           Count(files.playcount)                    AS watchedcount,
26570a0222fSdrh           NULLIF(Count(DISTINCT( episode.c12 )), 0) AS totalSeasons
26670a0222fSdrh    FROM   tvshow
26770a0222fSdrh           LEFT JOIN tvshowlinkpath
26870a0222fSdrh                  ON tvshowlinkpath.idshow = tvshow.idshow
26970a0222fSdrh           LEFT JOIN path
27070a0222fSdrh                  ON path.idpath = tvshowlinkpath.idpath
27170a0222fSdrh           LEFT JOIN episode
27270a0222fSdrh                  ON episode.idshow = tvshow.idshow
27370a0222fSdrh           LEFT JOIN files
27470a0222fSdrh                  ON files.idfile = episode.idfile
27570a0222fSdrh    GROUP  BY tvshow.idshow;
27670a0222fSdrh  SELECT
27770a0222fSdrh    episodeview.c12,
27870a0222fSdrh    path.strPath,
27970a0222fSdrh    tvshowview.c00,
28070a0222fSdrh    tvshowview.c01,
28170a0222fSdrh    tvshowview.c05,
28270a0222fSdrh    tvshowview.c08,
28370a0222fSdrh    tvshowview.c14,
28470a0222fSdrh    tvshowview.c13,
28570a0222fSdrh    seasons.idSeason,
28670a0222fSdrh    count(1),
28770a0222fSdrh    count(files.playCount)
28870a0222fSdrh  FROM episodeview
28970a0222fSdrh      JOIN tvshowview ON tvshowview.idShow = episodeview.idShow
29070a0222fSdrh      JOIN seasons ON (seasons.idShow = tvshowview.idShow
29170a0222fSdrh                       AND seasons.season = episodeview.c12)
29270a0222fSdrh      JOIN files ON files.idFile = episodeview.idFile
29370a0222fSdrh      JOIN tvshowlinkpath ON tvshowlinkpath.idShow = tvshowview.idShow
29470a0222fSdrh      JOIN path ON path.idPath = tvshowlinkpath.idPath
29570a0222fSdrh  WHERE tvshowview.idShow = 1
29670a0222fSdrh  GROUP BY episodeview.c12;
29770a0222fSdrh} {1 /tmp/tvshows/The.Big.Bang.Theory/ {The Big Bang Theory} {Leonard Hofstadter and Sheldon Cooper are brilliant physicists, the kind of "beautiful minds" that understand how the universe works. But none of that genius helps them interact with people, especially women. All this begins to change when a free-spirited beauty named Penny moves in next door. Sheldon, Leonard's roommate, is quite content spending his nights playing Klingon Boggle with their socially dysfunctional friends, fellow CalTech scientists Howard Wolowitz and Raj Koothrappali. However, Leonard sees in Penny a whole new universe of possibilities... including love.} 2007-09-24 Comedy CBS TV-PG 3 1 0}
29870a0222fSdrh
29969c15feeSdrh##############################################################################
30069c15feeSdrh# 2015-05-18.  Make sure transitive constraints are avoided when column
30169c15feeSdrh# affinities and collating sequences get in the way.
30269c15feeSdrh#
30369c15feeSdrhdb close
30469c15feeSdrhforcedelete test.db
30569c15feeSdrhsqlite3 db test.db
30669c15feeSdrhdo_execsql_test transitive1-500 {
30769c15feeSdrh  CREATE TABLE x(i INTEGER PRIMARY KEY, y TEXT);
30869c15feeSdrh  INSERT INTO x VALUES(10, '10');
30969c15feeSdrh  SELECT * FROM x WHERE x.y>='1' AND x.y<'2' AND x.i=x.y;
31069c15feeSdrh} {10 10}
31169c15feeSdrhdo_execsql_test transitive1-510 {
31269c15feeSdrh  CREATE TABLE t1(x TEXT);
31369c15feeSdrh  CREATE TABLE t2(y TEXT);
31469c15feeSdrh  INSERT INTO t1 VALUES('abc');
31569c15feeSdrh  INSERT INTO t2 VALUES('ABC');
31669c15feeSdrh  SELECT * FROM t1 CROSS JOIN t2 WHERE (x=y COLLATE nocase) AND y='ABC';
31769c15feeSdrh} {abc ABC}
31869c15feeSdrhdo_execsql_test transitive1-520 {
31969c15feeSdrh  CREATE TABLE t3(i INTEGER PRIMARY KEY, t TEXT);
32069c15feeSdrh  INSERT INTO t3 VALUES(10, '10');
32169c15feeSdrh  SELECT * FROM t3 WHERE i=t AND t = '10 ';
32269c15feeSdrh} {}
32369c15feeSdrhdo_execsql_test transitive1-530 {
32469c15feeSdrh  CREATE TABLE u1(x TEXT, y INTEGER, z TEXT);
32569c15feeSdrh  CREATE INDEX i1 ON u1(x);
32669c15feeSdrh  INSERT INTO u1 VALUES('00013', 13, '013');
32769c15feeSdrh  SELECT * FROM u1 WHERE x=y AND y=z AND z='013';
32869c15feeSdrh} {00013 13 013}
32969c15feeSdrhdo_execsql_test transitive1-540 {
33069c15feeSdrh  CREATE TABLE b1(x, y);
33169c15feeSdrh  INSERT INTO b1 VALUES('abc', 'ABC');
33269c15feeSdrh  CREATE INDEX b1x ON b1(x);
33369c15feeSdrh  SELECT * FROM b1 WHERE (x=y COLLATE nocase) AND y='ABC';
33469c15feeSdrh} {abc ABC}
33569c15feeSdrhdo_execsql_test transitive1-550 {
33669c15feeSdrh  CREATE TABLE c1(x, y COLLATE nocase, z);
33769c15feeSdrh  INSERT INTO c1 VALUES('ABC', 'ABC', 'abc');
33869c15feeSdrh  SELECT * FROM c1 WHERE x=y AND y=z AND z='abc';
33969c15feeSdrh} {ABC ABC abc}
34069c15feeSdrhdo_execsql_test transitive1-560 {
34169c15feeSdrh  CREATE INDEX c1x ON c1(x);
34269c15feeSdrh  SELECT * FROM c1 WHERE x=y AND y=z AND z='abc';
34369c15feeSdrh} {ABC ABC abc}
34469c15feeSdrhdo_execsql_test transitive1-560eqp {
34569c15feeSdrh  EXPLAIN QUERY PLAN
34669c15feeSdrh  SELECT * FROM c1 WHERE x=y AND y=z AND z='abc';
3478210233cSdrh} {/SCAN c1/}
34869c15feeSdrhdo_execsql_test transitive1-570 {
34969c15feeSdrh  SELECT * FROM c1 WHERE x=y AND z=y AND z='abc';
35069c15feeSdrh} {}
35169c15feeSdrhdo_execsql_test transitive1-570eqp {
35269c15feeSdrh  EXPLAIN QUERY PLAN
35369c15feeSdrh  SELECT * FROM c1 WHERE x=y AND z=y AND z='abc';
3548210233cSdrh} {/SEARCH c1 USING INDEX c1x/}
35570a0222fSdrh
35667656ac7Sdrh# 2021-05-04 forum https://sqlite.org/forum/forumpost/eb8613976a
35767656ac7Sdrhreset_db
35867656ac7Sdrhdo_execsql_test transitive1-600 {
35967656ac7Sdrh  CREATE TABLE t0(a0 INT, b1 INT);
36067656ac7Sdrh  CREATE INDEX t0b1 ON t0(b1);
36167656ac7Sdrh  CREATE TABLE t1(w,x,y,z3 INT);
36267656ac7Sdrh  INSERT INTO t0(a0, b1) VALUES (0,1);
36367656ac7Sdrh  INSERT INTO t1(w,x,y,z3) VALUES (7,8,9,1);
36467656ac7Sdrh} {}
36567656ac7Sdrhdo_execsql_test transitive1-610 {
36667656ac7Sdrh  SELECT ALL * FROM t0,t1 WHERE b1=z3 AND a0=z3;
36767656ac7Sdrh} {}
36867656ac7Sdrhdo_execsql_test transitive1-620 {
36967656ac7Sdrh  SELECT ALL * FROM t0,t1 WHERE likely(b1=z3) AND a0=z3;
37067656ac7Sdrh} {}
37167656ac7Sdrhdo_execsql_test transitive1-630 {
37267656ac7Sdrh  DROP TABLE t0;
37367656ac7Sdrh  DROP TABLE t1;
37467656ac7Sdrh  CREATE TABLE t0(c0 INT, c1 INT UNIQUE);
37567656ac7Sdrh  CREATE TABLE t1(c0 INT);
37667656ac7Sdrh  INSERT INTO t0(c0, c1) VALUES (0, 1);
37767656ac7Sdrh  INSERT INTO t1(c0) VALUES (1);
37867656ac7Sdrh  SELECT ALL * FROM t1 NATURAL JOIN t0 WHERE (t1.c0=t0.c1);
37967656ac7Sdrh  SELECT ALL * FROM t1 NATURAL JOIN t0 WHERE (likely(t1.c0=t0.c1));
38067656ac7Sdrh  SELECT ALL * FROM t1,t0 WHERE (likely(t1.c0=t0.c1) AND t1.c0=t0.c0);
38167656ac7Sdrh} {}
38267656ac7Sdrh
383beed24d5Sdan#-------------------------------------------------------------------------
384beed24d5Sdan# 2021-08-31 forum https://sqlite.org/forum/forumpost/8d1b58f112
385beed24d5Sdanreset_db
386beed24d5Sdando_execsql_test transitive1-700 {
387beed24d5Sdan  CREATE TABLE t1(a INT PRIMARY KEY);
388beed24d5Sdan  INSERT INTO t1(a) VALUES(1),(2),(3);
389beed24d5Sdan  CREATE TABLE t2(x INTEGER PRIMARY KEY,y INT);
390beed24d5Sdan  INSERT INTO t2(y) VALUES(2),(3);
391beed24d5Sdan}
392beed24d5Sdan
393beed24d5Sdando_execsql_test transitive1-710 {
394beed24d5Sdan  SELECT * FROM t1 CROSS JOIN t2 WHERE t2.y=t1.a AND t1.a=t2.x
395beed24d5Sdan} {}
396beed24d5Sdan
397beed24d5Sdando_execsql_test transitive1-720 {
398beed24d5Sdan  SELECT * FROM t1 CROSS JOIN t2 WHERE likely(t2.y=t1.a) AND unlikely(t1.a=t2.x)
399beed24d5Sdan} {}
400beed24d5Sdan
40136db90d3Sdrh# 2021-10-04 forum https://sqlite.org/forum/forumpost/a65cacbf5e1c41ba
40236db90d3Sdrh#
40336db90d3Sdrhreset_db
40436db90d3Sdrhdo_execsql_test transitive1-800 {
40536db90d3Sdrh  CREATE TABLE t1(a INT);
40636db90d3Sdrh  INSERT INTO t1 VALUES(0),(3);
40736db90d3Sdrh  CREATE TABLE t2(b INT UNIQUE, c INT);
40836db90d3Sdrh  INSERT INTO t2 VALUES(1,4)	,(0,5);
40936db90d3Sdrh  SELECT * FROM t1 WHERE EXISTS (SELECT 1 FROM t2 WHERE c=a AND b IS a);
41036db90d3Sdrh  SELECT * FROM t1 WHERE EXISTS (SELECT 1 FROM t2 WHERE a=c AND a IS b);
41136db90d3Sdrh  SELECT * FROM t1 WHERE EXISTS (SELECT 1 FROM t2 WHERE a=c AND b IS a);
41236db90d3Sdrh  SELECT * FROM t1 WHERE EXISTS (SELECT 1 FROM t2 WHERE c=a AND a IS b);
41336db90d3Sdrh} {}
414*3768f175Sdrhdo_execsql_test transitive1-810 {
415*3768f175Sdrh  CREATE TABLE t3(a INTEGER PRIMARY KEY,b);
416*3768f175Sdrh  INSERT INTO t3(a,b) VALUES(1,2),(5,5),(7,11);
417*3768f175Sdrh  SELECT * FROM t3 WHERE a=b AND a='5';
418*3768f175Sdrh} {5 5}
419*3768f175Sdrhdo_execsql_test transitive1-811 {
420*3768f175Sdrh  SELECT * FROM t3 WHERE a=b AND a='4';
421*3768f175Sdrh} {}
422*3768f175Sdrhdo_execsql_test transitive1-812 {
423*3768f175Sdrh  SELECT * FROM t3 WHERE a=b AND a='7';
424*3768f175Sdrh} {}
425*3768f175Sdrhdo_execsql_test transitive1-813 {
426*3768f175Sdrh  SELECT * FROM t3 WHERE a=b AND a='5x';
427*3768f175Sdrh} {}
42836db90d3Sdrh
42963db0392Sdrhfinish_test
430